Author Topic: Request - sine and cosine functions that outputs an 8.8 fixed point number  (Read 3392 times)

0 Members and 1 Guest are viewing this topic.

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Well, I'm working on a secret project atm. In order to make this project work, I need both a sine and cosine function that outputs an 8.8 fixed point number from -1 - 1.

My attempt in pure axe is this:

(sin(theta)*256)//128.0->Sine Answer
and
(cos(theta)*256)//128.0->Cosine Answer

The problem is that it only will work for positive sine and cosine answers.

So: does anyone have the hex for a sine and a cosine function for angles 0-255 (as in 256 = 0) that will output an 8.8 fixed point answer to HL and a positive/negative (1=neg,0=pos) flag to where ever axe's r6 (argument 6) is stored.

Thanks in advance!
« Last Edit: December 02, 2013, 12:54:32 pm by pimathbrainiac »
I am Bach.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Request - sine and cosine functions that outputs an 8.8 fixed point number
« Reply #1 on: December 02, 2013, 12:53:28 pm »
Hum, cos/sin already outputs fixed point ... it's just divided by 2.

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: Request - sine and cosine functions that outputs an 8.8 fixed point number
« Reply #2 on: December 02, 2013, 12:54:51 pm »
Hum, cos/sin already outputs fixed point ... it's just divided by 2.

so wait, if I multiply by 2, I get an 8.8 ranging from -1 to 1?
I am Bach.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Request - sine and cosine functions that outputs an 8.8 fixed point number
« Reply #3 on: December 02, 2013, 12:57:09 pm »
I guess so. ;)

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Request - sine and cosine functions that outputs an 8.8 fixed point number
« Reply #4 on: December 02, 2013, 12:58:29 pm »
Yes, but of course you'll lose one bit of precision. But I don't think that matters much.