View Full Version : Dumb Question (cos^-1)

04-10-2004, 10:10 PM
I'm just playing with Python 2.3, trying to get re-acquainted, and i've come across an extremely dumb problem, I don't know how to un-cosine (?) an angle on anything other than my calculator :p

I'm just writing something to solve some simple geometry (yeah, I'm pretty bored...), and when writing something to solve the formula:

cos (angle) = (a.b) / (|a|*|b|)

I can't get the angle because I don't know any function in any language equivalent to what cos^-1 would do on my calculator :p

Anybody know how to do it?

04-11-2004, 08:10 AM
Well, I don't know python but I can help you out some. You are trying to do the inverse cosine. If there isn't a inverse cosine function in python, this might help you out some:

x=cos(y) is the same as y=cos^-1(x)

04-11-2004, 11:46 AM
The "official" name is arccosine. So look for functions like with names like acos(), or arccos() (look also for asin(), atan(), since sometimes the arc-functions aren't complete and only one of the variants exists - because if you know the cosine of an angle you can calculate it's sine and tangent and use one of the other functions to get the angle). Also keep in mind that the result is probably in radians and not degrees.


04-17-2004, 09:20 PM
Also keep in mind that the result is probably in radians and not degrees.

I thought it would be acos(), but I never even thought to check in the function ref whether the output was in degrees or radians :P