pub struct Tracker { /* private fields */ }
Expand description
Orientation tracker: computes a device’s Orientation
from accelerometer
readings.
Implementations§
Source§impl Tracker
impl Tracker
Sourcepub fn new(threshold: impl Into<f32>) -> Self
pub fn new(threshold: impl Into<f32>) -> Self
Create a new orientation tracker.
The threshold
value should be slightly less than the absolute value
of the reading you get from the accelerometer when the device is lying
in a position where two of the axes are reading 0 (i.e. getting a
strong reading from one axis alone). It may require some
experimentation to properly tune this threshold.
For best results, set the accelerometer’s sensitivity higher than ±2g, e.g. ±4g or ±8g. This will help reduce noise in the accelerometer data.
Sourcepub fn update<V, C>(&mut self, acceleration: V) -> Orientation
pub fn update<V, C>(&mut self, acceleration: V) -> Orientation
Update the tracker’s internal state from the given acceleration vector
(i.e. obtained from Accelerometer::accel_norm
), returning a new
computed orientation value.
Sourcepub fn orientation(&self) -> Orientation
pub fn orientation(&self) -> Orientation
Get the last known orientation reading for the device.
Use Tracker::update
to obtain a new reading.