0
votes

A cosine is simply the result of a 90 degree shift of a sine value. I'm using a microcontroller with a software IEEE754 32-bit FPU, which has sin and cos functions. Sin and cos are relatively slow (around 800 cycles each), so it would make it faster if I could calculate the sine or cosine value and somehow derive the missing value. Is it possible?

1

1 Answers

2
votes

How fast is sqrt on your software FPU ? If it's faster than sin/cos then you can use the identity: sin(x)^2 + cos(x)^2 = 1, i.e.

cos(x) = sqrt(1 - sin(x)^2)

You'll need to take care of the +/- sign of course, but that's not a problem if you know which quadrant you're in.