mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Fix a couple mismatches of llAxes2Rot with actual behaviour.
For all zeros input, the result was <1,0,0,0> but we were producing <0,0,0,.5> because the first branch was taken. Fixed. We forgot to take the square root when calculating the magnitude of the quaternion while normalizing. Fixed. Use qnz instead of special casing.
This commit is contained in:
parent
2cca835ae9
commit
84648dadea
1 changed files with 3 additions and 4 deletions
|
@ -866,7 +866,7 @@ def llAxes2Rot(fwd, left, up):
|
||||||
# One of the hardest.
|
# One of the hardest.
|
||||||
|
|
||||||
t = math.fsum((fwd[0], left[1], up[2]))
|
t = math.fsum((fwd[0], left[1], up[2]))
|
||||||
if t >= 0.: # no danger of division by zero or negative roots
|
if t > 0.: # no danger of division by zero or negative roots
|
||||||
r = math.sqrt(1. + t)
|
r = math.sqrt(1. + t)
|
||||||
s = 0.5/r
|
s = 0.5/r
|
||||||
|
|
||||||
|
@ -892,9 +892,8 @@ def llAxes2Rot(fwd, left, up):
|
||||||
q = (s*(up[0]+fwd[2]), s*(left[2]+up[1]), r*0.5, s*(fwd[1]-left[0]))
|
q = (s*(up[0]+fwd[2]), s*(left[2]+up[1]), r*0.5, s*(fwd[1]-left[0]))
|
||||||
|
|
||||||
# Normalize
|
# Normalize
|
||||||
if q == (0.,0.,0.,0.):
|
q = qnz(q)
|
||||||
return Quaternion((0.,0.,0.,1.))
|
mag = math.sqrt(math.fsum((q[0]*q[0], q[1]*q[1], q[2]*q[2], q[3]*q[3])))
|
||||||
mag = math.fsum((q[0]*q[0], q[1]*q[1], q[2]*q[2], q[3]*q[3]))
|
|
||||||
return Quaternion(F32((q[0]/mag, q[1]/mag, q[2]/mag, q[3]/mag)))
|
return Quaternion(F32((q[0]/mag, q[1]/mag, q[2]/mag, q[3]/mag)))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue