Fix global variable leakage, and join sequential variable definitions.

This commit is contained in:
Jürg Lehni 2013-06-17 08:10:57 -07:00
parent 2693516844
commit 5ff990a84a

View file

@ -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))