nalgebra/third_party/glam/common/
glam_translation.rs1use super::glam::{DVec2, DVec3, DVec4, Vec2, Vec3, Vec3A, Vec4};
2use crate::{Translation2, Translation3, Translation4};
3
4macro_rules! impl_translation_conversion(
5 ($N: ty, $Vec2: ty, $Vec3: ty, $Vec4: ty) => {
6 impl From<$Vec2> for Translation2<$N> {
7 #[inline]
8 fn from(e: $Vec2) -> Translation2<$N> {
9 (*e.as_ref()).into()
10 }
11 }
12
13 impl From<Translation2<$N>> for $Vec2 {
14 #[inline]
15 fn from(e: Translation2<$N>) -> $Vec2 {
16 e.vector.into()
17 }
18 }
19
20 impl From<$Vec3> for Translation3<$N> {
21 #[inline]
22 fn from(e: $Vec3) -> Translation3<$N> {
23 (*e.as_ref()).into()
24 }
25 }
26
27 impl From<Translation3<$N>> for $Vec3 {
28 #[inline]
29 fn from(e: Translation3<$N>) -> $Vec3 {
30 e.vector.into()
31 }
32 }
33
34 impl From<$Vec4> for Translation4<$N> {
35 #[inline]
36 fn from(e: $Vec4) -> Translation4<$N> {
37 (*e.as_ref()).into()
38 }
39 }
40
41 impl From<Translation4<$N>> for $Vec4 {
42 #[inline]
43 fn from(e: Translation4<$N>) -> $Vec4 {
44 e.vector.into()
45 }
46 }
47 }
48);
49
50impl_translation_conversion!(f32, Vec2, Vec3, Vec4);
51impl_translation_conversion!(f64, DVec2, DVec3, DVec4);
52
53impl From<Vec3A> for Translation3<f32> {
54 #[inline]
55 fn from(e: Vec3A) -> Translation3<f32> {
56 (*e.as_ref()).into()
57 }
58}
59
60impl From<Translation3<f32>> for Vec3A {
61 #[inline]
62 fn from(e: Translation3<f32>) -> Vec3A {
63 e.vector.into()
64 }
65}