Difference between revisions of "ToCartOffset"
From SCAR Divi Manual
(Created page with "==Definition== <source lang="scar" lines="false"> function ToCartOffset(Point: PPoint; offset: TPoint): TPoint; </source> ===Source Code=== <source lang="scar"> function ToCartO...") |
(No difference)
|
Revision as of 12:57, 3 July 2011
Definition
function ToCartOffset(Point: PPoint; 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)