Shop OBEX P1 Docs P2 Docs Learn Events
polxy() method question — Parallax Forums

polxy() method question

Trying out the polxy Spin2 method is giving me results that I don't understand.
Per the Spin2 document:

POLXY(length, angle32bit) : x, y Convert (length,angle32bit) to (x,y)

Several examples show it used in repeat loops to display sin waves in debug scope windows using code like this (example):

repeat
  x, y := polxy($7FFF, z += $01000000)

I get an x and y when I run something like this but the x, y results don't make any sense to me. I believe its because of the angle32bit parameter. I did some searching but didn't find it defined anywhere. I assumed this method would allow me enter something like a 45 degree angle with a length of 14.14 and get an x and y value of 10.

Comments

  • AribaAriba Posts: 2,682

    angle32bit means: one turn (0..360°, 0..2Pi) is resolved to the full range of a 32bit integer (0..4294967296).

    CON
       _clkfreq = 160_000_000
    
       DEGREE   = $80000000 / 180
    
    PUB main() | cos, sin
      cos,sin := polxy(14_142, 45*DEGREE)
      debug(sdec(sin),sdec(cos))
    

    Andy

Sign In or Register to comment.