Currently, running the following returns a vector of nans:
import spatial_casadi as sc
sc.Rotation.from_quat([0, 0, 0, 1]).as_rotvec()
It should return a zero vector. The issue is in line 423:
scale = theta / casadi.sin(theta * 0.5)
The limit as theta -> 0 of this expression is 2. But this returns nan.
Consider the implementation from scipy spatial, where they use a Taylor expansion to get around this:
angle = 2 * atan2(_norm3(quat_single), quat_single[3])
if angle <= 1e-3: # small angle Taylor series expansion
angle2 = angle * angle
scale = 2 + angle2 / 12 + 7 * angle2 * angle2 / 2880
else: # large angle
scale = angle / sin(angle / 2)
Perhaps something similar with ca.if_else would do the trick.
Currently, running the following returns a vector of nans:
It should return a zero vector. The issue is in line 423:
The limit as theta -> 0 of this expression is 2. But this returns nan.
Consider the implementation from scipy spatial, where they use a Taylor expansion to get around this:
Perhaps something similar with
ca.if_elsewould do the trick.