Hi there, I am trying to do a math operation, which is returning the following error:

# Error: ValueError: file line 50: math domain error

line 50 is: angle = math.acos(upRotated * P_V)

I don´t know why sometimes it happens when I change very very small values in an axis which doesn´t change the direction of the triangle built by the position of the 3 locators.

This is my code:

```
def getMDagPath(name):
dag = om.MDagPath()
sel = om.MSelectionList()
sel.add(name)
sel.getDagPath(0, dag)
return dag
def aimConstr(lct_, lct_A, lct_U):
vAim = om.MVector().xAxis
vUp = om.MVector().yAxis
P_dag = getMDagPath(lct_)
A_dag = getMDagPath(lct_A)
U_dag = getMDagPath(lct_U)
transformFn = om.MFnTransform(P_dag)
P_Pos = transformFn.rotatePivot(om.MSpace.kWorld)
transformFn.setObject(A_dag)
A_Pos = transformFn.rotatePivot(om.MSpace.kWorld)
transformFn.setObject(U_dag)
U_Pos = transformFn.rotatePivot(om.MSpace.kWorld)
aimVector = (A_Pos - P_Pos)
upVector = (U_Pos - P_Pos)
P_U = aimVector.normal()
P_V = upVector
P_W = (P_U ^ P_V).normal()
P_V = P_W ^ P_U
quaternionU = om.MQuaternion(vAim, P_U)
quaternion = quaternionU
upRotated = vUp.rotateBy(quaternion)
angle = math.acos(upRotated * P_V)
aimConstr("e", "t", "tup")
```

I have 3 locators: “e”, “t” and “tup”

the position of “e”: [-0.5, 0.0, 0.5]

the position of “t”: [-0.5, 0.5, 0.5]

the position of “tup”: [thisValueIsGettingTheErrorWhenIChange, 0.0, 0.5]

thisValueIsGettingTheErrorWhenIChange:

0.495 works!

0.497 doesn´t work…

0.498 works!

0.499 doesn´t work…

0.6180000000000001 work!

0.618 doesn´t work…

Does somebody know how to explain this?

thanks a lot!