use crate::{FloatConst, Interval};
#[doc = crate::_tags!(geom)]
#[doc = crate::_doc_location!("num/geom/dir")]
#[must_use]
#[repr(u8)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Hash)]
pub enum AngleKind {
#[default]
Full,
Acute,
Right,
Obtuse,
Straight,
Reflex,
}
impl AngleKind {
pub fn interval_deg(self) -> Interval<u16> {
use AngleKind as K;
match self {
K::Full => Interval::closed(0, 0), K::Acute => Interval::open(0, 90), K::Right => Interval::closed(90, 90), K::Obtuse => Interval::open(90, 180), K::Straight => Interval::closed(180, 180), K::Reflex => Interval::open(180, 360), }
}
pub fn interval_gra(self) -> Interval<u16> {
use AngleKind as K;
match self {
K::Full => Interval::closed(0, 0),
K::Acute => Interval::open(0, 100),
K::Right => Interval::closed(100, 100),
K::Obtuse => Interval::open(100, 200),
K::Straight => Interval::closed(200, 200),
K::Reflex => Interval::open(200, 400),
}
}
pub fn interval_rad(self) -> Interval<f32> {
const PI: f32 = f32::PI;
use AngleKind as K;
match self {
K::Full => Interval::closed(0.0, 0.0),
K::Acute => Interval::open(0.0, PI / 2.0),
K::Right => Interval::closed(PI / 2.0, PI / 2.0),
K::Obtuse => Interval::open(PI / 2.0, PI),
K::Straight => Interval::closed(PI, PI),
K::Reflex => Interval::open(PI, 2.0 * PI),
}
}
pub fn interval_u8(self) -> Interval<u8> {
use AngleKind as K;
match self {
K::Full => Interval::closed(0, 0),
K::Acute => Interval::open(0, 64),
K::Right => Interval::closed(64, 64),
K::Obtuse => Interval::open(64, 128),
K::Straight => Interval::closed(128, 128),
K::Reflex => Interval::open(128, 255),
}
}
}