1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! 2-D geometric operations relevant to integrated circuit layout.
//!
//! # Examples
//!
//! Create a [rectangle](crate::rect::Rect):
//!
//! ```
//! # use geometry::prelude::*;
//! let rect = Rect::from_sides(10, 20, 30, 40);
//! ```
#![warn(missing_docs)]

extern crate self as geometry;

pub mod align;
pub mod bbox;
pub mod contains;
pub mod corner;
pub mod dims;
pub mod dir;
pub mod edge;
pub mod intersect;
pub mod orientation;
pub mod place;
pub mod point;
pub mod polygon;
pub mod prelude;
pub mod rect;
pub mod ring;
pub mod shape;
pub mod side;
pub mod sign;
pub mod snap;
pub mod span;
pub mod transform;
pub mod union;

/// Wraps the given angle to the interval `[0, 360)` degrees.
///
/// # Examples
///
/// ```
/// use geometry::wrap_angle;
///
/// assert_eq!(wrap_angle(10.), 10.);
/// assert_eq!(wrap_angle(-10.), 350.);
/// assert_eq!(wrap_angle(-740.), 340.);
/// assert_eq!(wrap_angle(-359.), 1.);
/// assert_eq!(wrap_angle(-1.), 359.);
/// assert_eq!(wrap_angle(725.), 5.);
/// assert_eq!(wrap_angle(360.), 0.);
/// assert_eq!(wrap_angle(-360.), 0.);
/// ```
pub fn wrap_angle(angle: f64) -> f64 {
    ((angle % 360.) + 360.) % 360.
}