Skip to content

Commit

Permalink
Link quaternion and rotor functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderFabisch committed Sep 28, 2023
1 parent 6faa9ac commit 5e7515f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
12 changes: 12 additions & 0 deletions pytransform3d/rotations/_quaternion_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ def concatenate_quaternions(q1, q2):
-------
q12 : array-like, shape (4,)
Quaternion that represents the concatenated rotation q1 * q2
See Also
--------
concatenate_rotors : Concatenate rotors, which is the same operation.
"""
q1 = check_quaternion(q1, unit=False)
q2 = check_quaternion(q2, unit=False)
Expand All @@ -128,6 +132,10 @@ def q_prod_vector(q, v):
-------
w : array-like, shape (3,)
3d vector
See Also
--------
rotor_apply : The same operation with a different name.
"""
q = check_quaternion(q)
t = 2 * np.cross(q[1:], v)
Expand All @@ -150,6 +158,10 @@ def q_conj(q):
-------
q_c : array-like, shape (4,)
Conjugate (w, -x, -y, -z)
See Also
--------
rotor_reverse : Reverse of a rotor, which is the same operation.
"""
q = check_quaternion(q)
return np.array([q[0], -q[1], -q[2], -q[3]])
Expand Down
15 changes: 14 additions & 1 deletion pytransform3d/rotations/_rotors.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def rotor_reverse(rotor):
-------
reverse_rotor : array, shape (4,)
Reverse of the rotor: (a, b_yz, b_zx, b_xy)
See Also
--------
q_conj : Quaternion conjugate, which is the same operation.
"""
rotor = check_rotor(rotor)
return np.hstack(((rotor[0],), -rotor[1:]))
Expand All @@ -111,14 +115,19 @@ def concatenate_rotors(rotor1, rotor2):
-------
rotor : array, shape (4,)
rotor1 applied to rotor2: (a, b_yz, b_zx, b_xy)
See Also
--------
concatenate_quaternions : Concatenate quaternions, which is the same
operation.
"""
rotor1 = check_rotor(rotor1)
rotor2 = check_rotor(rotor2)
return concatenate_quaternions(rotor1, rotor2)


def rotor_apply(rotor, v):
r"""Compute rotation matrix from rotor.
r"""Apply rotor to vector.
.. math::
Expand All @@ -136,6 +145,10 @@ def rotor_apply(rotor, v):
-------
v : array, shape (3,)
Rotated vector
See Also
--------
q_prod_vector : The same operation with a different name.
"""
rotor = check_rotor(rotor)
return q_prod_vector(rotor, v)
Expand Down

0 comments on commit 5e7515f

Please sign in to comment.