ToPolarOffset

From SCAR Divi Manual
Jump to: navigation, search

Definition

function ToPolarOffset(const Point, Offset: TPoint): PPoint;

Source Code

function ToPolarOffset(const Point, Offset: TPoint): PPoint;
var
  p: TPoint;
begin
  p.X := Point.X - Offset.X;
  p.Y := Point.Y - Offset.Y;
  Result.R := Sqrt(Sqr(p.X) + Sqr(p.Y));
  Result.T := ArcTan2(p.Y, p.X);
  Result.T := RadToDeg(Result.T);
end;

Availability

SCAR Divi 3.00 > Current

Description

Converts a given cartesian coordinate defined by the TPoint Point with an offset given by Offset to a polar coordinate defined by a PPoint.

Example

var
  p: PPoint;

begin
  p := ToPolarOffset(Point(3, 4), Point(2, 2));
  WriteLn('PPoint(' + FloatToStr(p.R) + ';' + FloatToStr(p.T) + ')');
end.

Output:

PPoint(2,23606797749979;63,434948822922)

See Also