vec3_rs/
consts.rs

1use crate::{Vector3, Vector3Coordinate};
2
3impl<T: Vector3Coordinate> Vector3<T> {
4    /// Unit vector along the X-axis.
5    #[must_use]
6    #[inline]
7    pub fn x_axis() -> Self {
8        Self {
9            x: T::one(),
10            y: T::zero(),
11            z: T::zero(),
12        }
13    }
14
15    /// Unit vector along the Y-axis.
16    #[must_use]
17    #[inline]
18    pub fn y_axis() -> Self {
19        Self {
20            x: T::zero(),
21            y: T::one(),
22            z: T::zero(),
23        }
24    }
25
26    /// Unit vector along the Z-axis.
27    #[must_use]
28    #[inline]
29    pub fn z_axis() -> Self {
30        Self {
31            x: T::zero(),
32            y: T::zero(),
33            z: T::one(),
34        }
35    }
36
37    /// Vector with all components set to 1.
38    #[must_use]
39    #[inline]
40    pub fn one() -> Self {
41        Self {
42            x: T::one(),
43            y: T::one(),
44            z: T::one(),
45        }
46    }
47
48    /// Vector with all components set to 0.
49    #[must_use]
50    #[inline]
51    pub fn zero() -> Self {
52        Self {
53            x: T::zero(),
54            y: T::zero(),
55            z: T::zero(),
56        }
57    }
58}