mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
angle_axis_from_quaternion
This commit is contained in:
parent
656a1d8b8e
commit
34b8326c7a
1 changed files with 11 additions and 0 deletions
|
@ -34,6 +34,17 @@ def quaternion_from_angle_axis(angle, axis):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def angle_axis_from_quaternion(quaternion):
|
||||||
|
axis = normalize(
|
||||||
|
quaternion[1:],
|
||||||
|
fall_back=np.array([1, 0, 0])
|
||||||
|
)
|
||||||
|
angle = 2 * np.arccos(quaternion[0])
|
||||||
|
if angle > TAU / 2:
|
||||||
|
angle = TAU - angle
|
||||||
|
return angle, axis
|
||||||
|
|
||||||
|
|
||||||
def quaternion_conjugate(quaternion):
|
def quaternion_conjugate(quaternion):
|
||||||
result = np.array(quaternion)
|
result = np.array(quaternion)
|
||||||
result[1:] *= -1
|
result[1:] *= -1
|
||||||
|
|
Loading…
Add table
Reference in a new issue