// Stolen from https://github.com/c1m50c/fixed-vectors (MIT license) /// Vector for holding two-dimensional values. /// /// # Example /// /// ``` /// use fixed_wide_vectors::Vector2; /// /// let mut vec2 = Vector2::new(1, 2); /// vec2 += Vector2::new(1, 2); /// /// assert_eq!(vec2.x, 2); /// assert_eq!(vec2.y, 4); /// ``` pub struct Vector2 { pub x: T, pub y: T, } /// Vector for holding three-dimensional values. /// /// # Example /// /// ``` /// use fixed_wide_vectors::Vector3; /// /// let mut vec3 = Vector3::new(1, 2, 3); /// vec3 += Vector3::new(1, 2, 3); /// /// assert_eq!(vec3.x, 2); /// assert_eq!(vec3.y, 4); /// assert_eq!(vec3.z, 6); /// ``` pub struct Vector3 { pub x: T, pub y: T, pub z: T, } /// Vector for holding four-dimensional values. /// /// # Example /// /// ``` /// use fixed_wide_vectors::Vector4; /// /// let mut vec4 = Vector4::new(1, 2, 3, 4); /// vec4 += Vector4::new(1, 2, 3, 4); /// /// assert_eq!(vec4.x, 2); /// assert_eq!(vec4.y, 4); /// assert_eq!(vec4.z, 6); /// assert_eq!(vec4.w, 8); /// ``` pub struct Vector4 { pub x: T, pub y: T, pub z: T, pub w: T, } crate::impl_vector!(Vector2 { x, y }, 2); crate::impl_vector!(Vector3 { x, y, z }, 3); crate::impl_vector!(Vector4 { x, y, z, w }, 4); crate::impl_extend!(Vector2 { x, y }, Vector3, z); crate::impl_extend!(Vector3 { x, y, z }, Vector4, w); crate::impl_matrix_inner!((Vector2 { x, y }, Vector2 { x, y }, 2), (Vector2 { x, y }, Vector2 { x, y }, 2) ); crate::impl_matrix_inner!((Vector2 { x, y }, Vector2 { x, y }, 2), (Vector3 { x, y, z }, Vector3 { x, y, z }, 3) ); crate::impl_matrix_inner!((Vector2 { x, y }, Vector2 { x, y }, 2), (Vector4 { x, y, z, w }, Vector4 { x, y, z, w }, 4) ); crate::impl_matrix_inner!((Vector3 { x, y, z }, Vector3 { x, y, z }, 3), (Vector2 { x, y }, Vector2 { x, y }, 2) ); crate::impl_matrix_inner!((Vector3 { x, y, z }, Vector3 { x, y, z }, 3), (Vector3 { x, y, z }, Vector3 { x, y, z }, 3) ); crate::impl_matrix_inner!((Vector3 { x, y, z }, Vector3 { x, y, z }, 3), (Vector4 { x, y, z, w }, Vector4 { x, y, z, w }, 4) ); crate::impl_matrix_inner!((Vector4 { x, y, z, w }, Vector4 { x, y, z, w }, 4), (Vector2 { x, y }, Vector2 { x, y }, 2) ); crate::impl_matrix_inner!((Vector4 { x, y, z, w }, Vector4 { x, y, z, w }, 4), (Vector3 { x, y, z }, Vector3 { x, y, z }, 3) ); crate::impl_matrix_inner!((Vector4 { x, y, z, w }, Vector4 { x, y, z, w }, 4), (Vector4 { x, y, z, w }, Vector4 { x, y, z, w }, 4) ); //cross product crate::impl_vector_3!();