Skip to main content

rscad_core/geometric/
axis.rs

1#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
2#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
4pub enum Axis {
5    X,
6    Y,
7    Z,
8}
9
10#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
13pub struct Direction {
14    pub axis: Axis,
15    pub positive: bool,
16}
17impl Direction {
18    pub const X: Self = Self {
19        axis: Axis::X,
20        positive: true,
21    };
22    pub const Y: Self = Self {
23        axis: Axis::Y,
24        positive: true,
25    };
26    pub const Z: Self = Self {
27        axis: Axis::Z,
28        positive: true,
29    };
30}
31
32impl core::ops::Neg for Direction {
33    type Output = Self;
34
35    fn neg(mut self) -> Self::Output {
36        self.positive = !self.positive;
37        self
38    }
39}