Skip to main content

wrap_angle

Function wrap_angle 

Source
pub fn wrap_angle(t: f64) -> f64
Expand description

An angle moved into [0, 2π): what a periodic curve’s or surface’s parameter is reported in (docs/DATA-MODEL.md §Conventions). A negative angle whose sum with 2π rounds up to 2π becomes 0 — the same point on the circle, and inside the domain. A non-finite angle comes back unchanged.

use arris_math::wrap_angle;
use core::f64::consts::TAU;

assert_eq!(wrap_angle(0.0), 0.0);
assert_eq!(wrap_angle(-1.0), TAU - 1.0);
assert_eq!(wrap_angle(-1e-300), 0.0);
assert_eq!(wrap_angle(TAU + 1.0), 1.0);