Python Math

Ok, so I’m working on a .blend with triangles, heres and example of what the triangle would look like.
What I’m doing is trying to get angle A.
a,b,c are known values so according to good old trigonometry:

a^2 = b^2 + c^2 - 2bc*cosA

So, I’m after A and after rearranging the formula I get this:

cosA = (a^2)/(b^2 + c^2 - 2bc)

This wouldn’t be problem on my calculator, but in python how do I find the exact value of A not the value of cosA, I looked at the math module but I couldn’t figure out what to use.

And also, did I rearrange it correctly?

it’s an equation isn’t… so if you divide everything by Cos… will get rid of the get rid of the Cos in front of the A? so CosA/cos = ((a^2)/(b^2 + c^2 -2bc))/cos

so A = ((a^2)/(b^2 + c^2 -2bc))/cos ?? hmm I have no idea if this is correct.

It could work, it makes sense, I’ll give it a try later because I’m a bit short on time atm.

Edit, nvm that wont work. cos is a ratio so it has to be cos45 or something, cos by itself it meaningless really.

this should help…

  • the angles of a triangle if one knows the three sides:

code: A = acos((b2 + c2 - a**2)/(2bc))


REiKo Rhiemer;
Thanks, I tried using acos but got wierd results, it was only last night that I realised that it not onlyt takes radian input but it gives a radian output. At least I know its acos now.

I am glad you got it to work. Inverse trigonometric functions are fun :).

Radians become degrees if multiplied by 180, right?

1 rad = 180/pi;
so pi rad = 180 degrees;
pi/2 = 90 degrees and so on;

Conversely 1 degree = pi/180;
so 90 degree = pi/2

rad/degree conversions are easy beans if you just use math.radians(number in degrees) or math.degrees(number in radians)

Hah, I saw that function but didn’t know what it was for.