RotationMatrix Class¶
The RotationMatrix class represents attitude using Direction Cosine Matrices (DCM) for spacecraft orientation and coordinate transformations.
RotationMatrix
¶
RotationMatrix(r11: float, r12: float, r13: float, r21: float, r22: float, r23: float, r31: float, r32: float, r33: float)
Represents a rotation using a 3x3 rotation matrix (Direction Cosine Matrix).
A rotation matrix is an orthogonal 3x3 matrix with determinant +1 that represents rotation in 3D space. Also known as a Direction Cosine Matrix (DCM).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r11
|
float
|
Element at row 1, column 1 |
required |
r12
|
float
|
Element at row 1, column 2 |
required |
r13
|
float
|
Element at row 1, column 3 |
required |
r21
|
float
|
Element at row 2, column 1 |
required |
r22
|
float
|
Element at row 2, column 2 |
required |
r23
|
float
|
Element at row 2, column 3 |
required |
r31
|
float
|
Element at row 3, column 1 |
required |
r32
|
float
|
Element at row 3, column 2 |
required |
r33
|
float
|
Element at row 3, column 3 |
required |
Raises:
| Type | Description |
|---|---|
BraheError
|
If the matrix is not a valid rotation matrix |
Example
import brahe as bh
import numpy as np
# Create identity rotation
dcm = bh.RotationMatrix(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
# Create from numpy array
R = np.eye(3)
dcm2 = bh.RotationMatrix.from_matrix(R)
# Convert to quaternion
q = dcm.to_quaternion()
# Rotate a vector
v = np.array([1.0, 0.0, 0.0])
v_rot = dcm.rotate_vector(v)
Initialize instance.
__doc__
class-attribute
¶
__doc__ = 'Represents a rotation using a 3x3 rotation matrix (Direction Cosine Matrix).\n\nA rotation matrix is an orthogonal 3x3 matrix with determinant +1 that\nrepresents rotation in 3D space. Also known as a Direction Cosine Matrix (DCM).\n\nArgs:\n r11 (float): Element at row 1, column 1\n r12 (float): Element at row 1, column 2\n r13 (float): Element at row 1, column 3\n r21 (float): Element at row 2, column 1\n r22 (float): Element at row 2, column 2\n r23 (float): Element at row 2, column 3\n r31 (float): Element at row 3, column 1\n r32 (float): Element at row 3, column 2\n r33 (float): Element at row 3, column 3\n\nRaises:\n BraheError: If the matrix is not a valid rotation matrix\n\nExample:\n ```python\n import brahe as bh\n import numpy as np\n\n # Create identity rotation\n dcm = bh.RotationMatrix(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)\n\n # Create from numpy array\n R = np.eye(3)\n dcm2 = bh.RotationMatrix.from_matrix(R)\n\n # Convert to quaternion\n q = dcm.to_quaternion()\n\n # Rotate a vector\n v = np.array([1.0, 0.0, 0.0])\n v_rot = dcm.rotate_vector(v)\n ```'
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
__module__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
Rx
builtin
¶
Rx(angle: float, angle_format: AngleFormat) -> RotationMatrix
Create a rotation matrix for rotation about the X axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
Rotation angle in radians or degrees |
required |
angle_format
|
AngleFormat
|
Units of input angle (RADIANS or DEGREES) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix |
RotationMatrix
|
Rotation matrix for X-axis rotation |
Ry
builtin
¶
Ry(angle: float, angle_format: AngleFormat) -> RotationMatrix
Create a rotation matrix for rotation about the Y axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
Rotation angle in radians or degrees |
required |
angle_format
|
AngleFormat
|
Units of input angle (RADIANS or DEGREES) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix |
RotationMatrix
|
Rotation matrix for Y-axis rotation |
Rz
builtin
¶
Rz(angle: float, angle_format: AngleFormat) -> RotationMatrix
Create a rotation matrix for rotation about the Z axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
Rotation angle in radians or degrees |
required |
angle_format
|
AngleFormat
|
Units of input angle (RADIANS or DEGREES) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix |
RotationMatrix
|
Rotation matrix for Z-axis rotation |
__new__
builtin
¶
Create and return a new object. See help(type) for accurate signature.
from_euler_angle
builtin
¶
from_euler_angle(e: EulerAngle) -> RotationMatrix
Create a rotation matrix from Euler angles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e
|
EulerAngle
|
Euler angle representation |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix |
RotationMatrix
|
Equivalent rotation matrix |
from_euler_axis
builtin
¶
from_euler_axis(e: EulerAxis) -> RotationMatrix
Create a rotation matrix from an Euler axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e
|
EulerAxis
|
Euler axis representation |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix |
RotationMatrix
|
Equivalent rotation matrix |
from_matrix
builtin
¶
from_matrix(m: ndarray) -> RotationMatrix
Create a rotation matrix from a 3x3 numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
m
|
ndarray
|
3x3 rotation matrix |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix |
RotationMatrix
|
New rotation matrix instance |
Raises:
| Type | Description |
|---|---|
BraheError
|
If the matrix is not a valid rotation matrix |
from_quaternion
builtin
¶
from_quaternion(q: Quaternion) -> RotationMatrix
Create a rotation matrix from a quaternion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
Quaternion
|
Source quaternion |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix |
RotationMatrix
|
Equivalent rotation matrix |
from_rotation_matrix
builtin
¶
from_rotation_matrix(r: RotationMatrix) -> RotationMatrix
Create a rotation matrix from another rotation matrix (copy constructor).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
RotationMatrix
|
Source rotation matrix |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix |
RotationMatrix
|
New rotation matrix instance |
to_euler_angle
method descriptor
¶
to_euler_angle(order: str) -> EulerAngle
Convert to Euler angle representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
str
|
Desired rotation sequence (e.g., "XYZ", "ZYX") |
required |
Returns:
| Name | Type | Description |
|---|---|---|
EulerAngle |
EulerAngle
|
Equivalent Euler angles |
to_euler_axis
method descriptor
¶
to_euler_axis() -> EulerAxis
Convert to Euler axis representation.
Returns:
| Name | Type | Description |
|---|---|---|
EulerAxis |
EulerAxis
|
Equivalent Euler axis |
to_matrix
method descriptor
¶
to_matrix() -> ndarray
Convert rotation matrix to a 3x3 numpy array.
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: 3x3 rotation matrix |
to_quaternion
method descriptor
¶
to_quaternion() -> Quaternion
Convert to quaternion representation.
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion |
Quaternion
|
Equivalent quaternion |
to_rotation_matrix
method descriptor
¶
to_rotation_matrix() -> RotationMatrix
Convert to rotation matrix representation (returns self).
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix |
RotationMatrix
|
This rotation matrix |