Skip to main content

glow_effects/util/
point.rs

1use std::fmt::Debug;
2
3pub trait PointContainer: Sized + Debug + Send + Sync + Clone + Copy {
4    fn get_x(&self) -> f64;
5    fn get_y(&self) -> f64;
6    fn get_z(&self) -> f64;
7    fn copy_with_new_coordinates(&self, x: f64, y: f64, z: f64) -> Self;
8    fn get_nalgebra_point(&self) -> nalgebra::Point3<f64> {
9        nalgebra::Point3::new(self.get_x(), self.get_y(), self.get_z())
10    }
11}
12
13impl PointContainer for nalgebra::Point3<f64> {
14    fn get_x(&self) -> f64 {
15        self.x
16    }
17    fn get_y(&self) -> f64 {
18        self.y
19    }
20
21    fn get_z(&self) -> f64 {
22        self.z
23    }
24
25    fn copy_with_new_coordinates(&self, x: f64, y: f64, z: f64) -> Self {
26        nalgebra::Point3::new(x, y, z)
27    }
28}
29
30impl PointContainer for Point {
31    fn get_x(&self) -> f64 {
32        self.x
33    }
34    fn get_y(&self) -> f64 {
35        self.y
36    }
37
38    fn get_z(&self) -> f64 {
39        self.z
40    }
41
42    fn copy_with_new_coordinates(&self, x: f64, y: f64, z: f64) -> Self {
43        Point { x, y, z }
44    }
45}
46
47#[derive(Debug, Clone, Copy, PartialEq)]
48pub struct Point {
49    pub x: f64,
50    pub y: f64,
51    pub z: f64,
52}