Classifies a rotation in radians into an [`AngleType`]. Normalises to `[0, 2π)` first, then checks within `EPS` of each cardinal.
(radians: f32)
| 81 | /// Classifies a rotation in radians into an [`AngleType`]. |
| 82 | /// Normalises to `[0, 2π)` first, then checks within `EPS` of each cardinal. |
| 83 | pub fn classify_angle(radians: f32) -> AngleType { |
| 84 | let normalized = radians.rem_euclid(std::f32::consts::TAU); |
| 85 | const EPS: f32 = 0.001; |
| 86 | if normalized < EPS || (std::f32::consts::TAU - normalized) < EPS { |
| 87 | AngleType::Zero |
| 88 | } else if (normalized - std::f32::consts::FRAC_PI_2).abs() < EPS { |
| 89 | AngleType::Right90 |
| 90 | } else if (normalized - std::f32::consts::PI).abs() < EPS { |
| 91 | AngleType::Straight180 |
| 92 | } else if (normalized - 3.0 * std::f32::consts::FRAC_PI_2).abs() < EPS { |
| 93 | AngleType::Right270 |
| 94 | } else { |
| 95 | AngleType::Arbitrary(normalized) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | use crate::layout::CornerRadius; |
| 100 |
no outgoing calls