demo.jpg_explanation demo.jpgI have a random serial points array like:
var arr:Array=[[115,195],[142,161],[177,132],[217,105],[258,122],[304,128],[361,119],[395,98],[427,65],[467,67],[501,93],[536,136],...]
Just click mouse on stage and push the mouseX,mouseY into the arr to got it.
I get the length of them by:
var _length:Number=0;
for(var i:int=1;i<arr.length;i++){
var p1:Point =new Point(arr[i-1].x,arr[i-1].y);
var p2:Point =new Point(arr[i].x,arr[i].y);
_length+=Point.distance(p1, p2);
}
Now I want to subdivie the line segment made by those points to equal segment by a random int: 10,or 11,20,...and the equal point must be on the line still .
I am not good at the Math,so sorry about that.I can't find the right function after some days trying to find it myself.
So,would you like to help me?
Best thanks and best wish to you!
Sorry for my English*^_^*
Ps:
I can get the point on the line by:
var p1:Point=new Point(Xn,Yn)
var p2:Point=new Point(Xn+1,Yn+1)
var p3:Point=Point.interpolate(p1,p2,m)//m= 0~1