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...") |
|||
| Line 1: | Line 1: | ||
==Definition== | ==Definition== | ||
<source lang="scar" lines="false"> | <source lang="scar" lines="false"> | ||
| − | function ToCartOffset(Point: PPoint; | + | function ToCartOffset(const Point: PPoint; const Offset: TPoint): TPoint; |
</source> | </source> | ||
| Line 22: | Line 22: | ||
==Description== | ==Description== | ||
| − | Converts a given polar coordinate defined by the [[PPoint]] '''Point''' to a cartesian coordinate defined by a [[TPoint]] with an offset given by ''' | + | 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== | ==Example== | ||
Latest revision as of 12:57, 3 July 2011
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)