Fix llRot2Euler's return types.

It didn't return Vector in the singularity case. Also, it neglected to truncate the result to single precision.
This commit is contained in:
Sei Lisa 2017-01-23 16:39:58 +01:00
parent 84648dadea
commit 6ac02854aa

View file

@ -1584,15 +1584,15 @@ def llRot2Euler(r):
# Check gimbal lock conditions # Check gimbal lock conditions
if abs(y) > 0.99999: if abs(y) > 0.99999:
return (0., math.asin(y), math.atan2(2.*(r[2]*r[3]+r[0]*r[1]), return Vector(F32((0., math.asin(y), math.atan2(2.*(r[2]*r[3]+r[0]*r[1]),
1.-2.*(r[0]*r[0]+r[2]*r[2]))) 1.-2.*(r[0]*r[0]+r[2]*r[2])))))
qy2 = r[1]*r[1] qy2 = r[1]*r[1]
return Vector(( return Vector(F32((
math.atan2(2.*(r[0]*r[3]-r[1]*r[2]), 1.-2.*(r[0]*r[0]+qy2)), math.atan2(2.*(r[0]*r[3]-r[1]*r[2]), 1.-2.*(r[0]*r[0]+qy2)),
math.asin(y), math.asin(y),
math.atan2(2.*(r[2]*r[3]-r[0]*r[1]), 1.-2.*(r[2]*r[2]+qy2)) math.atan2(2.*(r[2]*r[3]-r[0]*r[1]), 1.-2.*(r[2]*r[2]+qy2))
)) )))
def llRot2Fwd(r): def llRot2Fwd(r):
assert isrotation(r) assert isrotation(r)