assimp/math/
vector3.rs

1#[cfg(feature = "cgmath")]
2use cgmath::{Point3, Vector3};
3use ffi::AiVector3D;
4
5define_type_and_iterator! {
6    /// Vector3D docs
7    #[derive(Clone, Copy, Debug, PartialEq)]
8    struct Vector3D(AiVector3D)
9    /// Vector3DIter docs
10    struct Vector3DIter
11}
12
13impl Vector3D {
14    pub fn new(x: f32, y: f32, z: f32) -> Vector3D {
15        Vector3D(AiVector3D { x: x, y: y, z: z })
16    }
17}
18
19impl From<[f32; 3]> for Vector3D {
20    fn from(v: [f32; 3]) -> Vector3D {
21        Vector3D::new(v[0], v[1], v[2])
22    }
23}
24
25impl From<Vector3D> for [f32; 3] {
26    fn from(v: Vector3D) -> [f32; 3] {
27        [v.x, v.y, v.z]
28    }
29}
30
31#[cfg(feature = "cgmath")]
32impl From<Point3<f32>> for Vector3D {
33    fn from(p: Point3<f32>) -> Vector3D {
34        Vector3D::new(p[0], p[1], p[2])
35    }
36}
37
38#[cfg(feature = "cgmath")]
39impl From<Vector3D> for Point3<f32> {
40    fn from(v: Vector3D) -> Point3<f32> {
41        Point3::new(v.x, v.y, v.z)
42    }
43}
44
45#[cfg(feature = "cgmath")]
46impl From<Vector3<f32>> for Vector3D {
47    fn from(v: Vector3<f32>) -> Vector3D {
48        Vector3D::new(v[0], v[1], v[2])
49    }
50}
51
52#[cfg(feature = "cgmath")]
53impl From<Vector3D> for Vector3<f32> {
54    fn from(v: Vector3D) -> Vector3<f32> {
55        Vector3::new(v.x, v.y, v.z)
56    }
57}