Difference between revisions of "ToPolarOffset"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> function ToPolarOffset(const Point, Offset: TPoint): PPoint; </source> ===Source Code=== <source lang="scar"> function ToPolarO...")
(No difference)

Revision as of 13:12, 3 July 2011

Definition

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

Source Code

function ToPolarOffset(const Point, Offset: TPoint): PPoint;
begin
  Point.X := Point.X - Offset.X;
  Point.Y := Point.Y - Offset.Y;
  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 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