Debian Codegraph @

debian/missing-sources/glam-0.16.0/src/vec2.rs

raw symbols SCIP
1 use craterust-analyzer cargo glam 0.16.0 crate/::corerust-analyzer cargo glam 0.16.0 core/::traitsrust-analyzer cargo glam 0.16.0 core/traits/::vectorrust-analyzer cargo glam 0.16.0 core/traits/vector/::*;
2 use craterust-analyzer cargo glam 0.16.0 crate/::{BVec2rust-analyzer cargo glam 0.16.0 vec_mask/BVec2#, DVec3rust-analyzer cargo glam 0.16.0 vec3/DVec3#, IVec3rust-analyzer cargo glam 0.16.0 vec3/IVec3#, UVec3rust-analyzer cargo glam 0.16.0 vec3/UVec3#, Vec3rust-analyzer cargo glam 0.16.0 vec3/Vec3#, XYrust-analyzer cargo glam 0.16.0 core/storage/XY#};
3 #[cfg(not(target_arch = "spirv"))]
4 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/;
5 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{f32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/, opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::*};
6
7 #[cfg(not(feature = "std"))]
8 use num_traits::Float;
9
10 #[cfg(feature = "std")]
11 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::{Productrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/accum/Product#, Sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/accum/Sum#};
12
13 macro_rules! impl_vec2_common_methodsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_common_methods! {
14 ($t:ty, $vec2:ident, $vec3:ident, $mask:ident, $inner:ident) => {
15 /// All zeroes.
16 pub const ZERO: Self = Self($inner::ZERO);
17
18 /// All ones.
19 pub const ONE: Self = Self($inner::ONE);
20
21 /// `[1, 0]`: a unit-length vector pointing along the positive X axis.
22 pub const X: Self = Self($inner::X);
23
24 /// `[0, 1]`: a unit-length vector pointing along the positive Y axis.
25 pub const Y: Self = Self($inner::Y);
26
27 /// The unit axes.
28 pub const AXES: [Self; 2] = [Self::X, Self::Y];
29
30 /// Creates a new vector.
31 #[inline(always)]
32 pub fn new(x: $t, y: $t) -> $vec2 {
33 Self(Vector2::new(x, y))
34 }
35
36 /// Creates a 3D vector from `self` and the given `z` value.
37 #[inline(always)]
38 pub fn extend(self, z: $t) -> $vec3 {
39 $vec3::new(self.x, self.y, z)
40 }
41
42 /// `[x, y]`
43 #[inline(always)]
44 pub fn to_array(&self) -> [$t; 2] {
45 [self.x, self.y]
46 }
47
48 impl_vecn_common_methods!($t, $vec2, $mask, $inner, Vector2);
49 };
50 }
51
52 macro_rules! impl_vec2_signed_methodsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_signed_methods! {
53 ($t:ty, $vec2:ident, $vec3:ident, $mask:ident, $inner:ident) => {
54 impl_vec2_common_methods!($t, $vec2, $vec3, $mask, $inner);
55 impl_vecn_signed_methods!($t, $vec2, $mask, $inner, SignedVector2);
56
57 /// Returns a vector that is equal to `self` rotated by 90 degrees.
58 #[inline(always)]
59 pub fn perp(self) -> Self {
60 Self(self.0.perp())
61 }
62
63 /// The perpendicular dot product of `self` and `other`.
64 /// Also known as the wedge product, 2d cross product, and determinant.
65 #[inline(always)]
66 #[cfg_attr(
67 docsrs,
68 doc(alias = "wedge"),
69 doc(alias = "cross"),
70 doc(alias = "determinant")
71 )]
72 pub fn perp_dot(self, other: $vec2) -> $t {
73 self.0.perp_dot(other.0)
74 }
75 };
76 }
77
78 macro_rules! impl_vec2_float_methodsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_float_methods! {
79 ($t:ty, $vec2:ident, $vec3:ident, $mask:ident, $inner:ident) => {
80 impl_vec2_signed_methods!($t, $vec2, $vec3, $mask, $inner);
81 impl_vecn_float_methods!($t, $vec2, $mask, $inner, FloatVector2);
82
83 /// Returns the angle (in radians) between `self` and `other`.
84 ///
85 /// The input vectors do not need to be unit length however they must be non-zero.
86 #[inline(always)]
87 pub fn angle_between(self, other: Self) -> $t {
88 self.0.angle_between(other.0)
89 }
90 };
91 }
92
93 macro_rules! impl_vec2_common_traitsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_common_traits! {
94 ($t:ty, $new:ident, $vec2:ident, $vec3:ident, $mask:ident, $inner:ident) => {
95 /// Creates a 2-dimensional vector.
96 #[inline(always)]
97 pub fn $new(x: $t, y: $t) -> $vec2 {
98 $vec2::new(x, y)
99 }
100
101 #[cfg(not(target_arch = "spirv"))]
102 impl fmt::Display for $vec2 {
103 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
104 write!(f, "[{}, {}]", self.x, self.y)
105 }
106 }
107
108 #[cfg(not(target_arch = "spirv"))]
109 impl fmt::Debug for $vec2 {
110 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
111 fmt.debug_tuple(stringify!($vec2))
112 .field(&self.x)
113 .field(&self.y)
114 .finish()
115 }
116 }
117
118 impl From<($t, $t)> for $vec2 {
119 #[inline(always)]
120 fn from(t: ($t, $t)) -> Self {
121 Self($inner::from_tuple(t))
122 }
123 }
124
125 impl From<$vec2> for ($t, $t) {
126 #[inline(always)]
127 fn from(v: $vec2) -> Self {
128 v.0.into_tuple()
129 }
130 }
131
132 impl Deref for $vec2 {
133 type Target = XY<$t>;
134 #[inline(always)]
135 fn deref(&self) -> &Self::Target {
136 self.0.as_ref_xy()
137 }
138 }
139
140 impl DerefMut for $vec2 {
141 #[inline(always)]
142 fn deref_mut(&mut self) -> &mut Self::Target {
143 self.0.as_mut_xy()
144 }
145 }
146
147 impl_vecn_common_traits!($t, 2, $vec2, $inner, Vector2);
148 };
149 }
150
151 macro_rules! impl_vec2_unsigned_traitsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_unsigned_traits! {
152 ($t:ty, $new:ident, $vec2:ident, $vec3:ident, $mask:ident, $inner:ident) => {
153 impl_vec2_common_traits!($t, $new, $vec2, $vec3, $mask, $inner);
154 };
155 }
156
157 macro_rules! impl_vec2_signed_traitsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_signed_traits! {
158 ($t:ty, $new:ident, $vec2:ident, $vec3:ident, $mask:ident, $inner:ident) => {
159 impl_vec2_common_traits!($t, $new, $vec2, $vec3, $mask, $inner);
160 impl_vecn_signed_traits!($t, 2, $vec2, $inner, SignedVector2);
161 };
162 }
163
164 type XYF32rust-analyzer cargo glam 0.16.0 vec2/XYF32# = XYrust-analyzer cargo glam 0.16.0 core/storage/XY#<f32>;
165
166 /// A 2-dimensional vector.
167 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)]
168 #[repr(transparent)]
169 pub struct Vec2rust-analyzer cargo glam 0.16.0 vec2/Vec2#(pub(craterust-analyzer cargo glam 0.16.0 crate/) XYF32rust-analyzer cargo glam 0.16.0 vec2/XYF32#);
170
171 impl Vec2rust-analyzer cargo glam 0.16.0 vec2/Vec2# {
172 impl_vec2_float_methodsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_float_methods!!(f32, Vec2rust-analyzer cargo glam 0.16.0 vec2/Vec2#, Vec3rust-analyzer cargo glam 0.16.0 vec3/Vec3#, BVec2rust-analyzer cargo glam 0.16.0 vec_mask/BVec2#, XYF32rust-analyzer cargo glam 0.16.0 vec2/XYF32#);
173 impl_vecn_as_f64rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_f64!!(DVec2rust-analyzer cargo glam 0.16.0 vec2/DVec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
174 impl_vecn_as_i32rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_i32!!(IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
175 impl_vecn_as_u32rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_u32!!(UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
176 }
177 impl_vec2_signed_traitsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_signed_traits!!(f32, vec2rust-analyzer cargo glam 0.16.0 vec2/vec2()., Vec2rust-analyzer cargo glam 0.16.0 vec2/Vec2#, Vec3, BVec2, XYF32rust-analyzer cargo glam 0.16.0 vec2/XYF32#);
178
179 type XYF64rust-analyzer cargo glam 0.16.0 vec2/XYF64# = XYrust-analyzer cargo glam 0.16.0 core/storage/XY#<f64>;
180
181 /// A 2-dimensional vector.
182 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)]
183 #[repr(transparent)]
184 pub struct DVec2rust-analyzer cargo glam 0.16.0 vec2/DVec2#(pub(craterust-analyzer cargo glam 0.16.0 crate/) XYF64rust-analyzer cargo glam 0.16.0 vec2/XYF64#);
185
186 impl DVec2rust-analyzer cargo glam 0.16.0 vec2/DVec2# {
187 impl_vec2_float_methodsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_float_methods!!(f64, DVec2rust-analyzer cargo glam 0.16.0 vec2/DVec2#, DVec3rust-analyzer cargo glam 0.16.0 vec3/DVec3#, BVec2rust-analyzer cargo glam 0.16.0 vec_mask/BVec2#, XYF64rust-analyzer cargo glam 0.16.0 vec2/XYF64#);
188 impl_vecn_as_f32rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_f32!!(Vec2rust-analyzer cargo glam 0.16.0 vec2/Vec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
189 impl_vecn_as_i32rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_i32!!(IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
190 impl_vecn_as_u32rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_u32!!(UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
191 }
192 impl_vec2_signed_traitsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_signed_traits!!(f64, dvec2rust-analyzer cargo glam 0.16.0 vec2/dvec2()., DVec2rust-analyzer cargo glam 0.16.0 vec2/DVec2#, DVec3, BVec2, XYF64rust-analyzer cargo glam 0.16.0 vec2/XYF64#);
193
194 type XYI32rust-analyzer cargo glam 0.16.0 vec2/XYI32# = XYrust-analyzer cargo glam 0.16.0 core/storage/XY#<i32>;
195
196 /// A 2-dimensional vector.
197 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)]
198 #[repr(transparent)]
199 pub struct IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2#(pub(craterust-analyzer cargo glam 0.16.0 crate/) XYI32rust-analyzer cargo glam 0.16.0 vec2/XYI32#);
200
201 impl IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2# {
202 impl_vec2_signed_methodsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_signed_methods!!(i32, IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2#, IVec3rust-analyzer cargo glam 0.16.0 vec3/IVec3#, BVec2rust-analyzer cargo glam 0.16.0 vec_mask/BVec2#, XYI32rust-analyzer cargo glam 0.16.0 vec2/XYI32#);
203 impl_vecn_as_f32rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_f32!!(Vec2rust-analyzer cargo glam 0.16.0 vec2/Vec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
204 impl_vecn_as_f64rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_f64!!(DVec2rust-analyzer cargo glam 0.16.0 vec2/DVec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
205 impl_vecn_as_u32rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_u32!!(UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
206 }
207 impl_vec2_signed_traitsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_signed_traits!!(i32, ivec2rust-analyzer cargo glam 0.16.0 vec2/ivec2()., IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2#, IVec3, BVec2, XYI32rust-analyzer cargo glam 0.16.0 vec2/XYI32#);
208 impl_vecn_eq_hash_traitsrust-analyzer cargo glam 0.16.0 vec/impl_vecn_eq_hash_traits!!(i32, 2, IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2#);
209
210 type XYU32rust-analyzer cargo glam 0.16.0 vec2/XYU32# = XYrust-analyzer cargo glam 0.16.0 core/storage/XY#<u32>;
211
212 /// A 2-dimensional vector.
213 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)]
214 #[repr(transparent)]
215 pub struct UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2#(pub(craterust-analyzer cargo glam 0.16.0 crate/) XYU32rust-analyzer cargo glam 0.16.0 vec2/XYU32#);
216
217 impl UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2# {
218 impl_vec2_common_methodsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_common_methods!!(u32, UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2#, UVec3rust-analyzer cargo glam 0.16.0 vec3/UVec3#, BVec2rust-analyzer cargo glam 0.16.0 vec_mask/BVec2#, XYU32rust-analyzer cargo glam 0.16.0 vec2/XYU32#);
219 impl_vecn_as_f32rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_f32!!(Vec2rust-analyzer cargo glam 0.16.0 vec2/Vec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
220 impl_vecn_as_f64rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_f64!!(DVec2rust-analyzer cargo glam 0.16.0 vec2/DVec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
221 impl_vecn_as_i32rust-analyzer cargo glam 0.16.0 vec/impl_vecn_as_i32!!(IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2#, xrust-analyzer cargo glam 0.16.0 core/storage/XY#x., yrust-analyzer cargo glam 0.16.0 core/storage/XY#y.);
222 }
223 impl_vec2_unsigned_traitsrust-analyzer cargo glam 0.16.0 vec2/impl_vec2_unsigned_traits!!(u32, uvec2rust-analyzer cargo glam 0.16.0 vec2/uvec2()., UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2#, UVec3, BVec2, XYU32rust-analyzer cargo glam 0.16.0 vec2/XYU32#);
224 impl_vecn_eq_hash_traitsrust-analyzer cargo glam 0.16.0 vec/impl_vecn_eq_hash_traits!!(u32, 2, UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2#);
225
226 mod const_test_vec2rust-analyzer cargo glam 0.16.0 vec2/const_test_vec2/ {
227 const_assert_eqrust-analyzer cargo glam 0.16.0 macros/const_assert_eq!!(4, corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::align_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/align_of().::<superrust-analyzer cargo glam 0.16.0 vec2/::Vec2rust-analyzer cargo glam 0.16.0 vec2/Vec2#>());
228 const_assert_eqrust-analyzer cargo glam 0.16.0 macros/const_assert_eq!!(8, corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<superrust-analyzer cargo glam 0.16.0 vec2/::Vec2rust-analyzer cargo glam 0.16.0 vec2/Vec2#>());
229 }
230
231 mod const_test_dvec2rust-analyzer cargo glam 0.16.0 vec2/const_test_dvec2/ {
232 const_assert_eqrust-analyzer cargo glam 0.16.0 macros/const_assert_eq!!(8, corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::align_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/align_of().::<superrust-analyzer cargo glam 0.16.0 vec2/::DVec2rust-analyzer cargo glam 0.16.0 vec2/DVec2#>());
233 const_assert_eqrust-analyzer cargo glam 0.16.0 macros/const_assert_eq!!(16, corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<superrust-analyzer cargo glam 0.16.0 vec2/::DVec2rust-analyzer cargo glam 0.16.0 vec2/DVec2#>());
234 }
235
236 mod const_test_ivec2rust-analyzer cargo glam 0.16.0 vec2/const_test_ivec2/ {
237 const_assert_eqrust-analyzer cargo glam 0.16.0 macros/const_assert_eq!!(4, corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::align_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/align_of().::<superrust-analyzer cargo glam 0.16.0 vec2/::IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2#>());
238 const_assert_eqrust-analyzer cargo glam 0.16.0 macros/const_assert_eq!!(8, corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<superrust-analyzer cargo glam 0.16.0 vec2/::IVec2rust-analyzer cargo glam 0.16.0 vec2/IVec2#>());
239 }
240
241 mod const_test_uvec2rust-analyzer cargo glam 0.16.0 vec2/const_test_uvec2/ {
242 const_assert_eqrust-analyzer cargo glam 0.16.0 macros/const_assert_eq!!(4, corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::align_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/align_of().::<superrust-analyzer cargo glam 0.16.0 vec2/::UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2#>());
243 const_assert_eqrust-analyzer cargo glam 0.16.0 macros/const_assert_eq!!(8, corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<superrust-analyzer cargo glam 0.16.0 vec2/::UVec2rust-analyzer cargo glam 0.16.0 vec2/UVec2#>());
244 }