Created
May 17, 2011 02:09
-
-
Save lucasmotta/975761 to your computer and use it in GitHub Desktop.
Returns a specific point from segments of points
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getPointAt(progress : Number) : Point | |
{ | |
var i : int; | |
var length : int = _points.length; | |
var pointProgress : Number; | |
var totalProgress : Number = 0; | |
for(i = 1 ; i < length; i++) | |
{ | |
pointProgress = Point.distance(_points[i], _points[i - 1]) / _length; | |
totalProgress += pointProgress; | |
if(totalProgress >= progress) | |
{ | |
return Point.interpolate(_points[i - 1], _points[i], (totalProgress - progress) / pointProgress); | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment