nalgebra/geometry/
scale_coordinates.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use std::ops::{Deref, DerefMut};

use crate::base::coordinates::{X, XY, XYZ, XYZW, XYZWA, XYZWAB};
use crate::base::Scalar;

use crate::geometry::Scale;

/*
 *
 * Give coordinates to Scale{1 .. 6}
 *
 */

macro_rules! deref_impl(
    ($D: expr, $Target: ident $(, $comps: ident)*) => {
        impl<T: Scalar> Deref for Scale<T, $D> {
            type Target = $Target<T>;

            #[inline]
            fn deref(&self) -> &Self::Target {
                self.vector.deref()
            }
        }

        impl<T: Scalar> DerefMut for Scale<T, $D> {
            #[inline]
            fn deref_mut(&mut self) -> &mut Self::Target {
                self.vector.deref_mut()
            }
        }
    }
);

deref_impl!(1, X, x);
deref_impl!(2, XY, x, y);
deref_impl!(3, XYZ, x, y, z);
deref_impl!(4, XYZW, x, y, z, w);
deref_impl!(5, XYZWA, x, y, z, w, a);
deref_impl!(6, XYZWAB, x, y, z, w, a, b);