ToPolar

From SCAR Divi Manual
Revision as of 13:03, 3 July 2011 by Freddy (talk | contribs) (Definition)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Definition

function ToPolar(const Point: TPoint): PPoint;

Source Code

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

Availability

SCAR Divi 3.00 > Current

Description

Converts a given cartesian coordinate defined by the TPoint Point to a polar coordinate defined by a PPoint.

Example

var
  p: PPoint;

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

Output:

PPoint(5;53,130102354156)

See Also