Inverse Sin in Python?? Please help

I am working on a script to calculate angles, but all equations for working out angles that I know require you to use sin-1 tan-1 or cos-1, how can I do this is blender? I have tried all that I can (itan invtan etc) but none work

Can anyone help?

Thanks,
Ian

1 Like

Use the asin, acos and atan function from the math module (it’s a standard Python module, not part of Blender).

import math

print math.asin(0.5)

or

from math import *

print asin(0.5)

Note that the trig functions in math return and use radians, not degrees.

Martin

martin: Thanks for the fast reply, but
If sin a = b, then sin^-1 b = a
Using asin, I cannot get the right answer:

sin(2) = 0.909
asin(0.909) = 1.14

I dont think asin is the same as inverse sin.

Does anyone know the formula for the sin curve? I can use that instead of a pre-defined function such as asin.

Thanks

Sorry, I have just tried it again and found that

a = sin(2)
b = asin(a)
b doesnt = 2

but

a = cos(2)
b = acos(a)
b DOES= 2

I think the problem was with the initial number I used.

I had found this earlier on the python site, but had only tried asin and so had thought it didnt work. Sorry!

IAn

Because y = sin(x) is a repetitive function, there is more than one value of x for every value of y. ie sin(2) = sin(1.14) = 0.909

Therefore, when you do x = asin(y), you will only ever get a value between -PI/2 <= x <= PI/2