mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Fix global variable leakage, and join sequential variable definitions.
This commit is contained in:
parent
2693516844
commit
5ff990a84a
1 changed files with 8 additions and 8 deletions
|
@ -806,14 +806,14 @@ statics: {
|
||||||
* @return {Number} Curvatue of the curve at specified offset
|
* @return {Number} Curvatue of the curve at specified offset
|
||||||
*/
|
*/
|
||||||
getCurvatureAt: function(offset, isParameter) {
|
getCurvatureAt: function(offset, isParameter) {
|
||||||
values = this.getValues();
|
var values = this.getValues(),
|
||||||
// First derivative at offset/parameter
|
// First derivative at offset/parameter
|
||||||
var dt = Curve.evaluate(values, offset, isParameter, 1);
|
dt = Curve.evaluate(values, offset, isParameter, 1),
|
||||||
// Second derivative at offset/parameter
|
// Second derivative at offset/parameter
|
||||||
var d2t = Curve.evaluate(values, offset, isParameter, 3);
|
d2t = Curve.evaluate(values, offset, isParameter, 3),
|
||||||
var dx = dt.x, dy = dt.y, d2x = d2t.x, d2y = d2t.y;
|
dx = dt.x, dy = dt.y, d2x = d2t.x, d2y = d2t.y,
|
||||||
var isEnd = offset === 0 || ( isParameter )? offset === 1 :
|
isEnd = offset === 0 || ( isParameter )? offset === 1 :
|
||||||
offset === this.getLength();
|
offset === this.getLength();
|
||||||
//Calculate Curvature
|
//Calculate Curvature
|
||||||
// if at an end point, k = (2/3) * h / a^2
|
// if at an end point, k = (2/3) * h / a^2
|
||||||
// else, k = |dx * d2y - dy * d2x| / (( dx^2 + dy^2 )^(3/2))
|
// else, k = |dx * d2y - dy * d2x| / (( dx^2 + dy^2 )^(3/2))
|
||||||
|
|
Loading…
Reference in a new issue