![]() |
The Direction of a Vector | download program |
This article has been moved to
www.davdata.nl
please wait...
| 0 | right |
| 90 | down |
| 180 | left |
| 270 | up |
function Angle(x1,y1,x2,y2 : integer) : single; //return angle of line //right = 0; down = pi/2 (90) ; left = pi (180) ; up = 3pi/2 (270) begin if x1 = x2 then begin if y2 > y1 then result := 0.5*pi else result := 1.5*pi; exit; end; result := arctan((y2-y1)/(x2-x1)); if x2 < x1 then result := result + pi; if result < 0 then result := result + 2*pi; result := result * 180 / pi; //make degrees end;