pub trait SensorFusionMath: Sized {
// Required methods
fn estimate_gravity(q: Quaternion<Self>) -> Vector3d<Self>;
fn derivative(q: Quaternion<Self>, gyro: Vector3d<Self>) -> Quaternion<Self>;
fn madgwick_step_acc(
q: Quaternion<Self>,
acc: Vector3d<Self>,
max_acc_magnitude_squared: Self,
) -> Quaternion<Self>;
fn madgwick_step_acc_mag(
q: Quaternion<Self>,
acc: Vector3d<Self>,
mag: Vector3d<Self>,
max_acc_magnitude_squared: Self,
) -> Quaternion<Self>;
}Required Methods§
fn estimate_gravity(q: Quaternion<Self>) -> Vector3d<Self>
fn derivative(q: Quaternion<Self>, gyro: Vector3d<Self>) -> Quaternion<Self>
fn madgwick_step_acc( q: Quaternion<Self>, acc: Vector3d<Self>, max_acc_magnitude_squared: Self, ) -> Quaternion<Self>
fn madgwick_step_acc_mag( q: Quaternion<Self>, acc: Vector3d<Self>, mag: Vector3d<Self>, max_acc_magnitude_squared: Self, ) -> Quaternion<Self>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl SensorFusionMath for f32
impl SensorFusionMath for f32
Source§fn madgwick_step_acc(
q: Quaternion<Self>,
acc: Vector3d<Self>,
max_acc_magnitude_squared: Self,
) -> Quaternion<Self>
fn madgwick_step_acc( q: Quaternion<Self>, acc: Vector3d<Self>, max_acc_magnitude_squared: Self, ) -> Quaternion<Self>
Features of this implementation:
-
Parallel Throughput: Instead of 12 separate floating-point multiplications and 8 additions, the SIMD unit performs 3 vector multiplications and 2 vector additions.
-
Instruction Density: The
simd_swizzle!maps directly to the VREV or VMOV instructions on the M33. -
Register Reuse:
q_vstays in its SIMD register the entire time. The compiler will likely use VFMA (Vector Fused Multiply-Add) to combine the terms, meaning this whole function could resolve in under 15 clock cycles.