1use std::{
33 fmt::{Debug, Display},
34 iter::{Product, Sum},
35 hash::Hash,
36 ops::{
37 Add, AddAssign,
38 Sub, SubAssign,
39 Mul, MulAssign,
40 Div, DivAssign,
41 Rem, RemAssign,
42 BitAnd, BitAndAssign,
43 BitOr, BitOrAssign,
44 BitXor, BitXorAssign,
45 Index, IndexMut,
46 Neg, Not,
47 Shl, Shr,
48 },
49};
50use glam::{
51 BVec2, BVec3, BVec3A, BVec4, BVec4A,
52 I8Vec2, I8Vec3, I8Vec4,
53 U8Vec2, U8Vec3, U8Vec4,
54 I16Vec2, I16Vec3, I16Vec4,
55 U16Vec2, U16Vec3, U16Vec4,
56 IVec2, IVec3, IVec4,
57 UVec2, UVec3, UVec4,
58 I64Vec2, I64Vec3, I64Vec4,
59 U64Vec2, U64Vec3, U64Vec4,
60 USizeVec2, USizeVec3, USizeVec4,
61 Vec2, Vec3, Vec3A, Vec4,
62 DVec2, DVec3, DVec4,
63};
64
65mod private {
66 pub trait Sealed {}
67}
68use private::Sealed;
69
70pub trait BVec
74where
75 Self:
76 Sealed +
77 Clone +
78 Copy +
79 PartialEq +
80 Eq +
81 Hash +
82 Default +
83 Not<Output = Self> +
84 BitAnd<Output = Self> +
85 BitAndAssign +
86 BitOr<Output = Self> +
87 BitOrAssign +
88 BitXor<Output = Self> +
89 BitXorAssign +
90 Debug +
91 Display +
92 From<Self::Array> +
93 Into<Self::Array> +
94 ,
95 Self::Array: Index<usize, Output = bool>,
96{
97 type Array;
98 const FALSE: Self;
99 const TRUE: Self;
100 const DIM: usize;
101 fn splat(v: bool) -> Self;
102 fn from_array(a: Self::Array) -> Self;
103 fn bitmask(self) -> u32;
104 fn any(self) -> bool;
105 fn all(self) -> bool;
106 fn test(&self, index: usize) -> bool;
107 fn set(&mut self, index: usize, value: bool);
108}
109
110macro_rules! impl_gbvec {
111 ($type:ty, $dim:literal) => {
112 impl Sealed for $type {}
113 impl BVec for $type {
114 type Array = [bool; $dim];
115 const FALSE: Self = Self::FALSE;
116 const TRUE: Self = Self::TRUE;
117 const DIM: usize = $dim;
118 fn splat(v: bool) -> Self { Self::splat(v) }
119 fn from_array(a: Self::Array) -> Self { Self::from_array(a) }
120 fn bitmask(self) -> u32 { self.bitmask() }
121 fn any(self) -> bool { self.any() }
122 fn all(self) -> bool { self.all() }
123 fn test(&self, index: usize) -> bool { self.test(index) }
124 fn set(&mut self, index: usize, value: bool) { self.set(index, value) }
125 }
126 };
127}
128
129impl_gbvec!(BVec2, 2);
130impl_gbvec!(BVec3, 3);
131impl_gbvec!(BVec3A, 3);
132impl_gbvec!(BVec4, 4);
133impl_gbvec!(BVec4A, 4);
134
135pub trait GVec
139where
140 for <'a> Self:
141 Sealed +
142 Clone +
143 Copy +
144 PartialEq +
145 Default +
146 Display +
147 Debug +
148 Add<Output = Self> +
149 Add<&'a Self, Output = Self> +
150 Add<Self::Scalar, Output = Self> +
151 Add<&'a Self::Scalar, Output = Self> +
152 AddAssign +
153 AddAssign<&'a Self> +
154 AddAssign<Self::Scalar> +
155 AddAssign<&'a Self::Scalar> +
156 Sub<Output = Self> +
157 Sub<&'a Self, Output = Self> +
158 Sub<Self::Scalar, Output = Self> +
159 Sub<&'a Self::Scalar, Output = Self> +
160 SubAssign +
161 SubAssign<&'a Self> +
162 SubAssign<Self::Scalar> +
163 SubAssign<&'a Self::Scalar> +
164 Mul<Output = Self> +
165 Mul<&'a Self, Output = Self> +
166 Mul<Self::Scalar, Output = Self> +
167 Mul<&'a Self::Scalar, Output = Self> +
168 MulAssign +
169 MulAssign<&'a Self> +
170 MulAssign<Self::Scalar> +
171 MulAssign<&'a Self::Scalar> +
172 Div<Output = Self> +
173 Div<&'a Self, Output = Self> +
174 Div<Self::Scalar, Output = Self> +
175 Div<&'a Self::Scalar, Output = Self> +
176 DivAssign +
177 DivAssign<&'a Self> +
178 DivAssign<Self::Scalar> +
179 DivAssign<&'a Self::Scalar> +
180 Rem<Output = Self> +
181 Rem<&'a Self, Output = Self> +
182 Rem<Self::Scalar, Output = Self> +
183 Rem<&'a Self::Scalar, Output = Self> +
184 RemAssign +
185 RemAssign<&'a Self> +
186 RemAssign<Self::Scalar> +
187 RemAssign<&'a Self::Scalar> +
188 AsRef<Self::Array> +
189 AsMut<Self::Array> +
190 From<Self::Array> +
191 Into<Self::Array> +
192 Sum +
193 Sum<&'a Self> +
194 Product +
195 Product<&'a Self> +
196 Index<usize, Output = Self::Scalar> +
197 IndexMut<usize, Output = Self::Scalar> +
198 From<Self::BVec> +
199 ,
200 for <'a> Self::Scalar:
201 'static +
202 Copy +
203 PartialOrd +
204 Add<Self, Output = Self> +
205 Add<&'a Self, Output = Self> +
206 Sub<Self, Output = Self> +
207 Sub<&'a Self, Output = Self> +
208 Mul<Self, Output = Self> +
209 Mul<&'a Self, Output = Self> +
210 Div<Self, Output = Self> +
211 Div<&'a Self, Output = Self> +
212 Rem<Self, Output = Self> +
213 Rem<&'a Self, Output = Self> +
214 ,
215 Self::BVec: BVec,
216 Self::Axes: Index<usize, Output = Self>,
217 Self::Array: Index<usize, Output = Self::Scalar>,
218 Self::I8Vec: I8Vec,
219 Self::U8Vec: U8Vec,
220 Self::I16Vec: I16Vec,
221 Self::U16Vec: U16Vec,
222 Self::I32Vec: I32Vec,
223 Self::U32Vec: U32Vec,
224 Self::I64Vec: I64Vec,
225 Self::U64Vec: U64Vec,
226 Self::USizeVec: USizeVec,
227 Self::F32Vec: F32Vec,
228 Self::F64Vec: F64Vec,
229{
230 type Scalar;
231 type BVec;
232 type Axes;
233 type Array;
234 type I8Vec;
235 type U8Vec;
236 type I16Vec;
237 type U16Vec;
238 type I32Vec;
239 type U32Vec;
240 type I64Vec;
241 type U64Vec;
242 type USizeVec;
243 type F32Vec;
244 type F64Vec;
245 const ZERO: Self;
246 const ONE: Self;
247 const MIN: Self;
248 const MAX: Self;
249 const AXES: Self::Axes;
250 const DIM: usize;
251 fn splat(v: Self::Scalar) -> Self;
252 fn map<F: Fn(Self::Scalar) -> Self::Scalar>(self, f: F) -> Self;
253 fn from_array(a: Self::Array) -> Self;
254 fn to_array(&self) -> Self::Array;
255 fn from_slice(slice: &[Self::Scalar]) -> Self;
256 fn write_to_slice(self, slice: &mut [Self::Scalar]);
257 fn dot(self, rhs: Self) -> Self::Scalar;
258 fn dot_into_vec(self, rhs: Self) -> Self;
259 fn min(self, rhs: Self) -> Self;
260 fn max(self, rhs: Self) -> Self;
261 fn clamp(self, min: Self, max: Self) -> Self;
262 fn min_element(self) -> Self::Scalar;
263 fn max_element(self) -> Self::Scalar;
264 fn min_position(self) -> usize;
265 fn max_position(self) -> usize;
266 fn element_sum(self) -> Self::Scalar;
267 fn element_product(self) -> Self::Scalar;
268 fn select(mask: Self::BVec, if_true: Self, if_false: Self) -> Self;
269 fn cmpeq(self, rhs: Self) -> Self::BVec;
270 fn cmpne(self, rhs: Self) -> Self::BVec;
271 fn cmpge(self, rhs: Self) -> Self::BVec;
272 fn cmpgt(self, rhs: Self) -> Self::BVec;
273 fn cmple(self, rhs: Self) -> Self::BVec;
274 fn cmplt(self, rhs: Self) -> Self::BVec;
275 fn length_squared(self) -> Self::Scalar;
276 fn as_i8vec(&self) -> Self::I8Vec;
277 fn as_u8vec(&self) -> Self::U8Vec;
278 fn as_i16vec(&self) -> Self::I16Vec;
279 fn as_u16vec(&self) -> Self::U16Vec;
280 fn as_ivec(&self) -> Self::I32Vec;
281 fn as_uvec(&self) -> Self::U32Vec;
282 fn as_i64vec(&self) -> Self::I64Vec;
283 fn as_u64vec(&self) -> Self::U64Vec;
284 fn as_usizevec(&self) -> Self::USizeVec;
285 fn as_vec(&self) -> Self::F32Vec;
286 fn as_dvec(&self) -> Self::F64Vec;
287}
288
289macro_rules! as_types {
290 (2) => {
291 type I8Vec = I8Vec2;
292 type U8Vec = U8Vec2;
293 type I16Vec = I16Vec2;
294 type U16Vec = U16Vec2;
295 type I32Vec = IVec2;
296 type U32Vec = UVec2;
297 type I64Vec = I64Vec2;
298 type U64Vec = U64Vec2;
299 type USizeVec = USizeVec2;
300 type F32Vec = Vec2;
301 type F64Vec = DVec2;
302 };
303 (3) => {
304 type I8Vec = I8Vec3;
305 type U8Vec = U8Vec3;
306 type I16Vec = I16Vec3;
307 type U16Vec = U16Vec3;
308 type I32Vec = IVec3;
309 type U32Vec = UVec3;
310 type I64Vec = I64Vec3;
311 type U64Vec = U64Vec3;
312 type USizeVec = USizeVec3;
313 type F32Vec = Vec3;
314 type F64Vec = DVec3;
315 };
316 (4) => {
317 type I8Vec = I8Vec4;
318 type U8Vec = U8Vec4;
319 type I16Vec = I16Vec4;
320 type U16Vec = U16Vec4;
321 type I32Vec = IVec4;
322 type U32Vec = UVec4;
323 type I64Vec = I64Vec4;
324 type U64Vec = U64Vec4;
325 type USizeVec = USizeVec4;
326 type F32Vec = Vec4;
327 type F64Vec = DVec4;
328 };
329}
330
331macro_rules! impl_as {
332 ($fn_name:ident, $out:ty, ($($comp:ident),*)) => {
333 fn $fn_name(&self) -> $out {
334 <$out>::new($(self.$comp as <$out as GVec>::Scalar),*)
335 }
336 };
337 ($fn_name:ident, $out:ty, 2) => {
338 impl_as!($fn_name, $out, (x, y));
339 };
340 ($fn_name:ident, $out:ty, 3) => {
341 impl_as!($fn_name, $out, (x, y, z));
342 };
343 ($fn_name:ident, $out:ty, 4) => {
344 impl_as!($fn_name, $out, (x, y, z, w));
345 };
346}
347
348macro_rules! impl_gvec {
349 ($type:ty, $scalar:ty, $bvec:ty, $dim:tt) => {
350 impl Sealed for $type {}
351 impl GVec for $type {
352 type Scalar = $scalar;
353 type BVec = $bvec;
354 type Axes = [Self; $dim];
355 type Array = [$scalar; $dim];
356 as_types!($dim);
357 const ZERO: Self = Self::ZERO;
358 const ONE: Self = Self::ONE;
359 const MIN: Self = Self::MIN;
360 const MAX: Self = Self::MAX;
361 const AXES: Self::Axes = Self::AXES;
362 const DIM: usize = $dim;
363 fn splat(v: Self::Scalar) -> Self { Self::splat(v) }
364 fn map<F: Fn(Self::Scalar) -> Self::Scalar>(self, f: F) -> Self { self.map(f) }
365 fn from_array(a: Self::Array) -> Self { Self::from_array(a) }
366 fn to_array(&self) -> Self::Array { self.to_array() }
367 fn from_slice(slice: &[Self::Scalar]) -> Self { Self::from_slice(slice) }
368 fn write_to_slice(self, slice: &mut [Self::Scalar]) { self.write_to_slice(slice) }
369 fn dot(self, rhs: Self) -> Self::Scalar { self.dot(rhs) }
370 fn dot_into_vec(self, rhs: Self) -> Self { self.dot_into_vec(rhs) }
371 fn min(self, rhs: Self) -> Self { self.min(rhs) }
372 fn max(self, rhs: Self) -> Self { self.max(rhs) }
373 fn clamp(self, min: Self, max: Self) -> Self { self.clamp(min, max) }
374 fn min_element(self) -> Self::Scalar { self.min_element() }
375 fn max_element(self) -> Self::Scalar { self.max_element() }
376 fn min_position(self) -> usize { self.min_position() }
377 fn max_position(self) -> usize { self.max_position() }
378 fn element_sum(self) -> Self::Scalar { self.element_sum() }
379 fn element_product(self) -> Self::Scalar { self.element_product() }
380 fn select(mask: Self::BVec, if_true: Self, if_false: Self) -> Self { Self::select(mask, if_true, if_false) }
381 fn cmpeq(self, rhs: Self) -> Self::BVec { self.cmpeq(rhs) }
382 fn cmpne(self, rhs: Self) -> Self::BVec { self.cmpne(rhs) }
383 fn cmpge(self, rhs: Self) -> Self::BVec { self.cmpge(rhs) }
384 fn cmpgt(self, rhs: Self) -> Self::BVec { self.cmpgt(rhs) }
385 fn cmple(self, rhs: Self) -> Self::BVec { self.cmple(rhs) }
386 fn cmplt(self, rhs: Self) -> Self::BVec { self.cmplt(rhs) }
387 fn length_squared(self) -> Self::Scalar { self.length_squared() }
388 impl_as!(as_i8vec, Self::I8Vec, $dim);
389 impl_as!(as_u8vec, Self::U8Vec, $dim);
390 impl_as!(as_i16vec, Self::I16Vec, $dim);
391 impl_as!(as_u16vec, Self::U16Vec, $dim);
392 impl_as!(as_ivec, Self::I32Vec, $dim);
393 impl_as!(as_uvec, Self::U32Vec, $dim);
394 impl_as!(as_i64vec, Self::I64Vec, $dim);
395 impl_as!(as_u64vec, Self::U64Vec, $dim);
396 impl_as!(as_usizevec, Self::USizeVec, $dim);
397 impl_as!(as_vec, Self::F32Vec, $dim);
398 impl_as!(as_dvec, Self::F64Vec, $dim);
399 }
400 };
401}
402pub(crate) use impl_gvec;
403
404impl_gvec!(I8Vec2, i8, BVec2, 2);
405impl_gvec!(I8Vec3, i8, BVec3, 3);
406impl_gvec!(I8Vec4, i8, BVec4, 4);
407impl_gvec!(U8Vec2, u8, BVec2, 2);
408impl_gvec!(U8Vec3, u8, BVec3, 3);
409impl_gvec!(U8Vec4, u8, BVec4, 4);
410impl_gvec!(I16Vec2, i16, BVec2, 2);
411impl_gvec!(I16Vec3, i16, BVec3, 3);
412impl_gvec!(I16Vec4, i16, BVec4, 4);
413impl_gvec!(U16Vec2, u16, BVec2, 2);
414impl_gvec!(U16Vec3, u16, BVec3, 3);
415impl_gvec!(U16Vec4, u16, BVec4, 4);
416impl_gvec!(IVec2, i32, BVec2, 2);
417impl_gvec!(IVec3, i32, BVec3, 3);
418impl_gvec!(IVec4, i32, BVec4, 4);
419impl_gvec!(UVec2, u32, BVec2, 2);
420impl_gvec!(UVec3, u32, BVec3, 3);
421impl_gvec!(UVec4, u32, BVec4, 4);
422impl_gvec!(I64Vec2, i64, BVec2, 2);
423impl_gvec!(I64Vec3, i64, BVec3, 3);
424impl_gvec!(I64Vec4, i64, BVec4, 4);
425impl_gvec!(U64Vec2, u64, BVec2, 2);
426impl_gvec!(U64Vec3, u64, BVec3, 3);
427impl_gvec!(U64Vec4, u64, BVec4, 4);
428impl_gvec!(USizeVec2, usize, BVec2, 2);
429impl_gvec!(USizeVec3, usize, BVec3, 3);
430impl_gvec!(USizeVec4, usize, BVec4, 4);
431impl_gvec!(Vec2, f32, BVec2, 2);
432impl_gvec!(Vec3, f32, BVec3, 3);
433impl_gvec!(Vec3A, f32, BVec3A, 3);
434impl_gvec!(Vec4, f32, BVec4A, 4);
435impl_gvec!(DVec2, f64, BVec2, 2);
436impl_gvec!(DVec3, f64, BVec3, 3);
437impl_gvec!(DVec4, f64, BVec4, 4);
438
439pub trait GVec2
443where
444 Self:
445 GVec<
446 Axes = [Self; 2],
447 Array = [<Self as GVec>::Scalar; 2],
448 I8Vec = I8Vec2,
449 U8Vec = U8Vec2,
450 I16Vec = I16Vec2,
451 U16Vec = U16Vec2,
452 I32Vec = IVec2,
453 U32Vec = UVec2,
454 I64Vec = I64Vec2,
455 U64Vec = U64Vec2,
456 USizeVec = USizeVec2,
457 F32Vec = Vec2,
458 F64Vec = DVec2,
459 > +
460 From<(Self::Scalar, Self::Scalar)> +
461 Into<(Self::Scalar, Self::Scalar)> +
462 ,
463{
464 type Extended;
465 const X: Self;
466 const Y: Self;
467 fn x(self) -> Self::Scalar;
468 fn y(self) -> Self::Scalar;
469 fn new(x: Self::Scalar, y: Self::Scalar) -> Self;
470 fn extend(self, z: Self::Scalar) -> Self::Extended;
471 fn with_x(self, x: Self::Scalar) -> Self;
472 fn with_y(self, y: Self::Scalar) -> Self;
473}
474
475macro_rules! impl_gvec2 {
476 ($type:ty, $extended:ty) => {
477 impl GVec2 for $type {
478 type Extended = $extended;
479 const X: Self = Self::X;
480 const Y: Self = Self::Y;
481 fn x(self) -> Self::Scalar { self.x }
482 fn y(self) -> Self::Scalar { self.y }
483 fn new(x: Self::Scalar, y: Self::Scalar) -> Self { Self::new(x, y) }
484 fn extend(self, z: Self::Scalar) -> Self::Extended { self.extend(z) }
485 fn with_x(self, x: Self::Scalar) -> Self { self.with_x(x) }
486 fn with_y(self, y: Self::Scalar) -> Self { self.with_y(y) }
487 }
488 };
489}
490pub(crate) use impl_gvec2;
491
492impl_gvec2!(I8Vec2, I8Vec3);
493impl_gvec2!(U8Vec2, U8Vec3);
494impl_gvec2!(I16Vec2, I16Vec3);
495impl_gvec2!(U16Vec2, U16Vec3);
496impl_gvec2!(IVec2, IVec3);
497impl_gvec2!(UVec2, UVec3);
498impl_gvec2!(I64Vec2, I64Vec3);
499impl_gvec2!(U64Vec2, U64Vec3);
500impl_gvec2!(USizeVec2, USizeVec3);
501impl_gvec2!(Vec2, Vec3);
502impl_gvec2!(DVec2, DVec3);
503
504pub trait GVec3
508where
509 Self:
510 GVec<
511 Axes = [Self; 3],
512 Array = [<Self as GVec>::Scalar; 3],
513 I8Vec = I8Vec3,
514 U8Vec = U8Vec3,
515 I16Vec = I16Vec3,
516 U16Vec = U16Vec3,
517 I32Vec = IVec3,
518 U32Vec = UVec3,
519 I64Vec = I64Vec3,
520 U64Vec = U64Vec3,
521 USizeVec = USizeVec3,
522 F32Vec = Vec3,
523 F64Vec = DVec3,
524 > +
525 From<(Self::Scalar, Self::Scalar, Self::Scalar)> +
526 Into<(Self::Scalar, Self::Scalar, Self::Scalar)> +
527 ,
528{
529 type Extended;
530 type Truncated;
531 const X: Self;
532 const Y: Self;
533 const Z: Self;
534 fn x(self) -> Self::Scalar;
535 fn y(self) -> Self::Scalar;
536 fn z(self) -> Self::Scalar;
537 fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self;
538 fn extend(self, w: Self::Scalar) -> Self::Extended;
539 fn truncate(self) -> Self::Truncated;
540 fn with_x(self, x: Self::Scalar) -> Self;
541 fn with_y(self, y: Self::Scalar) -> Self;
542 fn with_z(self, z: Self::Scalar) -> Self;
543 fn cross(self, rhs: Self) -> Self;
544}
545
546macro_rules! impl_gvec3 {
547 ($type:ty, $extended:ty, $truncated: ty) => {
548 impl GVec3 for $type {
549 type Extended = $extended;
550 type Truncated = $truncated;
551 const X: Self = Self::X;
552 const Y: Self = Self::Y;
553 const Z: Self = Self::Z;
554 fn x(self) -> Self::Scalar { self.x }
555 fn y(self) -> Self::Scalar { self.y }
556 fn z(self) -> Self::Scalar { self.z }
557 fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self { Self::new(x, y, z) }
558 fn extend(self, w: Self::Scalar) -> Self::Extended { self.extend(w) }
559 fn truncate(self) -> Self::Truncated { self.truncate() }
560 fn with_x(self, x: Self::Scalar) -> Self { self.with_x(x) }
561 fn with_y(self, y: Self::Scalar) -> Self { self.with_y(y) }
562 fn with_z(self, z: Self::Scalar) -> Self { self.with_z(z) }
563 fn cross(self, rhs: Self) -> Self { self.cross(rhs) }
564 }
565 };
566}
567pub(crate) use impl_gvec3;
568
569impl_gvec3!(I8Vec3, I8Vec4, I8Vec2);
570impl_gvec3!(U8Vec3, U8Vec4, U8Vec2);
571impl_gvec3!(I16Vec3, I16Vec4, I16Vec2);
572impl_gvec3!(U16Vec3, U16Vec4, U16Vec2);
573impl_gvec3!(IVec3, IVec4, IVec2);
574impl_gvec3!(UVec3, UVec4, UVec2);
575impl_gvec3!(I64Vec3, I64Vec4, I64Vec2);
576impl_gvec3!(U64Vec3, U64Vec4, U64Vec2);
577impl_gvec3!(USizeVec3, USizeVec4, USizeVec2);
578impl_gvec3!(Vec3, Vec4, Vec2);
579impl_gvec3!(Vec3A, Vec4, Vec2);
580impl_gvec3!(DVec3, DVec4, DVec2);
581
582pub trait GVec4
586where
587 Self:
588 GVec<
589 Axes = [Self; 4],
590 Array = [<Self as GVec>::Scalar; 4],
591 I8Vec = I8Vec4,
592 U8Vec = U8Vec4,
593 I16Vec = I16Vec4,
594 U16Vec = U16Vec4,
595 I32Vec = IVec4,
596 U32Vec = UVec4,
597 I64Vec = I64Vec4,
598 U64Vec = U64Vec4,
599 USizeVec = USizeVec4,
600 F32Vec = Vec4,
601 F64Vec = DVec4,
602 > +
603 From<(Self::Scalar, Self::Scalar, Self::Scalar, Self::Scalar)> +
604 Into<(Self::Scalar, Self::Scalar, Self::Scalar, Self::Scalar)> +
605 ,
606{
607 type Truncated;
608 const X: Self;
609 const Y: Self;
610 const Z: Self;
611 const W: Self;
612 fn x(self) -> Self::Scalar;
613 fn y(self) -> Self::Scalar;
614 fn z(self) -> Self::Scalar;
615 fn w(self) -> Self::Scalar;
616 fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar, w: Self::Scalar) -> Self;
617 fn truncate(self) -> Self::Truncated;
618 fn with_x(self, x: Self::Scalar) -> Self;
619 fn with_y(self, y: Self::Scalar) -> Self;
620 fn with_z(self, z: Self::Scalar) -> Self;
621 fn with_w(self, w: Self::Scalar) -> Self;
622}
623
624macro_rules! impl_gvec4 {
625 ($type:ty, $truncated:ty) => {
626 impl GVec4 for $type {
627 type Truncated = $truncated;
628 const X: Self = Self::X;
629 const Y: Self = Self::Y;
630 const Z: Self = Self::Z;
631 const W: Self = Self::W;
632 fn x(self) -> Self::Scalar { self.x }
633 fn y(self) -> Self::Scalar { self.y }
634 fn z(self) -> Self::Scalar { self.z }
635 fn w(self) -> Self::Scalar { self.w }
636 fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar, w: Self::Scalar) -> Self { Self::new(x, y, z, w) }
637 fn truncate(self) -> Self::Truncated { self.truncate() }
638 fn with_x(self, x: Self::Scalar) -> Self { self.with_x(x) }
639 fn with_y(self, y: Self::Scalar) -> Self { self.with_y(y) }
640 fn with_z(self, z: Self::Scalar) -> Self { self.with_z(z) }
641 fn with_w(self, w: Self::Scalar) -> Self { self.with_w(w) }
642 }
643 };
644}
645pub(crate) use impl_gvec4;
646
647impl_gvec4!(I8Vec4, I8Vec3);
648impl_gvec4!(U8Vec4, U8Vec3);
649impl_gvec4!(I16Vec4, I16Vec3);
650impl_gvec4!(U16Vec4, U16Vec3);
651impl_gvec4!(IVec4, IVec3);
652impl_gvec4!(UVec4, UVec3);
653impl_gvec4!(I64Vec4, I64Vec3);
654impl_gvec4!(U64Vec4, U64Vec3);
655impl_gvec4!(USizeVec4, USizeVec3);
656impl_gvec4!(Vec4, Vec3);
657impl_gvec4!(DVec4, DVec3);
658
659pub trait SignedVec: GVec + Neg {
663 const NEG_ONE: Self;
664 fn abs(self) -> Self;
665 fn signum(self) -> Self;
666 fn is_negative_bitmask(self) -> u32;
667 fn distance_squared(self, rhs: Self) -> Self::Scalar;
668 fn div_euclid(self, rhs: Self) -> Self;
669 fn rem_euclid(self, rhs: Self) -> Self;
670}
671
672macro_rules! impl_signedvec {
673 ($type:ty) => {
674 impl SignedVec for $type {
675 const NEG_ONE: Self = Self::NEG_ONE;
676 fn abs(self) -> Self { self.abs() }
677 fn signum(self) -> Self { self.signum() }
678 fn is_negative_bitmask(self) -> u32 { self.is_negative_bitmask() }
679 fn distance_squared(self, rhs: Self) -> Self::Scalar { self.distance_squared(rhs) }
680 fn div_euclid(self, rhs: Self) -> Self { self.div_euclid(rhs) }
681 fn rem_euclid(self, rhs: Self) -> Self { self.rem_euclid(rhs) }
682 }
683 };
684}
685pub(crate) use impl_signedvec;
686
687impl_signedvec!(I16Vec2);
688impl_signedvec!(I16Vec3);
689impl_signedvec!(I16Vec4);
690impl_signedvec!(I8Vec2);
691impl_signedvec!(I8Vec3);
692impl_signedvec!(I8Vec4);
693impl_signedvec!(IVec2);
694impl_signedvec!(IVec3);
695impl_signedvec!(IVec4);
696impl_signedvec!(I64Vec2);
697impl_signedvec!(I64Vec3);
698impl_signedvec!(I64Vec4);
699impl_signedvec!(Vec2);
700impl_signedvec!(Vec3);
701impl_signedvec!(Vec3A);
702impl_signedvec!(Vec4);
703impl_signedvec!(DVec2);
704impl_signedvec!(DVec3);
705impl_signedvec!(DVec4);
706
707pub trait SignedVec2: SignedVec + GVec2 {
711 const NEG_X: Self;
712 const NEG_Y: Self;
713 fn perp(self) -> Self;
714 fn perp_dot(self, rhs: Self) -> Self::Scalar;
715 fn rotate(self, rhs: Self) -> Self;
716}
717
718macro_rules! impl_signedvec2 {
719 ($type:ty) => {
720 impl SignedVec2 for $type {
721 const NEG_X: Self = Self::NEG_X;
722 const NEG_Y: Self = Self::NEG_Y;
723 fn perp(self) -> Self { self.perp() }
724 fn perp_dot(self, rhs: Self) -> Self::Scalar { self.perp_dot(rhs) }
725 fn rotate(self, rhs: Self) -> Self { self.rotate(rhs) }
726 }
727 };
728}
729pub(crate) use impl_signedvec2;
730
731impl_signedvec2!(I8Vec2);
732impl_signedvec2!(I16Vec2);
733impl_signedvec2!(IVec2);
734impl_signedvec2!(I64Vec2);
735impl_signedvec2!(Vec2);
736impl_signedvec2!(DVec2);
737
738pub trait SignedVec3: SignedVec + GVec3 {
742 const NEG_X: Self;
743 const NEG_Y: Self;
744 const NEG_Z: Self;
745}
746
747macro_rules! impl_signedvec3 {
748 ($type:ty) => {
749 impl SignedVec3 for $type {
750 const NEG_X: Self = Self::NEG_X;
751 const NEG_Y: Self = Self::NEG_Y;
752 const NEG_Z: Self = Self::NEG_Z;
753 }
754 };
755}
756pub(crate) use impl_signedvec3;
757
758impl_signedvec3!(I8Vec3);
759impl_signedvec3!(I16Vec3);
760impl_signedvec3!(IVec3);
761impl_signedvec3!(I64Vec3);
762impl_signedvec3!(Vec3);
763impl_signedvec3!(Vec3A);
764impl_signedvec3!(DVec3);
765
766pub trait SignedVec4: SignedVec + GVec4 {
770 const NEG_X: Self;
771 const NEG_Y: Self;
772 const NEG_Z: Self;
773 const NEG_W: Self;
774}
775
776macro_rules! impl_signedvec4 {
777 ($type:ty) => {
778 impl SignedVec4 for $type {
779 const NEG_X: Self = Self::NEG_X;
780 const NEG_Y: Self = Self::NEG_Y;
781 const NEG_Z: Self = Self::NEG_Z;
782 const NEG_W: Self = Self::NEG_W;
783 }
784 };
785}
786pub(crate) use impl_signedvec4;
787
788impl_signedvec4!(I8Vec4);
789impl_signedvec4!(I16Vec4);
790impl_signedvec4!(IVec4);
791impl_signedvec4!(I64Vec4);
792impl_signedvec4!(Vec4);
793impl_signedvec4!(DVec4);
794
795pub trait FloatVec: SignedVec {
799 const NAN: Self;
800 const INFINITY: Self;
801 const NEG_INFINITY: Self;
802 fn copysign(self, rhs: Self) -> Self;
803 fn is_finite(self) -> bool;
804 fn is_finite_mask(self) -> Self::BVec;
805 fn is_nan(self) -> bool;
806 fn is_nan_mask(self) -> Self::BVec;
807 fn length(self) -> Self::Scalar;
808 fn length_recip(self) -> Self::Scalar;
809 fn distance(self, rhs: Self) -> Self::Scalar;
810 fn normalize(self) -> Self;
811 fn try_normalize(self) -> Option<Self>;
812 fn normalize_or(self, fallback: Self) -> Self;
813 fn normalize_or_zero(self) -> Self;
814 fn normalize_and_length(self) -> (Self, Self::Scalar);
815 fn is_normalized(self) -> bool;
816 fn project_onto(self, rhs: Self) -> Self;
817 fn reject_from(self, rhs: Self) -> Self;
818 fn project_onto_normalized(self, rhs: Self) -> Self;
819 fn reject_from_normalized(self, rhs: Self) -> Self;
820 fn round(self) -> Self;
821 fn floor(self) -> Self;
822 fn ceil(self) -> Self;
823 fn trunc(self) -> Self;
824 fn fract(self) -> Self;
825 fn fract_gl(self) -> Self;
826 fn exp(self) -> Self;
827 fn powf(self, n: Self::Scalar) -> Self;
828 fn recip(self) -> Self;
829 fn lerp(self, rhs: Self, s: Self::Scalar) -> Self;
830 fn move_towards(&self, rhs: Self, d: Self::Scalar) -> Self;
831 fn midpoint(self, rhs: Self) -> Self;
832 fn abs_diff_eq(self, rhs: Self, max_abs_diff: Self::Scalar) -> bool;
833 fn clamp_length(self, min: Self::Scalar, max: Self::Scalar) -> Self;
834 fn clamp_length_max(self, max: Self::Scalar) -> Self;
835 fn clamp_length_min(self, min: Self::Scalar) -> Self;
836 fn mul_add(self, a: Self, b: Self) -> Self;
837 fn reflect(self, normal: Self) -> Self;
838 fn refract(self, normal: Self, eta: Self::Scalar) -> Self;
839}
840
841macro_rules! impl_floatvec {
842 ($type:ty) => {
843 impl FloatVec for $type {
844 const NAN: Self = Self::NAN;
845 const INFINITY: Self = Self::INFINITY;
846 const NEG_INFINITY: Self = Self::NEG_INFINITY;
847 fn copysign(self, rhs: Self) -> Self { self.copysign(rhs) }
848 fn is_finite(self) -> bool { self.is_finite() }
849 fn is_finite_mask(self) -> Self::BVec { self.is_finite_mask() }
850 fn is_nan(self) -> bool { self.is_nan() }
851 fn is_nan_mask(self) -> Self::BVec { self.is_nan_mask() }
852 fn length(self) -> Self::Scalar { self.length() }
853 fn length_recip(self) -> Self::Scalar { self.length_recip() }
854 fn distance(self, rhs: Self) -> Self::Scalar { self.distance(rhs) }
855 fn normalize(self) -> Self { self.normalize() }
856 fn try_normalize(self) -> Option<Self> { self.try_normalize() }
857 fn normalize_or(self, fallback: Self) -> Self { self.normalize_or(fallback) }
858 fn normalize_or_zero(self) -> Self { self.normalize_or_zero() }
859 fn normalize_and_length(self) -> (Self, Self::Scalar) { self.normalize_and_length() }
860 fn is_normalized(self) -> bool { self.is_normalized() }
861 fn project_onto(self, rhs: Self) -> Self { self.project_onto(rhs) }
862 fn reject_from(self, rhs: Self) -> Self { self.reject_from(rhs) }
863 fn project_onto_normalized(self, rhs: Self) -> Self { self.project_onto_normalized(rhs) }
864 fn reject_from_normalized(self, rhs: Self) -> Self { self.reject_from_normalized(rhs) }
865 fn round(self) -> Self { self.round() }
866 fn floor(self) -> Self { self.floor() }
867 fn ceil(self) -> Self { self.ceil() }
868 fn trunc(self) -> Self { self.trunc() }
869 fn fract(self) -> Self { self.fract() }
870 fn fract_gl(self) -> Self { self.fract_gl() }
871 fn exp(self) -> Self { self.exp() }
872 fn powf(self, n: Self::Scalar) -> Self { self.powf(n) }
873 fn recip(self) -> Self { self.recip() }
874 fn lerp(self, rhs: Self, s: Self::Scalar) -> Self { self.lerp(rhs, s) }
875 fn move_towards(&self, rhs: Self, d: Self::Scalar) -> Self { self.move_towards(rhs, d) }
876 fn midpoint(self, rhs: Self) -> Self { self.midpoint(rhs) }
877 fn abs_diff_eq(self, rhs: Self, max_abs_diff: Self::Scalar) -> bool { self.abs_diff_eq(rhs, max_abs_diff) }
878 fn clamp_length(self, min: Self::Scalar, max: Self::Scalar) -> Self { self.clamp_length(min, max) }
879 fn clamp_length_max(self, max: Self::Scalar) -> Self { self.clamp_length_max(max) }
880 fn clamp_length_min(self, min: Self::Scalar) -> Self { self.clamp_length_min(min) }
881 fn mul_add(self, a: Self, b: Self) -> Self { self.mul_add(a, b) }
882 fn reflect(self, normal: Self) -> Self { self.reflect(normal) }
883 fn refract(self, normal: Self, eta: Self::Scalar) -> Self { self.refract(normal, eta) }
884 }
885 };
886}
887
888impl_floatvec!(Vec2);
889impl_floatvec!(Vec3);
890impl_floatvec!(Vec3A);
891impl_floatvec!(Vec4);
892impl_floatvec!(DVec2);
893impl_floatvec!(DVec3);
894impl_floatvec!(DVec4);
895
896pub trait FloatVec2: FloatVec + SignedVec2 {
900 fn angle_to(self, rhs: Self) -> Self::Scalar;
901 fn from_angle(angle: Self::Scalar) -> Self;
902 fn to_angle(self) -> Self::Scalar;
903 fn rotate_towards(&self, rhs: Self, max_angle: Self::Scalar) -> Self;
904}
905
906macro_rules! impl_floatvec2 {
907 ($type:ty) => {
908 impl FloatVec2 for $type {
909 fn angle_to(self, rhs: Self) -> Self::Scalar { self.angle_to(rhs) }
910 fn from_angle(angle: Self::Scalar) -> Self { Self::from_angle(angle) }
911 fn to_angle(self) -> Self::Scalar { self.to_angle() }
912 fn rotate_towards(&self, rhs: Self, max_angle: Self::Scalar) -> Self { self.rotate_towards(rhs, max_angle) }
913 }
914 };
915}
916
917impl_floatvec2!(Vec2);
918impl_floatvec2!(DVec2);
919
920pub trait FloatVec3: FloatVec + SignedVec3 {
924 fn angle_between(self, rhs: Self) -> Self::Scalar;
925 fn any_orthogonal_vector(&self) -> Self;
926 fn any_orthonormal_vector(&self) -> Self;
927 fn any_orthonormal_pair(&self) -> (Self, Self);
928 fn rotate_towards(self, rhs: Self, max_angle: Self::Scalar) -> Self;
929 fn slerp(self, rhs: Self, s: Self::Scalar) -> Self;
930}
931
932macro_rules! impl_floatvec3 {
933 ($type:ty) => {
934 impl FloatVec3 for $type {
935 fn angle_between(self, rhs: Self) -> Self::Scalar { self.angle_between(rhs) }
936 fn any_orthogonal_vector(&self) -> Self { self.any_orthogonal_vector() }
937 fn any_orthonormal_vector(&self) -> Self { self.any_orthonormal_vector() }
938 fn any_orthonormal_pair(&self) -> (Self, Self) { self.any_orthonormal_pair() }
939 fn rotate_towards(self, rhs: Self, max_angle: Self::Scalar) -> Self { self.rotate_towards(rhs, max_angle) }
940 fn slerp(self, rhs: Self, s: Self::Scalar) -> Self { self.slerp(rhs, s) }
941 }
942 };
943}
944
945impl_floatvec3!(Vec3);
946impl_floatvec3!(Vec3A);
947impl_floatvec3!(DVec3);
948
949pub trait FloatVec4: FloatVec + SignedVec4 {}
953
954impl FloatVec4 for Vec4 {}
955impl FloatVec4 for DVec4 {}
956
957pub trait IntVec
961where
962 Self:
963 GVec +
964 Eq +
965 Not<Output = Self> +
966 BitAnd<Output = Self> +
967 BitAnd<Self::Scalar, Output = Self> +
968 BitOr<Output = Self> +
969 BitOr<Self::Scalar, Output = Self> +
970 BitXor<Output = Self> +
971 BitXor<Self::Scalar, Output = Self> +
972 Shl<i8, Output = Self> +
973 Shr<i8, Output = Self> +
974 Shl<i16, Output = Self> +
975 Shr<i16, Output = Self> +
976 Shl<i32, Output = Self> +
977 Shr<i32, Output = Self> +
978 Shl<i64, Output = Self> +
979 Shr<i64, Output = Self> +
980 Shl<u8, Output = Self> +
981 Shr<u8, Output = Self> +
982 Shl<u16, Output = Self> +
983 Shr<u16, Output = Self> +
984 Shl<u32, Output = Self> +
985 Shr<u32, Output = Self> +
986 Shl<u64, Output = Self> +
987 Shr<u64, Output = Self> +
988 ,
989{
990 type UnsignedScalar;
991 fn checked_add(self, rhs: Self) -> Option<Self>;
992 fn checked_sub(self, rhs: Self) -> Option<Self>;
993 fn checked_mul(self, rhs: Self) -> Option<Self>;
994 fn checked_div(self, rhs: Self) -> Option<Self>;
995 fn wrapping_add(self, rhs: Self) -> Self;
996 fn wrapping_sub(self, rhs: Self) -> Self;
997 fn wrapping_mul(self, rhs: Self) -> Self;
998 fn wrapping_div(self, rhs: Self) -> Self;
999 fn saturating_add(self, rhs: Self) -> Self;
1000 fn saturating_sub(self, rhs: Self) -> Self;
1001 fn saturating_mul(self, rhs: Self) -> Self;
1002 fn saturating_div(self, rhs: Self) -> Self;
1003 fn manhattan_distance(self, rhs: Self) -> Self::UnsignedScalar;
1004 fn checked_manhattan_distance(self, rhs: Self) -> Option<Self::UnsignedScalar>;
1005 fn chebyshev_distance(self, rhs: Self) -> Self::UnsignedScalar;
1006}
1007
1008macro_rules! impl_intvec {
1009 ($type:ty, $unsigned:ty) => {
1010 impl IntVec for $type {
1011 type UnsignedScalar = $unsigned;
1012 fn checked_add(self, rhs: Self) -> Option<Self> { self.checked_add(rhs) }
1013 fn checked_sub(self, rhs: Self) -> Option<Self> { self.checked_sub(rhs) }
1014 fn checked_mul(self, rhs: Self) -> Option<Self> { self.checked_mul(rhs) }
1015 fn checked_div(self, rhs: Self) -> Option<Self> { self.checked_div(rhs) }
1016 fn wrapping_add(self, rhs: Self) -> Self { self.wrapping_add(rhs) }
1017 fn wrapping_sub(self, rhs: Self) -> Self { self.wrapping_sub(rhs) }
1018 fn wrapping_mul(self, rhs: Self) -> Self { self.wrapping_mul(rhs) }
1019 fn wrapping_div(self, rhs: Self) -> Self { self.wrapping_div(rhs) }
1020 fn saturating_add(self, rhs: Self) -> Self { self.saturating_add(rhs) }
1021 fn saturating_sub(self, rhs: Self) -> Self { self.saturating_sub(rhs) }
1022 fn saturating_mul(self, rhs: Self) -> Self { self.saturating_mul(rhs) }
1023 fn saturating_div(self, rhs: Self) -> Self { self.saturating_div(rhs) }
1024 fn manhattan_distance(self, rhs: Self) -> Self::UnsignedScalar { self.manhattan_distance(rhs) }
1025 fn checked_manhattan_distance(self, rhs: Self) -> Option<Self::UnsignedScalar> { self.checked_manhattan_distance(rhs) }
1026 fn chebyshev_distance(self, rhs: Self) -> Self::UnsignedScalar { self.chebyshev_distance(rhs) }
1027 }
1028 };
1029}
1030pub(crate) use impl_intvec;
1031
1032impl_intvec!(I8Vec2, u8);
1033impl_intvec!(I8Vec3, u8);
1034impl_intvec!(I8Vec4, u8);
1035impl_intvec!(U8Vec2, u8);
1036impl_intvec!(U8Vec3, u8);
1037impl_intvec!(U8Vec4, u8);
1038impl_intvec!(I16Vec2, u16);
1039impl_intvec!(I16Vec3, u16);
1040impl_intvec!(I16Vec4, u16);
1041impl_intvec!(U16Vec2, u16);
1042impl_intvec!(U16Vec3, u16);
1043impl_intvec!(U16Vec4, u16);
1044impl_intvec!(IVec2, u32);
1045impl_intvec!(IVec3, u32);
1046impl_intvec!(IVec4, u32);
1047impl_intvec!(UVec2, u32);
1048impl_intvec!(UVec3, u32);
1049impl_intvec!(UVec4, u32);
1050impl_intvec!(I64Vec2, u64);
1051impl_intvec!(I64Vec3, u64);
1052impl_intvec!(I64Vec4, u64);
1053impl_intvec!(U64Vec2, u64);
1054impl_intvec!(U64Vec3, u64);
1055impl_intvec!(U64Vec4, u64);
1056impl_intvec!(USizeVec2, usize);
1057impl_intvec!(USizeVec3, usize);
1058impl_intvec!(USizeVec4, usize);
1059
1060pub trait IntVec2
1064where
1065 Self:
1066 IntVec +
1067 GVec2 +
1068 Shl<IVec2, Output = Self> +
1069 Shr<IVec2, Output = Self> +
1070 Shl<UVec2, Output = Self> +
1071 Shr<UVec2, Output = Self> +
1072 ,
1073{}
1074
1075impl IntVec2 for I8Vec2 {}
1076impl IntVec2 for U8Vec2 {}
1077impl IntVec2 for I16Vec2 {}
1078impl IntVec2 for U16Vec2 {}
1079impl IntVec2 for IVec2 {}
1080impl IntVec2 for UVec2 {}
1081impl IntVec2 for I64Vec2 {}
1082impl IntVec2 for U64Vec2 {}
1083impl IntVec2 for USizeVec2 {}
1084
1085pub trait IntVec3
1089where
1090 Self:
1091 IntVec +
1092 GVec3<BVec = BVec3> +
1093 Shl<IVec3, Output = Self> +
1094 Shr<IVec3, Output = Self> +
1095 Shl<UVec3, Output = Self> +
1096 Shr<UVec3, Output = Self> +
1097 ,
1098{}
1099
1100impl IntVec3 for I8Vec3 {}
1101impl IntVec3 for U8Vec3 {}
1102impl IntVec3 for I16Vec3 {}
1103impl IntVec3 for U16Vec3 {}
1104impl IntVec3 for IVec3 {}
1105impl IntVec3 for UVec3 {}
1106impl IntVec3 for I64Vec3 {}
1107impl IntVec3 for U64Vec3 {}
1108impl IntVec3 for USizeVec3 {}
1109
1110pub trait IntVec4
1114where
1115 Self:
1116 IntVec +
1117 GVec4<BVec = BVec4> +
1118 Shl<IVec4, Output = Self> +
1119 Shr<IVec4, Output = Self> +
1120 Shl<UVec4, Output = Self> +
1121 Shr<UVec4, Output = Self> +
1122 ,
1123{}
1124
1125impl IntVec4 for I8Vec4 {}
1126impl IntVec4 for U8Vec4 {}
1127impl IntVec4 for I16Vec4 {}
1128impl IntVec4 for U16Vec4 {}
1129impl IntVec4 for IVec4 {}
1130impl IntVec4 for UVec4 {}
1131impl IntVec4 for I64Vec4 {}
1132impl IntVec4 for U64Vec4 {}
1133impl IntVec4 for USizeVec4 {}
1134
1135pub trait SIntVec: IntVec + SignedVec {}
1139
1140impl SIntVec for I8Vec2 {}
1141impl SIntVec for I8Vec3 {}
1142impl SIntVec for I8Vec4 {}
1143impl SIntVec for I16Vec2 {}
1144impl SIntVec for I16Vec3 {}
1145impl SIntVec for I16Vec4 {}
1146impl SIntVec for IVec2 {}
1147impl SIntVec for IVec3 {}
1148impl SIntVec for IVec4 {}
1149impl SIntVec for I64Vec2 {}
1150impl SIntVec for I64Vec3 {}
1151impl SIntVec for I64Vec4 {}
1152
1153pub trait SIntVec2: SIntVec + IntVec2 {}
1157
1158impl SIntVec2 for I8Vec2 {}
1159impl SIntVec2 for I16Vec2 {}
1160impl SIntVec2 for IVec2 {}
1161impl SIntVec2 for I64Vec2 {}
1162
1163pub trait SIntVec3: SIntVec + IntVec3 {}
1167
1168impl SIntVec3 for I8Vec3 {}
1169impl SIntVec3 for I16Vec3 {}
1170impl SIntVec3 for IVec3 {}
1171impl SIntVec3 for I64Vec3 {}
1172
1173pub trait SIntVec4: SIntVec + IntVec4 {}
1177
1178impl SIntVec4 for I8Vec4 {}
1179impl SIntVec4 for I16Vec4 {}
1180impl SIntVec4 for IVec4 {}
1181impl SIntVec4 for I64Vec4 {}
1182
1183pub trait UIntVec: IntVec {}
1187
1188impl UIntVec for U8Vec2 {}
1189impl UIntVec for U8Vec3 {}
1190impl UIntVec for U8Vec4 {}
1191impl UIntVec for U16Vec2 {}
1192impl UIntVec for U16Vec3 {}
1193impl UIntVec for U16Vec4 {}
1194impl UIntVec for UVec2 {}
1195impl UIntVec for UVec3 {}
1196impl UIntVec for UVec4 {}
1197impl UIntVec for U64Vec2 {}
1198impl UIntVec for U64Vec3 {}
1199impl UIntVec for U64Vec4 {}
1200impl UIntVec for USizeVec2 {}
1201impl UIntVec for USizeVec3 {}
1202impl UIntVec for USizeVec4 {}
1203
1204pub trait UIntVec2: UIntVec + IntVec2 {}
1208
1209impl UIntVec2 for U8Vec2 {}
1210impl UIntVec2 for U16Vec2 {}
1211impl UIntVec2 for UVec2 {}
1212impl UIntVec2 for U64Vec2 {}
1213impl UIntVec2 for USizeVec2 {}
1214
1215pub trait UIntVec3: UIntVec + IntVec3 {}
1219
1220impl UIntVec3 for U8Vec3 {}
1221impl UIntVec3 for U16Vec3 {}
1222impl UIntVec3 for UVec3 {}
1223impl UIntVec3 for U64Vec3 {}
1224impl UIntVec3 for USizeVec3 {}
1225
1226pub trait UIntVec4: UIntVec + IntVec4 {}
1230
1231impl UIntVec4 for U8Vec4 {}
1232impl UIntVec4 for U16Vec4 {}
1233impl UIntVec4 for UVec4 {}
1234impl UIntVec4 for U64Vec4 {}
1235impl UIntVec4 for USizeVec4 {}
1236
1237pub trait I8Vec: SIntVec<Scalar = i8> {}
1241
1242impl I8Vec for I8Vec2 {}
1243impl I8Vec for I8Vec3 {}
1244impl I8Vec for I8Vec4 {}
1245
1246pub trait U8Vec: UIntVec<Scalar = u8> {}
1250
1251impl U8Vec for U8Vec2 {}
1252impl U8Vec for U8Vec3 {}
1253impl U8Vec for U8Vec4 {}
1254
1255pub trait I16Vec: SIntVec<Scalar = i16> {}
1259
1260impl I16Vec for I16Vec2 {}
1261impl I16Vec for I16Vec3 {}
1262impl I16Vec for I16Vec4 {}
1263
1264pub trait U16Vec: UIntVec<Scalar = u16> {}
1268
1269impl U16Vec for U16Vec2 {}
1270impl U16Vec for U16Vec3 {}
1271impl U16Vec for U16Vec4 {}
1272
1273pub trait I32Vec: SIntVec<Scalar = i32> {}
1277
1278impl I32Vec for IVec2 {}
1279impl I32Vec for IVec3 {}
1280impl I32Vec for IVec4 {}
1281
1282pub trait U32Vec: UIntVec<Scalar = u32> {}
1286
1287impl U32Vec for UVec2 {}
1288impl U32Vec for UVec3 {}
1289impl U32Vec for UVec4 {}
1290
1291pub trait I64Vec: SIntVec<Scalar = i64> {}
1295
1296impl I64Vec for I64Vec2 {}
1297impl I64Vec for I64Vec3 {}
1298impl I64Vec for I64Vec4 {}
1299
1300pub trait U64Vec: UIntVec<Scalar = u64> {}
1304
1305impl U64Vec for U64Vec2 {}
1306impl U64Vec for U64Vec3 {}
1307impl U64Vec for U64Vec4 {}
1308
1309pub trait USizeVec: UIntVec<Scalar = usize> {}
1313
1314impl USizeVec for USizeVec2 {}
1315impl USizeVec for USizeVec3 {}
1316impl USizeVec for USizeVec4 {}
1317
1318pub trait F32Vec: FloatVec<Scalar = f32> {}
1322
1323impl F32Vec for Vec2 {}
1324impl F32Vec for Vec3 {}
1325impl F32Vec for Vec3A {}
1326impl F32Vec for Vec4 {}
1327
1328pub trait F64Vec: FloatVec<Scalar = f64> {}
1332
1333impl F64Vec for DVec2 {}
1334impl F64Vec for DVec3 {}
1335impl F64Vec for DVec4 {}