Skip to content

Commit

Permalink
[SLERP] Return the first quaternion when the two quaternion are equal
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulero committed Nov 29, 2023
1 parent ea55d1f commit 2ac00cd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/liecasadi/quaternion.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ def slerp_step(q1: Vector, q2: Vector, t: Scalar) -> Vector:

dot = cs.dot(q1, q2)
angle = cs.acos(dot)
# if the angle is small (meaning the quaternions are "equal") we return the first quaternion
return Quaternion(
(cs.sin((1.0 - t) * angle) * q1 + cs.sin(t * angle) * q2) / cs.sin(angle)
cs.if_else(
angle < 1e-6,
q1,
(cs.sin((1.0 - t) * angle) * q1 + cs.sin(t * angle) * q2)
/ cs.sin(angle),
)
)

0 comments on commit 2ac00cd

Please sign in to comment.