Sin and Cos in Spin
Are there any objects already released that do Sin and Cos calculations.· If not, I could just use a floating point co-processor; I would just rather do it with software.
Thanks,
crgwbr
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
NerdMaster
For
Life
Thanks,
crgwbr
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
NerdMaster
For
Life
Comments
·
Here are a few routines that can be incorporated into any object.· Keep in mind, that the Propeller contains a ROM table for 1/4 of SIN.· Based on your degree value you either flip and/or mirror the data to get the proper quadrant. (The routine below does this for you).· The·SIN·angle is represented as a 13-bit value, while the returned value is represented as a signed 16-bit value.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
So to use those routines, I would use something like:
PropAng := DEG2PROP(270)
CosAng := Cos(PropAng)
SinAng := Sin(PropAng)
Would this work?
Thanks Again,
crgwbr
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
NerdMaster
For
Life
CosAng := Cos(DEG2PROP(270))
SinAng := Sin(DEG2PROP(270))
Here is an alternaive method to code the Sin routine that resolves the 4 quadrants using a case statement:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
NerdMaster
For
Life
http://en.wikipedia.org/wiki/Cordic
My intention was to releas the code in two forms, assembly to be inserted in to other assembly programs and as a high speed cordic object. The cordic method can be used for other things like sqrt and 1/x so it could sit in a cog and just churn out what was asked of it. I just need time to sit down and put it together but after my move I am still no quite unpacked.
I did release a basic demo program here though:
http://forums.parallax.com/forums/default.aspx?f=25&m=150119
Graham
Thanks Anyway,
crgwbr
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
NerdMaster
For
Life