XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : cos to obtain an angle - help

03-04-2009, 02:58 AM
I am trying to obtain an angle in degrees.

I have the hypotenuse and the adjacent lengths, so I use cosine to obtain the angle but get different degrees in Maya versus my calc. (my calc. is correct, so something is missing from my Maya code).


float $hypotenuse = 25.110;
float $adjacent = 24.377;
print(rad_to_deg(cos($adjacent / $hypotenuse)));

I get 32.351

I should get 13.88 (http://www.easycalculation.com/trigonometry/triangle-angles.php)

What gives?

Here's something interesting as well:

// Result: 0.9708

// Result: 32.351

Somebody enlighten me please.

03-04-2009, 04:43 AM
You have it a little mixed up.

($adjacent / $hypotenuse) is equal to the cosine of the angle,
in other words:
float $cosA = $adjacent / $hypotenuse;

To get the angle from the cosine, you use the acos function.

print(rad_to_deg(acos($adjacent / $hypotenuse)));
// Result: 13.87805 //

03-04-2009, 04:44 AM
you need acos, not cos. :)

03-04-2009, 06:48 PM
I am much grateful; nonetheless, minutely embarrassed. Thank you much.

CGTalk Moderation
03-04-2009, 06:48 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.