nalgebra/geometry/
scale_coordinates.rs

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