Difference between revisions of "ToCart"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> function ToCart(Point: PPoint): TPoint; </source> ==Availability== SCAR Divi 3.00 > Current ==Description== Converts a given p...")
 
(Definition)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Definition==
 
==Definition==
 
<source lang="scar" lines="false">
 
<source lang="scar" lines="false">
function ToCart(Point: PPoint): TPoint;
+
function ToCart(const Point: PPoint): TPoint;
 +
</source>
 +
 
 +
===Source Code===
 +
<source lang="scar">
 +
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;
 
</source>
 
</source>
  
Line 8: Line 20:
  
 
==Description==
 
==Description==
Converts a given polar coordinate defined by the [[PPoint]] '''Point''' to a cartesian coordinate defined by a [[Tpoint]].
+
Converts a given polar coordinate defined by the [[PPoint]] '''Point''' to a cartesian coordinate defined by a [[TPoint]].
  
 
==Example==
 
==Example==
Line 17: Line 29:
  
 
begin
 
begin
   p.R := 1;
+
   p.R := 4;
   p.T := 1;
+
   p.T := 45;
 
   tp := ToCart(p);
 
   tp := ToCart(p);
 
   WriteLn('TPoint(' + IntToStr(tp.X) + ',' + IntToStr(tp.Y) + ')');
 
   WriteLn('TPoint(' + IntToStr(tp.X) + ',' + IntToStr(tp.Y) + ')');
Line 25: Line 37:
  
 
Output:
 
Output:
  TPoint(1,0)
+
  TPoint(3,3)
  
 
==See Also==
 
==See Also==

Latest revision as of 12:59, 3 July 2011

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