| 1 |
use super::glam::{ |
| 2 |
BVec2, BVec3, BVec4, DVec2, DVec3, DVec4, IVec2, IVec3, IVec4, UVec2, UVec3, UVec4, Vec2, Vec3, |
| 3 |
Vec3A, Vec4, |
| 4 |
}; |
| 5 |
use crate::{Point2, Point3, Point4}; |
| 6 |
|
| 7 |
macro_rules! impl_point_conversion( |
| 8 |
($N: ty, $Vec2: ty, $Vec3: ty, $Vec4: ty) => { |
| 9 |
impl From<$Vec2> for Point2<$N> { |
| 10 |
#[inline] |
| 11 |
fn from(e: $Vec2) -> Point2<$N> { |
| 12 |
<[$N;2]>::from(e).into() |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
impl From<Point2<$N>> for $Vec2 { |
| 17 |
#[inline] |
| 18 |
fn from(e: Point2<$N>) -> $Vec2 { |
| 19 |
<$Vec2>::new(e[0], e[1]) |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
impl From<$Vec3> for Point3<$N> { |
| 24 |
#[inline] |
| 25 |
fn from(e: $Vec3) -> Point3<$N> { |
| 26 |
<[$N;3]>::from(e).into() |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
impl From<Point3<$N>> for $Vec3 { |
| 31 |
#[inline] |
| 32 |
fn from(e: Point3<$N>) -> $Vec3 { |
| 33 |
<$Vec3>::new(e[0], e[1], e[2]) |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
impl From<$Vec4> for Point4<$N> { |
| 38 |
#[inline] |
| 39 |
fn from(e: $Vec4) -> Point4<$N> { |
| 40 |
<[$N;4]>::from(e).into() |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
impl From<Point4<$N>> for $Vec4 { |
| 45 |
#[inline] |
| 46 |
fn from(e: Point4<$N>) -> $Vec4 { |
| 47 |
<$Vec4>::new(e[0], e[1], e[2], e[3]) |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
); |
| 52 |
|
| 53 |
impl_point_conversion!(f32, Vec2, Vec3, Vec4); |
| 54 |
impl_point_conversion!(f64, DVec2, DVec3, DVec4); |
| 55 |
impl_point_conversion!(i32, IVec2, IVec3, IVec4); |
| 56 |
impl_point_conversion!(u32, UVec2, UVec3, UVec4); |
| 57 |
impl_point_conversion!(bool, BVec2, BVec3, BVec4); |
| 58 |
|
| 59 |
impl From<Vec3A> for Point3<f32> { |
| 60 |
#[inline] |
| 61 |
fn from(e: Vec3A) -> Point3<f32> { |
| 62 |
(*e.as_ref()).into() |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
impl From<Point3<f32>> for Vec3A { |
| 67 |
#[inline] |
| 68 |
fn from(e: Point3<f32>) -> Vec3A { |
| 69 |
Vec3A::new(e[0], e[1], e[2]) |
| 70 |
} |
| 71 |
} |