-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
838ad70
commit 8ff7e77
Showing
6 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Modified Rodrigues parameters.""" | ||
import numpy as np | ||
from ._utils import check_mrp | ||
|
||
|
||
def concatenate_mrp(mrp1, mrp2): | ||
r"""Concatenate two rotations defined by modified Rodrigues parameters. | ||
Suppose we want to apply two extrinsic rotations given by modified | ||
Rodrigues parameters mrp1 and mrp2 to a vector v. We can either apply mrp2 | ||
to v and then mrp1 to the result or we can concatenate mrp1 and mrp2 and | ||
apply the result to v. | ||
The solution for concatenation of two rotations | ||
:math:`\boldsymbol{p}_1,\boldsymbol{p}_2` is given by Shuster [1]_: | ||
.. math:: | ||
\boldsymbol{p} = | ||
\frac{ | ||
(1 - ||\boldsymbol{p}_1||^2) \boldsymbol{p}_2 | ||
+ (1 - ||\boldsymbol{p}_2||^2) \boldsymbol{p}_1 | ||
- 2 \boldsymbol{p}_2 \times \boldsymbol{p}_1} | ||
{1 + ||\boldsymbol{p}_2||^2 ||\boldsymbol{p}_1||^2 | ||
- 2 \boldsymbol{p}_2 \cdot \boldsymbol{p}_1}. | ||
Parameters | ||
---------- | ||
mrp1 : array-like, shape (3,) | ||
Modified Rodrigues parameters. | ||
mrp2 : array-like, shape (3,) | ||
Modified Rodrigues parameters. | ||
Returns | ||
------- | ||
mrp12 : array, shape (3,) | ||
Modified Rodrigues parameters that represent the concatenated rotation | ||
of mrp1 and mrp2. | ||
References | ||
---------- | ||
.. [1] Shuster, M. D. (1993). A Survey of Attitude Representations. | ||
Journal of the Astronautical Sciences, 41, 439-517. | ||
http://malcolmdshuster.com/Pub_1993h_J_Repsurv_scan.pdf | ||
""" | ||
mrp1 = check_mrp(mrp1) | ||
mrp2 = check_mrp(mrp2) | ||
norm1_sq = np.linalg.norm(mrp1) ** 2 | ||
norm2_sq = np.linalg.norm(mrp2) ** 2 | ||
cross_product = np.cross(mrp2, mrp1) | ||
scalar_product = np.dot(mrp2, mrp1) | ||
return ( | ||
(1 - norm1_sq) * mrp2 + (1 - norm2_sq) * mrp1 - 2 * cross_product | ||
) / (1 + norm2_sq * norm1_sq - 2 * scalar_product) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import numpy as np | ||
import numpy.typing as npt | ||
|
||
|
||
def concatenate_mrp(mrp1: npt.ArrayLike, mrp2: npt.ArrayLike) -> np.ndarray: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters