2016-12-05 05:44:42 +08:00
|
|
|
use std::ops::{Deref, DerefMut};
|
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::base::coordinates::{X, XY, XYZ, XYZW, XYZWA, XYZWAB};
|
2021-06-27 00:39:02 +08:00
|
|
|
use crate::base::{Scalar, U1, U2, U3, U4, U5, U6};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
2021-06-27 00:39:02 +08:00
|
|
|
use crate::geometry::OPoint;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
2017-08-03 01:37:44 +08:00
|
|
|
* Give coordinates to Point{1 .. 6}
|
2016-12-05 05:44:42 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
macro_rules! deref_impl(
|
2021-06-27 00:39:02 +08:00
|
|
|
($D: ty, $Target: ident $(, $comps: ident)*) => {
|
|
|
|
impl<T: Scalar> Deref for OPoint<T, $D>
|
2021-04-07 20:29:20 +08:00
|
|
|
{
|
2021-04-11 17:00:38 +08:00
|
|
|
type Target = $Target<T>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn deref(&self) -> &Self::Target {
|
2020-10-10 02:14:14 +08:00
|
|
|
&*self.coords
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-27 00:39:02 +08:00
|
|
|
impl<T: Scalar> DerefMut for OPoint<T, $D>
|
2021-04-07 20:29:20 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
|
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
2020-10-10 02:14:14 +08:00
|
|
|
&mut *self.coords
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-06-27 00:39:02 +08:00
|
|
|
deref_impl!(U1, X, x);
|
|
|
|
deref_impl!(U2, XY, x, y);
|
|
|
|
deref_impl!(U3, XYZ, x, y, z);
|
|
|
|
deref_impl!(U4, XYZW, x, y, z, w);
|
|
|
|
deref_impl!(U5, XYZWA, x, y, z, w, a);
|
|
|
|
deref_impl!(U6, XYZWAB, x, y, z, w, a, b);
|