spatial
Spatial and 6-DOF utility operations for trajectory optimization.
This module provides efficient symbolic expression nodes for common 6-DOF (six degree of freedom) operations used in aerospace and robotics applications. These operations directly map to optimized JAX implementations for high-performance evaluation.
QDCM
¶
Bases: Expr
Quaternion to Direction Cosine Matrix (DCM) conversion.
Converts a unit quaternion representation to a 3x3 direction cosine matrix (also known as a rotation matrix). This operation is commonly used in 6-DOF spacecraft dynamics, aircraft simulation, and robotics applications.
The quaternion is expected in scalar-last format: [qx, qy, qz, qw] where qw is the scalar component. The resulting DCM can be used to transform vectors from one reference frame to another.
Attributes:
| Name | Type | Description |
|---|---|---|
q |
Quaternion expression with shape (4,) |
Example
Use the QDCM to rotate a vector:
import openscvx as ox
q = ox.State("q", shape=(4,))
dcm = ox.QDCM(q) # Creates rotation matrix, shape (3, 3)
v_body = ox.Variable("v_body", shape=(3,))
v_inertial = dcm @ v_body
Note
The input quaternion does not need to be normalized; the implementation automatically handles normalization during evaluation.
Source code in openscvx/symbolic/expr/spatial.py
check_shape() -> Tuple[int, ...]
¶
Check that input is a quaternion and return DCM shape.
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Tuple[int, ...]
|
Shape (3, 3) for the resulting direction cosine matrix |
Raises:
| Type | Description |
|---|---|
ValueError
|
If quaternion does not have shape (4,) |
Source code in openscvx/symbolic/expr/spatial.py
SSM
¶
Bases: Expr
Angular rate vector to 3x3 skew-symmetric matrix (cross product matrix).
Constructs the 3x3 skew-symmetric matrix [ω]x that represents the cross product operation. For any 3D vector v, the cross product ω x v can be computed as the matrix-vector product [ω]x @ v.
The resulting matrix has the form
⎡ 0 -ωz ωy ⎤ ⎢ ωz 0 -ωx ⎥ ⎣-ωy ωx 0 ⎦
This operation is widely used in: - Rigid body dynamics (angular momentum calculations) - DCM time derivatives: Ṙ = [ω]x @ R - Velocity kinematics in robotics - Coriolis and centrifugal acceleration terms
Attributes:
| Name | Type | Description |
|---|---|---|
w |
Angular velocity or 3D vector expression with shape (3,) |
Example
Use the SSM to compute the rotation matrix derivative:
import openscvx as ox
omega = ox.Control("omega", shape=(3,))
R = ox.State("R", shape=(3, 3)) # Direction cosine matrix
# DCM time derivative
R_dot = ox.SSM(omega) @ R
Note
The skew-symmetric property ensures that [ω]xᵀ = -[ω]x, which is important for preserving orthogonality in DCM propagation.
See Also
SSMP: 4x4 skew-symmetric matrix for quaternion dynamics
Source code in openscvx/symbolic/expr/spatial.py
check_shape() -> Tuple[int, ...]
¶
Check that input is a 3D vector and return matrix shape.
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Tuple[int, ...]
|
Shape (3, 3) for the resulting skew-symmetric matrix |
Raises:
| Type | Description |
|---|---|
ValueError
|
If input vector does not have shape (3,) |
Source code in openscvx/symbolic/expr/spatial.py
SSMP
¶
Bases: Expr
Angular rate to 4x4 skew-symmetric matrix for quaternion dynamics.
Constructs the 4x4 skew-symmetric matrix Ω(ω) used in quaternion kinematic differential equations. This matrix relates angular velocity to the time derivative of the quaternion:
q̇ = (1/2) * Ω(ω) @ q
The resulting matrix has the form
⎡ 0 ωz -ωy ωx ⎤ ⎢-ωz 0 ωx ωy ⎥ ⎢ ωy -ωx 0 ωz ⎥ ⎣-ωx -ωy -ωz 0 ⎦
This is particularly useful for formulating quaternion-based attitude dynamics in spacecraft and aircraft trajectory optimization problems.
Attributes:
| Name | Type | Description |
|---|---|---|
w |
Angular velocity vector expression with shape (3,) |
Example
Use the SSMP to compute the quaternion derivative:
import openscvx as ox
omega = ox.Control("omega", shape=(3,))
q = ox.State("q", shape=(4,))
# Quaternion kinematic equation
q_dot = 0.5 * ox.SSMP(omega) @ q
See Also
SSM: 3x3 skew-symmetric matrix for cross product operations
Source code in openscvx/symbolic/expr/spatial.py
check_shape() -> Tuple[int, ...]
¶
Check that input is a 3D angular velocity and return matrix shape.
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Tuple[int, ...]
|
Shape (4, 4) for the resulting skew-symmetric matrix |
Raises:
| Type | Description |
|---|---|
ValueError
|
If angular velocity does not have shape (3,) |