(10-28-2022, 10:26 PM)bplus Wrote:(10-28-2022, 10:05 PM)madscijr Wrote:(10-28-2022, 09:36 PM)bplus Wrote: Ugh! you make it W A Y too complicated! Sorry I got to say.
dx = change along x axis ie xnew = xold + dx
dy = change along y axis ie ynew = yold + dy
dx = speed * cos(directionRadians)
dy = speed * sin(directionRadians)
Thanks for your reply!
I probably do make it too complicated.
The whole radians thing confuses me.
According to this article, 1 radian = distanceTravelled/radius.
That makes no sense to me in this context,
since there is no circle and hence no radius.
What should the radius be?
Half the screen width (or height, whichever is bigger)?
Or if the world extends to beyond the screen, half of that width?
And what is distance travelled supposed to be?
Sorry, I do believe you, I just totally suck at math.
(Also the precalculated arrays for dx/dy to degrees are to save having to do math on the fly.)
I did offer this in attempts to help, but glad to answer questions, hope they help.
There 2 different ways (actually more but...) to measure an angle one way is Degrees units and the other Radians units.
Radians can be converted to Degrees or Degrees to Radians just like inches can be converted to centimeters and centimeters to inches or Temperature can be told in Fahrenheit or Celsius. Just a unit of measure.
To convert between Degrees and Radians in QB64 we have _R2D(RadianAngle) Radians 2 (To) Degrees.
And the reverse Degrees to Radians use _D2R(angle in Degrees measure)
Or convert the old fashioned way before _R2D and _D2R
Degrees to Radians = Pi/180 * DegreesAngle
Radians to Degrees = 180/Pi * RadianAngle
(In fact I suspect this way slightly more efficient if you do the math Pi/180 = .017453292 or 180/Pi = 57.29577951, I see the later allot in old Basic code.)
I did try to provide some helper routines here:
https://staging.qb64phoenix.com/showthre...68#pid7768
The CosD() and SinD() functions allow you to work in Degrees and they convert to radians for you to get Sin() and Cos().
Quote:(Also the pre-calculated arrays for dx/dy to degrees are to save having to do some of the math on the fly.)Yeah in old days on mainframes sure not really necessary now unless you have some very special number crunching to do.
Checkout MasterGy, really fast 3D work without pre-calculated tables.
Wow, thanks for the info, I never knew!
I might not be a math wiz or even play one on TV, but I'll take good advice when it's offered.
(10-28-2022, 10:26 PM)bplus Wrote: I did try to provide some helper routines here:
https://staging.qb64phoenix.com/showthre...68#pid7768
The CosD() and SinD() functions allow you to work in Degrees and they convert to radians for you to get Sin() and Cos().
Very cool, that will come in handy for a lot of things, I think.
Thanks again!