Angle between two lines

hi EveryOne,

Can anybody tell me how to find an angle between two lines in flash.

Thanks in advance
Deepthi

  1. work out the gradients:
    var gradient:Number = (y2 - y1) / (x2 - x1);
    where (x1,y1) are the starting coordinates and (x2,y2) the ending coordinates of the line

  2. convert the gradient to an angle:
    var angle:Number = Math.atan(gradient);

  3. minus one from the other, get the absolute value and convert from radians to degrees:
    var difference:Number = Math.abs(angle1-angle2)*180/Math.PI; hope that helped.

Hey Tuncays, that’s really cool.

sweet++;

Thanks for sharing.