Math's Trig Versus Basic's Trig Functions
#3
This is a good thing for me to study, I think. I try to work in vectors mostly, but it would be helpful to have a deeper understanding of the coding differences for trig.

I prefer to work in math mode and so I generally resort to WINDOW commands to redefine my screen with (0, 0) at the desired central point and the axes appropriately flipped. Even then I find there are other things that need tweaking. For instance when I was doing the space vectoring thing I was using a 0/360 at the top and ascending clockwise, so in that instance I had to swap out SIN & COS as well as a few other tweaks to get it to work. In that program I was not having to define the whole screen, but rather just the sensor screen image and _PUTIMAGE-ing it to the main screen

For the unit circle visualizer it worked pretty well out of the gate except for an issue of going from 0-180 twice, rather than 0-360. First in quadrant I & II and then again from 0-180 in quadrant III & IV.

I ended up using a correctional branch, which seems to work fine:

    IF ci.y < 0 THEN ' aka the point is in quad. III & IV
        rad = TwoPI - ABS(_ATAN2(ci.y, ci.x))
    ELSE
        rad = _ATAN2(ci.y, ci.x)
    END IF


One thing my latest code did was get me more acquainted with PMAP since my redefined screen demands its use.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Reply


Messages In This Thread
RE: Math's Trig Versus Basic's Trig Functions - by OldMoses - 07-29-2022, 10:44 PM



Users browsing this thread: 17 Guest(s)