ToCartOffset

From SCAR Divi Manual
Jump to: navigation, search

Definition

function ToCartOffset(const Point: PPoint; const Offset: TPoint): TPoint;

Source Code

function ToCartOffset(const Point: PPoint; const Offset: TPoint): TPoint;
var
  T: Double;
begin
  T := DegToRad(Point.T);
  Result.X := Round(Point.R * Cos(T));
  Result.Y := Round(Point.R * Sin(T));
  Result.X := Result.X + offset.X;
  Result.Y := Result.Y + offset.Y;
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 with an offset given by Offset.

Example

var
  p: PPoint;
  tp: TPoint;

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

Output:

TPoint(5,5)

See Also