nalgebra/geometry/
point_coordinates.rs

1use std::ops::{Deref, DerefMut};
2
3use crate::base::coordinates::{X, XY, XYZ, XYZW, XYZWA, XYZWAB};
4use crate::base::{Scalar, U1, U2, U3, U4, U5, U6};
5
6use crate::geometry::OPoint;
7
8/*
9 *
10 * Give coordinates to Point{1 .. 6}
11 *
12 */
13
14macro_rules! deref_impl(
15    ($D: ty, $Target: ident $(, $comps: ident)*) => {
16        impl<T: Scalar> Deref for OPoint<T, $D>
17        {
18            type Target = $Target<T>;
19
20            #[inline]
21            fn deref(&self) -> &Self::Target {
22                &*self.coords
23            }
24        }
25
26        impl<T: Scalar> DerefMut for OPoint<T, $D>
27        {
28            #[inline]
29            fn deref_mut(&mut self) -> &mut Self::Target {
30                &mut *self.coords
31            }
32        }
33    }
34);
35
36deref_impl!(U1, X, x);
37deref_impl!(U2, XY, x, y);
38deref_impl!(U3, XYZ, x, y, z);
39deref_impl!(U4, XYZW, x, y, z, w);
40deref_impl!(U5, XYZWA, x, y, z, w, a);
41deref_impl!(U6, XYZWAB, x, y, z, w, a, b);