Triangle Trigonometry

Paul Rubin phr-n2001d at nightsong.com
Mon Dec 31 12:55:27 EST 2001


thelmagonzales99 at yahoo.com (Thelma F. Gonzales) writes:
> I'm trying to write a script that will calculate an unknown angle in a
> triangle. I have the value for the side adjacent and the side opposite
> of the angle in question, therefore I need to use the tangent
> function. I understand how to determine this value in decimal units,
> however I need degree units. I can reach down and pick up my trusty
> calculator and hit the inverse key and then the tangent key and viola
> I have my degree measurement. But, alas I do not want to use my old
> calculator to measure a few thousand angles, and I cannot figure out
> how to do this using the math module. Does anyone know how to invoke
> the "inverse" function in python?
> 
> Perhaps one of you kind folks can help me out, for I am completely
> frustrated.

There's no "inverse" function.  The inverse of the tangent function is
a separate function called the arctangent.  math.atan(x) gives the
arctangent of x.  math.atan2(x,y) gives the arctangent of x/y.
For what you're doing, you probably want atan2, which does the
right thing when y=0, and so forth.

Note that these functions give you the answer in radians.
To convert radians to degrees, multiply by 180/pi.



More information about the Python-list mailing list