formula for inverse sine?

Started by
9 comments, last by angry 20 years ago
It happends to be that the language im writing my car game in doesn't have inverse sine and cos functions. It only has normal sin and cos. So how in the world am I supposed to calculate the inverse sin and cos? Anyone knows the formula for these two functions? [edit] though it has atan, could that be of any help? [edited by - angry on April 5, 2004 12:38:44 PM]
Advertisement
I think this is correct:
asin(s) = atan(s/sqrt(1-s*s))

You can do something similar with the inverse cosine, but only if -pi/2 < acos(x) < pi/2. Then acos(x) = atan(sqrt(1 - x^2) / x).

You could always do it the old-skool way and use a lookup table... Or switch to a language with a sensible set of standard functions. No inverse trig functions, sheesh! What is this, 1968?

[edited by - Muzzafarath on April 5, 2004 2:30:36 PM]
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
quote:Or switch to a language with a sensible set of standard functions. No inverse trig functions, sheesh! What is this, 1968?


LoL, well the language is called Lingo and is used for making "movies" in a program called Director. These "movies" can then be exported to shockwave movies, which then can be viewed on normal webpages...

Thanks for the replies!
Arcsin(X) = Atn(X / Sqr(-X * X + 1))


is the equation your looking for...
--What are you nutz?I have nothing to say to your unevolved little brain. The more I say gives you more weapons to ask stupid questions.
Is there an echo in here?
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
quote:Original post by Muzzafarath
You can do something similar with the inverse cosine, but only if -pi/2 < acos(x) < pi/2. Then acos(x) = atan(sqrt(1 - x^2) / x).

You could always do it the old-skool way and use a lookup table... Or switch to a language with a sensible set of standard functions. No inverse trig functions, sheesh! What is this, 1968?

[edited by - Muzzafarath on April 5, 2004 2:30:36 PM]



Actually VB doesn''t either......
--What are you nutz?I have nothing to say to your unevolved little brain. The more I say gives you more weapons to ask stupid questions.
quote:Original post by Muzzafarath
Actually VB doesn''t either......

thought we were speaking about programming languages?
Hmmm... This is not as accurate (since the series was not expanded far enough) as the method using atan but had there been no atan you could have done it so:

asin(n)
{
return n + power(n, 3)/ Factorial(3) + 9 *power(n, 5)/ Factorial(5) + 225 *power(n, 7)/ Factorial(7);
}

acos(n)
{
return PI/ 2 - asin(n);
}
[insert rant about how people should be using java applets for games, instead of trying to shoehorn the game into shockwave/flash, here]

This topic is closed to new replies.

Advertisement