// 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 }, (T, T), 2); crate::impl_vector!(Vector3 { x, y, z }, (T, T, T), 3); crate::impl_vector!(Vector4 { x, y, z, w }, (T, T, T, T), 4); crate::impl_vector_extend!(Vector2 { x, y }, Vector3, z); crate::impl_vector_extend!(Vector3 { x, y, z }, Vector4, w); crate::impl_matrix!((Vector2 { x, y }, ((T, T), (T, T)), 2), (Vector2, 2), (Vector2 { x, y }) ); crate::impl_matrix!((Vector2 { x, y }, ((T, T, T), (T, T, T)), 2), (Vector3, 3), (Vector3 { x, y, z }) ); crate::impl_matrix!((Vector2 { x, y }, ((T, T, T, T), (T, T, T, T)), 2), (Vector4, 4), (Vector4 { x, y, z, w }) ); crate::impl_matrix!((Vector3 { x, y, z }, ((T, T), (T, T), (T, T)), 3), (Vector2, 2), (Vector2 { x, y }) ); crate::impl_matrix!((Vector3 { x, y, z }, ((T, T, T), (T, T, T), (T, T, T)), 3), (Vector3, 3), (Vector3 { x, y, z }) ); crate::impl_matrix!((Vector3 { x, y, z }, ((T, T, T, T), (T, T, T, T), (T, T, T, T)), 3), (Vector4, 4), (Vector4 { x, y, z, w }) ); crate::impl_matrix!((Vector4 { x, y, z, w }, ((T, T), (T, T), (T, T), (T, T)), 4), (Vector2, 2), (Vector2 { x, y }) ); crate::impl_matrix!((Vector4 { x, y, z, w }, ((T, T, T), (T, T, T), (T, T, T), (T, T, T)), 4), (Vector3, 3), (Vector3 { x, y, z }) ); crate::impl_matrix!((Vector4 { x, y, z, w }, ((T, T, T, T), (T, T, T, T), (T, T, T, T), (T, T, T, T)), 4), (Vector4, 4), (Vector4 { x, y, z, w }) );