From 05d251a953d7299ca9cc8f074e7beb4f63642268 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 21 Sep 2017 02:51:02 +0100 Subject: [PATCH] You cannot now overshoot the curve length in getUtoTmapping --- v3/src/paths/curves/Curve.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/v3/src/paths/curves/Curve.js b/v3/src/paths/curves/Curve.js index 42cfd5537..3fc739e4f 100644 --- a/v3/src/paths/curves/Curve.js +++ b/v3/src/paths/curves/Curve.js @@ -19,7 +19,7 @@ var Curve = new Class({ function Curve () { - this.arcLengthDivisions = 200; + this.arcLengthDivisions = 100; this.cacheArcLengths = []; @@ -122,6 +122,12 @@ var Curve = new Class({ this.getLengths(); }, + // Given a distance in pixels, get a t to find p. + getTFromDistance: function (distance, divisions) + { + return this.getUtoTmapping(0, distance, divisions); + }, + // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant getUtoTmapping: function (u, distance, divisions) @@ -135,7 +141,8 @@ var Curve = new Class({ if (distance) { - targetArcLength = distance; + // Cannot overshoot the curve + targetArcLength = Math.min(distance, arcLengths[il - 1]); } else {