Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rectangular/Polar coordinate converter using Inform-PE
#3
zip thats what this needs! thankyou!

BTW I think it would much more useful to have a R2P function and an P2R function. But how do you return two values? I guess you make it a sub and change the inputs to outputs, ie x, y in and angle, distance out for R2P and the reverse for P2R.

Like this:
Code: (Select All)
x = 10: y = 10
R2P x, y
Print x, y

P2R x, y
Print x, y

Sub R2P (XinAngleoutDegrees, YinDistanceOut)
    x = XinAngleoutDegrees
    y = YinDistanceOut
    XinAngleoutDegrees = _R2D(_Atan2(y, x))
    YinDistanceOut = Sqr(x * x + y * y)
End Sub

Sub P2R (AngleInDegreesXout, DistanceInYout)
    a = _D2R(AngleInDegreesXout)
    AngleInDegreesXout = DistanceInYout * Cos(a)
    DistanceInYout = DistanceInYout * Sin(a)
End Sub
b = b + ...
Reply


Messages In This Thread
RE: Rectangular/Polar coordinate converter using Inform-PE - by bplus - 09-05-2024, 10:34 PM



Users browsing this thread: 2 Guest(s)