Fix NaN in quaternion slerp when slerping opposite quaternions
All checks were successful
Run tests / Run tests (push) Successful in 7m18s
All checks were successful
Run tests / Run tests (push) Successful in 7m18s
This commit is contained in:
parent
28126518d5
commit
6601824986
1 changed files with 4 additions and 2 deletions
|
|
@ -265,8 +265,10 @@ namespace psemek::math
|
|||
auto const d = dot(q0.coords, q1.coords);
|
||||
|
||||
// prevent division by zero
|
||||
if (d >= T{1})
|
||||
return quaternion<T>{lerp(q0.coords, q1.coords, t)};
|
||||
if (d >= T{ 1})
|
||||
return quaternion<T>{lerp(q0.coords, q1.coords, t)};
|
||||
if (d <= T{-1})
|
||||
return quaternion<T>{lerp(q0.coords, -q1.coords, t)};
|
||||
|
||||
auto const omega = acos(abs(d));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue