09-03-2024, 01:57 PM (This post was last modified: 09-03-2024, 01:59 PM by bobalooie.)
Hello all,
I decided to experiment a bit with the Inform-PE system, so I resurrected a program I first wrote for a RS TRS-80 Model 4 with a hi-res graphics board. It is a small utility that converts rectangular 2D coordinates to polar and vice versa. The program also presents a simple 2D graphical view of the conversion result.
Comments and suggestions are welcomed.
Note to admins: I had to rename the R2P-Inform.frm file because the webpage wouldn't allow me to attach a .frm file. Is that something that can be fixed?
09-05-2024, 10:34 PM (This post was last modified: 09-05-2024, 11:02 PM by bplus.)
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
(09-07-2024, 01:01 PM)bplus Wrote: OK that might be it, I had it set on Degrees to do the first calc. It must of jumped back. That is unexpected behavior.
That's only because you weren't expecting it to reset. Now you know it will, so it's the expected result.
09-07-2024, 05:52 PM (This post was last modified: 09-07-2024, 05:55 PM by bplus.)
Well I said what I wanted to say, and I gave those 2 subs for handy tools to get those conversions without all the rig-a-ma-roll of an InForm app and still not have a couple of simple subs to take away from it.
Good practice with InForm, must of taken hours to assemble. I can't image waiting 2 minutes for every compile to get the thing up and running. Great effort there! I am sure Stax would appreciate the mathematically correct, anti-Basic way of graphing with Y axis increasing going up.