Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Dumb Question (cos^-1)

    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

    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

    Anybody know how to do it?

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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)
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    shmoove

  • #4
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb

    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

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •