1. Re: polar to rectangular conversion
At 03:54 97-06-29 +0000, Ralf wrote:
> Does anyone know how to calculate a new position from on old when
>you have an angle (360 degrees, no radians) and a distance?
global constant pi = 3.141592654
function Deg2Rad(atom deg) -- convert degree to radian
return deg/180*pi
end function
function Rad2Deg(atom radian)
return radian/pi*180
end function
function Polar2Rect(atom angle, atom distance) -- convert polar to rectangular
-- angle is in degree
x = cos(Deg2Rad(angle)*distance
y = sin(Deg2Rad(angle)*distance
return {x,y}
end function
function Rect2Polar(atom dx, atom dy) -- convert rectangular to polar
-- dx and dy are delta x and y between to points (or to the origin)
atom distance, angle
distance = sqrt(x*x + y*y)
angle = Rad2Deg(arctan(dy/dx)
return {angle,distance}
end function
Regards,
Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com