udaan.manif package¶
Submodules¶
Module contents¶
- udaan.manif.Rot2Eul(R)[source]
- class udaan.manif.S2[source]
Bases:
objectUnit vector on the 2-sphere S2.
- Wraps a 3-vector (unit norm). Supports:
q1 - q2 -> TS2 (configuration error as tangent vector) q + w -> S2 (geodesic step via exponential map, w is a TS2)
- __init__(q=None)[source]
- property arr: ndarray
Plain numpy array (copy).
- error_vec(other, version=2)[source]
Configuration error vector on the tangent space.
- Parameters:
other – The other S2 point.
version – Error formula variant. 2 (default): hat(q)^2 @ q_other 1: q_other x q (cross product)
- Return type:
- static from_spherical(phi=0.0, th=0.0)[source]
Point on S2 from spherical coordinates (azimuth phi, polar th).
- step(omega_dt=None)[source]
Geodesic step on S2 via the exponential map.
- Parameters:
omega_dt – angular velocity scaled by dt (3-vector).
Returns a new S2 element: q_next = expm(hat(omega_dt)) @ q.
- class udaan.manif.SO3[source]
Bases:
objectRotation matrix on the Special Orthogonal group SO(3).
- Wraps a 3x3 rotation matrix. Supports:
R1 @ R2 -> SO3 (group composition, if both SO3) R @ v -> ndarray (rotate a vector) R1 - R2 -> TSO3 (configuration error in the Lie algebra) R + w -> SO3 (exponential map step, w is a TSO3) R.T -> SO3 (transpose, preserves type)
- property T: SO3
Transpose (same as inverse for SO3).
- __init__(R=None)[source]
- property arr: ndarray
Plain numpy array (copy).
- config_error(other)[source]
Scalar configuration error: 0.5 * tr(I - other^T @ self).
Returns 0 when self == other, approaches 2 for 180-degree error.
- Return type:
- static from_angle_axis(eta)[source]
Construct SO3 from an angle-axis vector via the exponential map.
- static from_tilt_yaw(tilt, yaw)[source]
Construct SO3 from a tilt vector and a yaw angle.
- static from_two_vectors(b3, b1)[source]
Construct SO3 from a primary axis (b3) and a heading hint (b1).
Builds an orthonormal frame [b1’, b2, b3] where b3 is preserved exactly, b1’ is the closest vector to b1 orthogonal to b3, and b2 = b3 x b1’. Handles the singularity when b3 is parallel to b1.
This is the standard construction for desired attitude from thrust direction (b3) and heading direction (b1).
- Return type:
- step(Omega_dt=None)[source]
Integrate angular velocity via the exponential map.
- Parameters:
Omega_dt – angular velocity scaled by dt (3-vector or TSO3).
Returns a new SO3 element: R_next = R @ expm(hat(Omega_dt)).
- class udaan.manif.TS2[source]
Bases:
objectTangent vector to the 2-sphere S2.
Wraps a 3-vector representing angular velocity or configuration error on the sphere. Supports:
v1 - v2 -> TS2 (tangent vector difference) v1 + v2 -> TS2 (tangent vector sum) v * s -> TS2 (scalar multiplication) v.transport(q) -> TS2 (project onto tangent space at q)
- __init__(vector=None)[source]
- property arr: ndarray
Plain numpy array (copy).
- property norm: float
Magnitude of the tangent vector.
- transport(q)[source]
Transport this tangent vector to the tangent space at q.
Computes -hat(q)^2 @ self, which projects self onto T_q S2 with the correct sign so that ew = w - wd.transport(q).
- Return type:
- property vector: ndarray
Raw 3-vector as a plain np.ndarray.
- class udaan.manif.TSO3[source]
Bases:
objectElement of the Lie algebra so(3) — tangent vector to SO(3).
Wraps a 3-vector representing angular velocity or rotation error. Supports:
w1 - w2 -> TSO3 (tangent vector difference) w1 + w2 -> TSO3 (tangent vector sum) w * s -> TSO3 (scalar multiplication) w.hat() -> 3x3 (skew-symmetric matrix in so(3)) w.transport(R_from, R_to) -> TSO3 (frame transport)
- __init__(vector=None)[source]
- property arr: ndarray
Plain numpy array (copy).
- property norm: float
Magnitude of the tangent vector.
- transport(R_from, R_to)[source]
Transport this tangent vector from R_from’s body frame to R_to’s.
Computes R_to^T @ R_from @ self, which maps an angular velocity (self) expressed in R_from’s frame into R_to’s frame.
- Return type:
Example
eOm = Om - Omd.transport(Rd, R) # angular velocity error
- property vector: ndarray
Raw 3-vector as a plain np.ndarray.
- udaan.manif.expm_taylor_expansion(M, order=2)[source]
- udaan.manif.hat(vector)[source]
- udaan.manif.rodrigues_expm(vector)[source]
Closed-form matrix exponential for so(3) via Rodrigues’ formula.
Exact for 3-vectors (skew-symmetric generators) and ~1.5x faster than scipy.linalg.expm over the hat map. Uses Taylor expansion for small angles to avoid division-by-zero and maintain accuracy.
- udaan.manif.vee(matrix)[source]