Results 1 to 4 of 4

Thread: Python asin function

  1. #1
    Join Date
    Dec 2006
    Location
    127.0.0.1
    Beans
    54
    Distro
    Ubuntu 9.10 Karmic Koala

    Python asin function

    Hi all....

    I've been trying to write a Python script to solve triangles given various types of information but I'm having a bit of trouble with math.asin()... The section that ails me at present looks like this:

    Code:
    . . .
            A = math.radians(A)
            sinB = (b*math.sin(A))/a
            B = math.asin(sinB)     #<---This is the part that screws me over.
            return B
    I can print B and it works just fine but the math.asin(sinB) part gives me a 'math domain error' and I have no idea why and there is a surprisingly small amount of documentation on the internet for this function. This is the exact error I'm getting:

    Code:
    Traceback (most recent call last):
      File "./trisol.py", line 71, in <module>
        print parseArgs(sys.argv)
      File "./trisol.py", line 17, in parseArgs
        return ssa(argv)
      File "./trisol.py", line 60, in ssa
        B = math.asin(sinB)
    ValueError: math domain error
    Any help would be greatly appreciated.
    Last edited by forsaken_pariah; May 11th, 2007 at 01:50 AM.

  2. #2
    Join Date
    Jan 2007
    Beans
    235

    Re: Python asin function

    Well arcsin obviously needs the domain of -1 to 1 since it is .. arcsin.. So, what are the values of b and a?
    Disregard anything I post...

  3. #3
    Join Date
    Dec 2006
    Location
    127.0.0.1
    Beans
    54
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Python asin function

    Never mind. It works now. I was drunk when I posted that last night. I didn't have any idea what I was doing.

  4. #4
    WW is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Oct 2004
    Beans
    1,532

    Re: Python asin function

    Heh, so you were DWI (*).

    Next time, bring along a friend as a Designated Developer.





















    * Developing While Intoxicated
    Last edited by WW; May 12th, 2007 at 03:39 AM.

Bookmarks

Posting Permissions

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