SRL Archive - Research & Development Lounge

getting a polar point


Awkwardsaw

2009-12-05 20:49:39

this should counvert a normal point into a Polar Point, :p

i know there is a function in scar, but i dont know how to use the PPoint, since its properties doesnt show up in ctrl + space :p

program New;
{.Include SRL/SRL.scar}

type
TPolarPoint = record
rad, theta : integer;
end;

function get_polar(x, y: integer; mr : integer): TPolarPoint;
var
t : TPoint;
begin
if not InCircle(x, y, 0, 0, mr) then exit;
result.rad := mr;
while InCircle(x, y, 0, 0, result.rad) do
begin
result.rad := result.rad - 1;
if result.rad <= 0 then
exit;
end;
result.theta := 360;
t := point(0, 0);
while inAngle(t, 0, result.theta, 0, result.rad, X, Y) do
begin
result.theta := result.theta - 2;
if result.theta < 0 then
begin
result.theta := 0;
exit;
end;
wait(1);
end;
end;

var p : TPolarPoint;
begin
p := get_polar(1, 1, 5);
writeln(inttostr(p.rad) + ' ' + inttostr(p.theta));
end.

feedback pl0x

Quickmarch

2009-12-06 03:02:00

ToPolar works exactly the same as your function…

A PPoint is just the same as your TPolarPoint.

Awkwardsaw

2009-12-06 08:45:30

ok, then how do you use it?

its clearly not the exact same, or i wouldnt have made this :)

Wizzup?

2009-12-06 08:55:43

Angle = ArcTan2, Length = Sqrt(Sqr(x) + Sqr(y));

lordsaturn

2009-12-06 14:08:26

I know there's a thread somewhere, just a sec..


http://www.villavu.com/forum/showthread.php?t=37474&p=474683