I have to implement asin, acos and atan in environment where I have only following math tools:
I also already have reasonably good square root function.
Can I use those to implement reasonably efficient inverse trigonometric functions?
I don't need too big precision (the floating point numbers have very limited precision anyways), basic approximation will do.
I'm already half decided to go with table lookup, but I would like to know if there is some neater option (that doesn't need several hundred lines of code just to implement basic math).
EDIT:
To clear things up: I need to run the function hundreds of times per frame at 35 frames per second.
Do you need a large precision for arcsin(x)
function? If no you may calculate arcsin
in N nodes, and keep values in memory. I suggest using line aproximation. if x = A*x_(N) + (1-A)*x_(N+1)
then x = A*arcsin(x_(N)) + (1-A)*arcsin(x_(N+1))
where arcsin(x_(N))
is known.