|
M5Unit-IMU 0.0.2 git rev:e5b00aa
|
Plain Hamilton quaternion (float) used to represent attitude. More...
#include <quaternion.hpp>
Public Member Functions | |
| Quaternion ()=default | |
| Default-construct as identity (no rotation) | |
| constexpr | Quaternion (const float w_, const float x_, const float y_, const float z_) |
| Construct from components. | |
| Quaternion | operator* (const Quaternion &rhs) const |
| Hamilton product (this rotation applied after rhs) | |
| Quaternion | conjugated () const |
| Conjugate (equals the inverse for a unit quaternion) | |
| float | normSq () const |
| Squared norm. | |
| float | norm () const |
| Norm (magnitude) | |
| bool | normalize () |
| Normalize this quaternion in place. | |
| Quaternion | normalized () const |
| Return a normalized copy. | |
| Vector3 | rotate (const Vector3 &v) const |
| Rotate a vector by this quaternion (active rotation, right-handed) | |
| void | toEuler (float &roll_deg, float &pitch_deg, float &yaw_deg) const |
| Decompose this quaternion into aerospace ZYX Euler angles. | |
| void | integrate (const Vector3 &gyro_rad_s, const float dt) |
| Integrate body-frame angular velocity over dt (gyro kinematics) | |
Static Public Member Functions | |
| static Quaternion | identity () |
| Identity quaternion (no rotation) | |
| static Quaternion | fromAxisAngle (const Vector3 &axis, const float angle_rad) |
| Build a rotation quaternion from an axis and angle. | |
| static Quaternion | fromEuler (const float roll_deg, const float pitch_deg, const float yaw_deg) |
| Build a rotation quaternion from aerospace ZYX Euler angles. | |
Public Attributes | |
| float | w {1.0f} |
| Scalar part. | |
| float | x {} |
| Vector part X. | |
| float | y {} |
| Vector part Y. | |
| float | z {} |
| Vector part Z. | |
Plain Hamilton quaternion (float) used to represent attitude.
Euler angle conversions use the aerospace ZYX (yaw-pitch-roll) convention, in degrees. Rotations are right-handed and active (rotate a vector, not the frame).
|
inlinestatic |
Build a rotation quaternion from an axis and angle.
| axis | Rotation axis (need not be normalized; zero axis yields identity) |
| angle_rad | Rotation angle in radians |
|
inlinestatic |
Build a rotation quaternion from aerospace ZYX Euler angles.
| roll_deg | Roll (X axis) in degrees |
| pitch_deg | Pitch (Y axis) in degrees |
| yaw_deg | Yaw (Z axis) in degrees |
|
inline |
Integrate body-frame angular velocity over dt (gyro kinematics)
| gyro_rad_s | Angular velocity in rad/s (body frame) |
| dt | Time step in seconds |
Advances this quaternion by dq = 0.5 * q (X) (0, gyro_rad_s) * dt and renormalizes to counteract integration drift.
|
inline |
Normalize this quaternion in place.
Rotate a vector by this quaternion (active rotation, right-handed)
| v | Vector to rotate |
|
inline |
Decompose this quaternion into aerospace ZYX Euler angles.
| [out] | roll_deg | Roll (X axis) in degrees |
| [out] | pitch_deg | Pitch (Y axis) in degrees |
| [out] | yaw_deg | Yaw (Z axis) in degrees |
The pitch asin argument is clamped to [-1, 1] so that values near the gimbal lock (pitch = +-90 deg) never produce NaN.