ToCart

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

Definition

function ToCart(const Point: PPoint): TPoint;

Source Code

function ToCart(const Point: PPoint): TPoint;
var
  T: Double;
begin
  T := DegToRad(Point.T);
  Result.x := Round(Point.R * Cos(T));
  Result.y := Round(Point.R * Sin(T));
end;

Availability

SCAR Divi 3.00 > Current

Description

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

Example

var
  p: PPoint;
  tp: TPoint;

begin
  p.R := 4;
  p.T := 45;
  tp := ToCart(p);
  WriteLn('TPoint(' + IntToStr(tp.X) + ',' + IntToStr(tp.Y) + ')');
end.

Output:

TPoint(3,3)

See Also