, \t\t , How to determine the angle needed to travel from X1,Y1 to X2, Y2.,,Relative angles,,, Drawing a line from 100, 100 to 200, 200 would mean that you are,, drawling your line at 135 degrees.,,, This function determines that angle.,,, function RelativeAngle(X1,Y1, X2,Y2 : Integer) : Integer;,, var,, Theta : Extended;,, XDist,,, YDist : Integer;,, begin,, Result := 0;,,, //arctan((y2-y1)/(x2-x1)),, XDist := X2 - X1;,, YDist := Y1 - Y2;,, if (XDist = 0) and (YDist=0) then exit;,,, if YDist=0 then,, Theta := arctan((X2-X1)),, else,, Theta := arctan((X2-X1)/(Y1-Y2));,,, Result := Round(RadToDeg(Theta)); , ,, if (X2 >= X1) and (Y2> = y1) dan /kwadrant = 2, resultaten: = 90 + (90 ABS (resultaten), andere, als (x < = X1) en (y > = y1) dan /kwadrant = 3 = 180 + resultaten: ook als (X2 < = X1) en (y < = y1) dan /kwadrant = 4 = 270 + 90, ABS (resultaten); de resultaten:,, een einde te maken aan de;,
Relative angle
Previous:De veelhoek?
Next Page:Het gebruik van Microsoft, de agent