Skip to main content

rscad_core/geometric/
point.rs

1use crate::prelude_::*;
2#[derive(Clone, Copy, Debug, PartialEq)]
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
5pub struct Point2D {
6    pub x: f64,
7    pub y: f64,
8}
9
10impl Point2D {
11    pub const ORIGIN: Self = Point2D { x: 0.0, y: 0.0 };
12
13    pub fn xy<T: Number>(x: T, y: T) -> Self {
14        Self {
15            x: x.to_f64(),
16            y: y.to_f64(),
17        }
18    }
19}
20
21impl crate::Object for Point2D {}
22
23#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
24#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
25#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
26pub struct Point3D {
27    pub x: f64,
28    pub y: f64,
29    pub z: f64,
30}
31impl Point3D {
32    pub const ORIGIN: Self = Point3D {
33        x: 0.0,
34        y: 0.0,
35        z: 0.0,
36    };
37
38    pub fn xyz<T: Number>(x: T, y: T, z: T) -> Self {
39        Self {
40            x: x.to_f64(),
41            y: y.to_f64(),
42            z: z.to_f64(),
43        }
44    }
45}
46
47impl crate::Object for Point3D {}