pub fn wrap_to_pi<T>(angle: T) -> T
Expand description
Wrap an angle to the range 0 to $\pm\pi$ radians
This function is generic and can be used with any type that implements the necessary traits.
§Arguments
angle
- The angle to be wrapped, which can be of any type that implements the necessary traits.
§Returns
- The wrapped angle, which will be in the range -π to π radians.
§Example
use strapdown::wrap_to_pi;
use std::f64::consts::PI;
let angle = 3.0 * PI / 2.0; // radians
let wrapped_angle = wrap_to_pi(angle);
assert_eq!(wrapped_angle, -PI / 2.0); // 3π/4 radians wrapped to -π/4 radians