Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function AngleDegrees(pt1, pt2: TPoint): Extended;
- begin
- if (pt2.X = pt1.X) then
- begin
- if (pt2.Y > pt1.Y) then
- Result := 90.0
- else
- Result := 270.0;
- end else
- Result := (ArcTan2((pt2.Y - pt1.Y), (pt2.X - pt1.X)) * (180.0 / Pi));
- if (Result < 0) then
- Result := (Result + 360.0);
- end;
- function AngleDegrees2(pt1, pt2: TPoint): Extended;
- begin
- Result := (ArcTan2((pt2.Y - pt1.Y), (pt2.X - pt1.X)) * (180.0 / Pi));
- end;
- function AngleRadians(pt1, pt2: TPoint): Extended;
- begin
- Result := FixR(ArcTan2((pt2.Y - pt1.Y), (pt2.X - pt1.X)));
- end;
- function Angle(pt1, pt2: TPoint): Extended;
- begin
- Result := ((ArcTan2((pt2.Y - pt1.Y), (pt2.X - pt1.X)) * (180.0 / Pi)) + 90.0);
- if (Result < 0.0) then
- Result := (Result + 360.0);
- end;
- function DegreesToCompass(dgrs: Extended): Extended;
- begin
- Result := FixD(dgrs + 90.0);
- end;
- function CompassToDegrees(cmps: Extended): Extended;
- begin
- Result := FixD(cmps - 90.0);
- end;
- function RadiansToCompass(rdns: Extended): Extended;
- begin
- Result := FixD(Degrees(rdns) + 90.0);
- end;
- function CompassToRadians(cmps: Extended): Extended;
- begin
- Result := FixR(Radians(cmps - 90.0));
- end;
- var
- a, b: TPoint;
- begin
- ClearDebug;
- a := Point(10, 10);
- b := Point(20, 00);
- WriteLn(Angle(a, b));
- WriteLn(AngleDegrees(a, b));
- WriteLn(Degrees(CompassToRadians(DegreesToCompass(AngleDegrees2(a, b)))));
- WriteLn((Degrees(AngleRadians(a, b))));
- end.
Advertisement
Add Comment
Please, Sign In to add comment