1 // Generated from vec.rs.tera template. Edit the template, not the generated file.
2 
3 use crate::{BVec3, I16Vec3, I64Vec2, I64Vec4, IVec3, U16Vec3, U64Vec3, UVec3};
4 
5 #[cfg(not(target_arch = "spirv"))]
6 use core::fmt;
7 use core::iter::{Product, Sum};
8 use core::{f32, ops::*};
9 
10 /// Creates a 3-dimensional vector.
11 #[inline(always)]
12 #[must_use]
i64vec3(x: i64, y: i64, z: i64) -> I64Vec313 pub const fn i64vec3(x: i64, y: i64, z: i64) -> I64Vec3 {
14     I64Vec3::new(x, y, z)
15 }
16 
17 /// A 3-dimensional vector.
18 #[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
19 #[derive(Clone, Copy, PartialEq, Eq)]
20 #[cfg_attr(not(target_arch = "spirv"), repr(C))]
21 #[cfg_attr(target_arch = "spirv", repr(simd))]
22 pub struct I64Vec3 {
23     pub x: i64,
24     pub y: i64,
25     pub z: i64,
26 }
27 
28 impl I64Vec3 {
29     /// All zeroes.
30     pub const ZERO: Self = Self::splat(0);
31 
32     /// All ones.
33     pub const ONE: Self = Self::splat(1);
34 
35     /// All negative ones.
36     pub const NEG_ONE: Self = Self::splat(-1);
37 
38     /// All `i64::MIN`.
39     pub const MIN: Self = Self::splat(i64::MIN);
40 
41     /// All `i64::MAX`.
42     pub const MAX: Self = Self::splat(i64::MAX);
43 
44     /// A unit vector pointing along the positive X axis.
45     pub const X: Self = Self::new(1, 0, 0);
46 
47     /// A unit vector pointing along the positive Y axis.
48     pub const Y: Self = Self::new(0, 1, 0);
49 
50     /// A unit vector pointing along the positive Z axis.
51     pub const Z: Self = Self::new(0, 0, 1);
52 
53     /// A unit vector pointing along the negative X axis.
54     pub const NEG_X: Self = Self::new(-1, 0, 0);
55 
56     /// A unit vector pointing along the negative Y axis.
57     pub const NEG_Y: Self = Self::new(0, -1, 0);
58 
59     /// A unit vector pointing along the negative Z axis.
60     pub const NEG_Z: Self = Self::new(0, 0, -1);
61 
62     /// The unit axes.
63     pub const AXES: [Self; 3] = [Self::X, Self::Y, Self::Z];
64 
65     /// Creates a new vector.
66     #[inline(always)]
67     #[must_use]
new(x: i64, y: i64, z: i64) -> Self68     pub const fn new(x: i64, y: i64, z: i64) -> Self {
69         Self { x, y, z }
70     }
71 
72     /// Creates a vector with all elements set to `v`.
73     #[inline]
74     #[must_use]
splat(v: i64) -> Self75     pub const fn splat(v: i64) -> Self {
76         Self { x: v, y: v, z: v }
77     }
78 
79     /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use
80     /// for each element of `self`.
81     ///
82     /// A true element in the mask uses the corresponding element from `if_true`, and false
83     /// uses the element from `if_false`.
84     #[inline]
85     #[must_use]
select(mask: BVec3, if_true: Self, if_false: Self) -> Self86     pub fn select(mask: BVec3, if_true: Self, if_false: Self) -> Self {
87         Self {
88             x: if mask.test(0) { if_true.x } else { if_false.x },
89             y: if mask.test(1) { if_true.y } else { if_false.y },
90             z: if mask.test(2) { if_true.z } else { if_false.z },
91         }
92     }
93 
94     /// Creates a new vector from an array.
95     #[inline]
96     #[must_use]
from_array(a: [i64; 3]) -> Self97     pub const fn from_array(a: [i64; 3]) -> Self {
98         Self::new(a[0], a[1], a[2])
99     }
100 
101     /// `[x, y, z]`
102     #[inline]
103     #[must_use]
to_array(&self) -> [i64; 3]104     pub const fn to_array(&self) -> [i64; 3] {
105         [self.x, self.y, self.z]
106     }
107 
108     /// Creates a vector from the first 3 values in `slice`.
109     ///
110     /// # Panics
111     ///
112     /// Panics if `slice` is less than 3 elements long.
113     #[inline]
114     #[must_use]
from_slice(slice: &[i64]) -> Self115     pub const fn from_slice(slice: &[i64]) -> Self {
116         Self::new(slice[0], slice[1], slice[2])
117     }
118 
119     /// Writes the elements of `self` to the first 3 elements in `slice`.
120     ///
121     /// # Panics
122     ///
123     /// Panics if `slice` is less than 3 elements long.
124     #[inline]
write_to_slice(self, slice: &mut [i64])125     pub fn write_to_slice(self, slice: &mut [i64]) {
126         slice[0] = self.x;
127         slice[1] = self.y;
128         slice[2] = self.z;
129     }
130 
131     /// Internal method for creating a 3D vector from a 4D vector, discarding `w`.
132     #[allow(dead_code)]
133     #[inline]
134     #[must_use]
from_vec4(v: I64Vec4) -> Self135     pub(crate) fn from_vec4(v: I64Vec4) -> Self {
136         Self {
137             x: v.x,
138             y: v.y,
139             z: v.z,
140         }
141     }
142 
143     /// Creates a 4D vector from `self` and the given `w` value.
144     #[inline]
145     #[must_use]
extend(self, w: i64) -> I64Vec4146     pub fn extend(self, w: i64) -> I64Vec4 {
147         I64Vec4::new(self.x, self.y, self.z, w)
148     }
149 
150     /// Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`.
151     ///
152     /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()].
153     #[inline]
154     #[must_use]
truncate(self) -> I64Vec2155     pub fn truncate(self) -> I64Vec2 {
156         use crate::swizzles::Vec3Swizzles;
157         self.xy()
158     }
159 
160     /// Computes the dot product of `self` and `rhs`.
161     #[inline]
162     #[must_use]
dot(self, rhs: Self) -> i64163     pub fn dot(self, rhs: Self) -> i64 {
164         (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z)
165     }
166 
167     /// Returns a vector where every component is the dot product of `self` and `rhs`.
168     #[inline]
169     #[must_use]
dot_into_vec(self, rhs: Self) -> Self170     pub fn dot_into_vec(self, rhs: Self) -> Self {
171         Self::splat(self.dot(rhs))
172     }
173 
174     /// Computes the cross product of `self` and `rhs`.
175     #[inline]
176     #[must_use]
cross(self, rhs: Self) -> Self177     pub fn cross(self, rhs: Self) -> Self {
178         Self {
179             x: self.y * rhs.z - rhs.y * self.z,
180             y: self.z * rhs.x - rhs.z * self.x,
181             z: self.x * rhs.y - rhs.x * self.y,
182         }
183     }
184 
185     /// Returns a vector containing the minimum values for each element of `self` and `rhs`.
186     ///
187     /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`.
188     #[inline]
189     #[must_use]
min(self, rhs: Self) -> Self190     pub fn min(self, rhs: Self) -> Self {
191         Self {
192             x: self.x.min(rhs.x),
193             y: self.y.min(rhs.y),
194             z: self.z.min(rhs.z),
195         }
196     }
197 
198     /// Returns a vector containing the maximum values for each element of `self` and `rhs`.
199     ///
200     /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`.
201     #[inline]
202     #[must_use]
max(self, rhs: Self) -> Self203     pub fn max(self, rhs: Self) -> Self {
204         Self {
205             x: self.x.max(rhs.x),
206             y: self.y.max(rhs.y),
207             z: self.z.max(rhs.z),
208         }
209     }
210 
211     /// Component-wise clamping of values, similar to [`i64::clamp`].
212     ///
213     /// Each element in `min` must be less-or-equal to the corresponding element in `max`.
214     ///
215     /// # Panics
216     ///
217     /// Will panic if `min` is greater than `max` when `glam_assert` is enabled.
218     #[inline]
219     #[must_use]
clamp(self, min: Self, max: Self) -> Self220     pub fn clamp(self, min: Self, max: Self) -> Self {
221         glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
222         self.max(min).min(max)
223     }
224 
225     /// Returns the horizontal minimum of `self`.
226     ///
227     /// In other words this computes `min(x, y, ..)`.
228     #[inline]
229     #[must_use]
min_element(self) -> i64230     pub fn min_element(self) -> i64 {
231         self.x.min(self.y.min(self.z))
232     }
233 
234     /// Returns the horizontal maximum of `self`.
235     ///
236     /// In other words this computes `max(x, y, ..)`.
237     #[inline]
238     #[must_use]
max_element(self) -> i64239     pub fn max_element(self) -> i64 {
240         self.x.max(self.y.max(self.z))
241     }
242 
243     /// Returns a vector mask containing the result of a `==` comparison for each element of
244     /// `self` and `rhs`.
245     ///
246     /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
247     /// elements.
248     #[inline]
249     #[must_use]
cmpeq(self, rhs: Self) -> BVec3250     pub fn cmpeq(self, rhs: Self) -> BVec3 {
251         BVec3::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y), self.z.eq(&rhs.z))
252     }
253 
254     /// Returns a vector mask containing the result of a `!=` comparison for each element of
255     /// `self` and `rhs`.
256     ///
257     /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
258     /// elements.
259     #[inline]
260     #[must_use]
cmpne(self, rhs: Self) -> BVec3261     pub fn cmpne(self, rhs: Self) -> BVec3 {
262         BVec3::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y), self.z.ne(&rhs.z))
263     }
264 
265     /// Returns a vector mask containing the result of a `>=` comparison for each element of
266     /// `self` and `rhs`.
267     ///
268     /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all
269     /// elements.
270     #[inline]
271     #[must_use]
cmpge(self, rhs: Self) -> BVec3272     pub fn cmpge(self, rhs: Self) -> BVec3 {
273         BVec3::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y), self.z.ge(&rhs.z))
274     }
275 
276     /// Returns a vector mask containing the result of a `>` comparison for each element of
277     /// `self` and `rhs`.
278     ///
279     /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
280     /// elements.
281     #[inline]
282     #[must_use]
cmpgt(self, rhs: Self) -> BVec3283     pub fn cmpgt(self, rhs: Self) -> BVec3 {
284         BVec3::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y), self.z.gt(&rhs.z))
285     }
286 
287     /// Returns a vector mask containing the result of a `<=` comparison for each element of
288     /// `self` and `rhs`.
289     ///
290     /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all
291     /// elements.
292     #[inline]
293     #[must_use]
cmple(self, rhs: Self) -> BVec3294     pub fn cmple(self, rhs: Self) -> BVec3 {
295         BVec3::new(self.x.le(&rhs.x), self.y.le(&rhs.y), self.z.le(&rhs.z))
296     }
297 
298     /// Returns a vector mask containing the result of a `<` comparison for each element of
299     /// `self` and `rhs`.
300     ///
301     /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all
302     /// elements.
303     #[inline]
304     #[must_use]
cmplt(self, rhs: Self) -> BVec3305     pub fn cmplt(self, rhs: Self) -> BVec3 {
306         BVec3::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y), self.z.lt(&rhs.z))
307     }
308 
309     /// Returns a vector containing the absolute value of each element of `self`.
310     #[inline]
311     #[must_use]
abs(self) -> Self312     pub fn abs(self) -> Self {
313         Self {
314             x: self.x.abs(),
315             y: self.y.abs(),
316             z: self.z.abs(),
317         }
318     }
319 
320     /// Returns a vector with elements representing the sign of `self`.
321     ///
322     ///  - `0` if the number is zero
323     ///  - `1` if the number is positive
324     ///  - `-1` if the number is negative
325     #[inline]
326     #[must_use]
signum(self) -> Self327     pub fn signum(self) -> Self {
328         Self {
329             x: self.x.signum(),
330             y: self.y.signum(),
331             z: self.z.signum(),
332         }
333     }
334 
335     /// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`.
336     ///
337     /// A negative element results in a `1` bit and a positive element in a `0` bit.  Element `x` goes
338     /// into the first lowest bit, element `y` into the second, etc.
339     #[inline]
340     #[must_use]
is_negative_bitmask(self) -> u32341     pub fn is_negative_bitmask(self) -> u32 {
342         (self.x.is_negative() as u32)
343             | (self.y.is_negative() as u32) << 1
344             | (self.z.is_negative() as u32) << 2
345     }
346 
347     /// Computes the squared length of `self`.
348     #[doc(alias = "magnitude2")]
349     #[inline]
350     #[must_use]
length_squared(self) -> i64351     pub fn length_squared(self) -> i64 {
352         self.dot(self)
353     }
354 
355     /// Compute the squared euclidean distance between two points in space.
356     #[inline]
357     #[must_use]
distance_squared(self, rhs: Self) -> i64358     pub fn distance_squared(self, rhs: Self) -> i64 {
359         (self - rhs).length_squared()
360     }
361 
362     /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
363     ///
364     /// # Panics
365     /// This function will panic if any `rhs` element is 0 or the division results in overflow.
366     #[inline]
367     #[must_use]
div_euclid(self, rhs: Self) -> Self368     pub fn div_euclid(self, rhs: Self) -> Self {
369         Self::new(
370             self.x.div_euclid(rhs.x),
371             self.y.div_euclid(rhs.y),
372             self.z.div_euclid(rhs.z),
373         )
374     }
375 
376     /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`.
377     ///
378     /// # Panics
379     /// This function will panic if any `rhs` element is 0 or the division results in overflow.
380     ///
381     /// [Euclidean division]: i64::rem_euclid
382     #[inline]
383     #[must_use]
rem_euclid(self, rhs: Self) -> Self384     pub fn rem_euclid(self, rhs: Self) -> Self {
385         Self::new(
386             self.x.rem_euclid(rhs.x),
387             self.y.rem_euclid(rhs.y),
388             self.z.rem_euclid(rhs.z),
389         )
390     }
391 
392     /// Casts all elements of `self` to `f32`.
393     #[inline]
394     #[must_use]
as_vec3(&self) -> crate::Vec3395     pub fn as_vec3(&self) -> crate::Vec3 {
396         crate::Vec3::new(self.x as f32, self.y as f32, self.z as f32)
397     }
398 
399     /// Casts all elements of `self` to `f32`.
400     #[inline]
401     #[must_use]
as_vec3a(&self) -> crate::Vec3A402     pub fn as_vec3a(&self) -> crate::Vec3A {
403         crate::Vec3A::new(self.x as f32, self.y as f32, self.z as f32)
404     }
405 
406     /// Casts all elements of `self` to `f64`.
407     #[inline]
408     #[must_use]
as_dvec3(&self) -> crate::DVec3409     pub fn as_dvec3(&self) -> crate::DVec3 {
410         crate::DVec3::new(self.x as f64, self.y as f64, self.z as f64)
411     }
412 
413     /// Casts all elements of `self` to `i16`.
414     #[inline]
415     #[must_use]
as_i16vec3(&self) -> crate::I16Vec3416     pub fn as_i16vec3(&self) -> crate::I16Vec3 {
417         crate::I16Vec3::new(self.x as i16, self.y as i16, self.z as i16)
418     }
419 
420     /// Casts all elements of `self` to `u16`.
421     #[inline]
422     #[must_use]
as_u16vec3(&self) -> crate::U16Vec3423     pub fn as_u16vec3(&self) -> crate::U16Vec3 {
424         crate::U16Vec3::new(self.x as u16, self.y as u16, self.z as u16)
425     }
426 
427     /// Casts all elements of `self` to `i32`.
428     #[inline]
429     #[must_use]
as_ivec3(&self) -> crate::IVec3430     pub fn as_ivec3(&self) -> crate::IVec3 {
431         crate::IVec3::new(self.x as i32, self.y as i32, self.z as i32)
432     }
433 
434     /// Casts all elements of `self` to `u32`.
435     #[inline]
436     #[must_use]
as_uvec3(&self) -> crate::UVec3437     pub fn as_uvec3(&self) -> crate::UVec3 {
438         crate::UVec3::new(self.x as u32, self.y as u32, self.z as u32)
439     }
440 
441     /// Casts all elements of `self` to `u64`.
442     #[inline]
443     #[must_use]
as_u64vec3(&self) -> crate::U64Vec3444     pub fn as_u64vec3(&self) -> crate::U64Vec3 {
445         crate::U64Vec3::new(self.x as u64, self.y as u64, self.z as u64)
446     }
447 
448     /// Returns a vector containing the wrapping addition of `self` and `rhs`.
449     ///
450     /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
451     #[inline]
452     #[must_use]
wrapping_add(self, rhs: Self) -> Self453     pub const fn wrapping_add(self, rhs: Self) -> Self {
454         Self {
455             x: self.x.wrapping_add(rhs.x),
456             y: self.y.wrapping_add(rhs.y),
457             z: self.z.wrapping_add(rhs.z),
458         }
459     }
460 
461     /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
462     ///
463     /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
464     #[inline]
465     #[must_use]
wrapping_sub(self, rhs: Self) -> Self466     pub const fn wrapping_sub(self, rhs: Self) -> Self {
467         Self {
468             x: self.x.wrapping_sub(rhs.x),
469             y: self.y.wrapping_sub(rhs.y),
470             z: self.z.wrapping_sub(rhs.z),
471         }
472     }
473 
474     /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
475     ///
476     /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
477     #[inline]
478     #[must_use]
wrapping_mul(self, rhs: Self) -> Self479     pub const fn wrapping_mul(self, rhs: Self) -> Self {
480         Self {
481             x: self.x.wrapping_mul(rhs.x),
482             y: self.y.wrapping_mul(rhs.y),
483             z: self.z.wrapping_mul(rhs.z),
484         }
485     }
486 
487     /// Returns a vector containing the wrapping division of `self` and `rhs`.
488     ///
489     /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
490     #[inline]
491     #[must_use]
wrapping_div(self, rhs: Self) -> Self492     pub const fn wrapping_div(self, rhs: Self) -> Self {
493         Self {
494             x: self.x.wrapping_div(rhs.x),
495             y: self.y.wrapping_div(rhs.y),
496             z: self.z.wrapping_div(rhs.z),
497         }
498     }
499 
500     /// Returns a vector containing the saturating addition of `self` and `rhs`.
501     ///
502     /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
503     #[inline]
504     #[must_use]
saturating_add(self, rhs: Self) -> Self505     pub const fn saturating_add(self, rhs: Self) -> Self {
506         Self {
507             x: self.x.saturating_add(rhs.x),
508             y: self.y.saturating_add(rhs.y),
509             z: self.z.saturating_add(rhs.z),
510         }
511     }
512 
513     /// Returns a vector containing the saturating subtraction of `self` and `rhs`.
514     ///
515     /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`.
516     #[inline]
517     #[must_use]
saturating_sub(self, rhs: Self) -> Self518     pub const fn saturating_sub(self, rhs: Self) -> Self {
519         Self {
520             x: self.x.saturating_sub(rhs.x),
521             y: self.y.saturating_sub(rhs.y),
522             z: self.z.saturating_sub(rhs.z),
523         }
524     }
525 
526     /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
527     ///
528     /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
529     #[inline]
530     #[must_use]
saturating_mul(self, rhs: Self) -> Self531     pub const fn saturating_mul(self, rhs: Self) -> Self {
532         Self {
533             x: self.x.saturating_mul(rhs.x),
534             y: self.y.saturating_mul(rhs.y),
535             z: self.z.saturating_mul(rhs.z),
536         }
537     }
538 
539     /// Returns a vector containing the saturating division of `self` and `rhs`.
540     ///
541     /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
542     #[inline]
543     #[must_use]
saturating_div(self, rhs: Self) -> Self544     pub const fn saturating_div(self, rhs: Self) -> Self {
545         Self {
546             x: self.x.saturating_div(rhs.x),
547             y: self.y.saturating_div(rhs.y),
548             z: self.z.saturating_div(rhs.z),
549         }
550     }
551 }
552 
553 impl Default for I64Vec3 {
554     #[inline(always)]
default() -> Self555     fn default() -> Self {
556         Self::ZERO
557     }
558 }
559 
560 impl Div<I64Vec3> for I64Vec3 {
561     type Output = Self;
562     #[inline]
div(self, rhs: Self) -> Self563     fn div(self, rhs: Self) -> Self {
564         Self {
565             x: self.x.div(rhs.x),
566             y: self.y.div(rhs.y),
567             z: self.z.div(rhs.z),
568         }
569     }
570 }
571 
572 impl DivAssign<I64Vec3> for I64Vec3 {
573     #[inline]
div_assign(&mut self, rhs: Self)574     fn div_assign(&mut self, rhs: Self) {
575         self.x.div_assign(rhs.x);
576         self.y.div_assign(rhs.y);
577         self.z.div_assign(rhs.z);
578     }
579 }
580 
581 impl Div<i64> for I64Vec3 {
582     type Output = Self;
583     #[inline]
div(self, rhs: i64) -> Self584     fn div(self, rhs: i64) -> Self {
585         Self {
586             x: self.x.div(rhs),
587             y: self.y.div(rhs),
588             z: self.z.div(rhs),
589         }
590     }
591 }
592 
593 impl DivAssign<i64> for I64Vec3 {
594     #[inline]
div_assign(&mut self, rhs: i64)595     fn div_assign(&mut self, rhs: i64) {
596         self.x.div_assign(rhs);
597         self.y.div_assign(rhs);
598         self.z.div_assign(rhs);
599     }
600 }
601 
602 impl Div<I64Vec3> for i64 {
603     type Output = I64Vec3;
604     #[inline]
div(self, rhs: I64Vec3) -> I64Vec3605     fn div(self, rhs: I64Vec3) -> I64Vec3 {
606         I64Vec3 {
607             x: self.div(rhs.x),
608             y: self.div(rhs.y),
609             z: self.div(rhs.z),
610         }
611     }
612 }
613 
614 impl Mul<I64Vec3> for I64Vec3 {
615     type Output = Self;
616     #[inline]
mul(self, rhs: Self) -> Self617     fn mul(self, rhs: Self) -> Self {
618         Self {
619             x: self.x.mul(rhs.x),
620             y: self.y.mul(rhs.y),
621             z: self.z.mul(rhs.z),
622         }
623     }
624 }
625 
626 impl MulAssign<I64Vec3> for I64Vec3 {
627     #[inline]
mul_assign(&mut self, rhs: Self)628     fn mul_assign(&mut self, rhs: Self) {
629         self.x.mul_assign(rhs.x);
630         self.y.mul_assign(rhs.y);
631         self.z.mul_assign(rhs.z);
632     }
633 }
634 
635 impl Mul<i64> for I64Vec3 {
636     type Output = Self;
637     #[inline]
mul(self, rhs: i64) -> Self638     fn mul(self, rhs: i64) -> Self {
639         Self {
640             x: self.x.mul(rhs),
641             y: self.y.mul(rhs),
642             z: self.z.mul(rhs),
643         }
644     }
645 }
646 
647 impl MulAssign<i64> for I64Vec3 {
648     #[inline]
mul_assign(&mut self, rhs: i64)649     fn mul_assign(&mut self, rhs: i64) {
650         self.x.mul_assign(rhs);
651         self.y.mul_assign(rhs);
652         self.z.mul_assign(rhs);
653     }
654 }
655 
656 impl Mul<I64Vec3> for i64 {
657     type Output = I64Vec3;
658     #[inline]
mul(self, rhs: I64Vec3) -> I64Vec3659     fn mul(self, rhs: I64Vec3) -> I64Vec3 {
660         I64Vec3 {
661             x: self.mul(rhs.x),
662             y: self.mul(rhs.y),
663             z: self.mul(rhs.z),
664         }
665     }
666 }
667 
668 impl Add<I64Vec3> for I64Vec3 {
669     type Output = Self;
670     #[inline]
add(self, rhs: Self) -> Self671     fn add(self, rhs: Self) -> Self {
672         Self {
673             x: self.x.add(rhs.x),
674             y: self.y.add(rhs.y),
675             z: self.z.add(rhs.z),
676         }
677     }
678 }
679 
680 impl AddAssign<I64Vec3> for I64Vec3 {
681     #[inline]
add_assign(&mut self, rhs: Self)682     fn add_assign(&mut self, rhs: Self) {
683         self.x.add_assign(rhs.x);
684         self.y.add_assign(rhs.y);
685         self.z.add_assign(rhs.z);
686     }
687 }
688 
689 impl Add<i64> for I64Vec3 {
690     type Output = Self;
691     #[inline]
add(self, rhs: i64) -> Self692     fn add(self, rhs: i64) -> Self {
693         Self {
694             x: self.x.add(rhs),
695             y: self.y.add(rhs),
696             z: self.z.add(rhs),
697         }
698     }
699 }
700 
701 impl AddAssign<i64> for I64Vec3 {
702     #[inline]
add_assign(&mut self, rhs: i64)703     fn add_assign(&mut self, rhs: i64) {
704         self.x.add_assign(rhs);
705         self.y.add_assign(rhs);
706         self.z.add_assign(rhs);
707     }
708 }
709 
710 impl Add<I64Vec3> for i64 {
711     type Output = I64Vec3;
712     #[inline]
add(self, rhs: I64Vec3) -> I64Vec3713     fn add(self, rhs: I64Vec3) -> I64Vec3 {
714         I64Vec3 {
715             x: self.add(rhs.x),
716             y: self.add(rhs.y),
717             z: self.add(rhs.z),
718         }
719     }
720 }
721 
722 impl Sub<I64Vec3> for I64Vec3 {
723     type Output = Self;
724     #[inline]
sub(self, rhs: Self) -> Self725     fn sub(self, rhs: Self) -> Self {
726         Self {
727             x: self.x.sub(rhs.x),
728             y: self.y.sub(rhs.y),
729             z: self.z.sub(rhs.z),
730         }
731     }
732 }
733 
734 impl SubAssign<I64Vec3> for I64Vec3 {
735     #[inline]
sub_assign(&mut self, rhs: I64Vec3)736     fn sub_assign(&mut self, rhs: I64Vec3) {
737         self.x.sub_assign(rhs.x);
738         self.y.sub_assign(rhs.y);
739         self.z.sub_assign(rhs.z);
740     }
741 }
742 
743 impl Sub<i64> for I64Vec3 {
744     type Output = Self;
745     #[inline]
sub(self, rhs: i64) -> Self746     fn sub(self, rhs: i64) -> Self {
747         Self {
748             x: self.x.sub(rhs),
749             y: self.y.sub(rhs),
750             z: self.z.sub(rhs),
751         }
752     }
753 }
754 
755 impl SubAssign<i64> for I64Vec3 {
756     #[inline]
sub_assign(&mut self, rhs: i64)757     fn sub_assign(&mut self, rhs: i64) {
758         self.x.sub_assign(rhs);
759         self.y.sub_assign(rhs);
760         self.z.sub_assign(rhs);
761     }
762 }
763 
764 impl Sub<I64Vec3> for i64 {
765     type Output = I64Vec3;
766     #[inline]
sub(self, rhs: I64Vec3) -> I64Vec3767     fn sub(self, rhs: I64Vec3) -> I64Vec3 {
768         I64Vec3 {
769             x: self.sub(rhs.x),
770             y: self.sub(rhs.y),
771             z: self.sub(rhs.z),
772         }
773     }
774 }
775 
776 impl Rem<I64Vec3> for I64Vec3 {
777     type Output = Self;
778     #[inline]
rem(self, rhs: Self) -> Self779     fn rem(self, rhs: Self) -> Self {
780         Self {
781             x: self.x.rem(rhs.x),
782             y: self.y.rem(rhs.y),
783             z: self.z.rem(rhs.z),
784         }
785     }
786 }
787 
788 impl RemAssign<I64Vec3> for I64Vec3 {
789     #[inline]
rem_assign(&mut self, rhs: Self)790     fn rem_assign(&mut self, rhs: Self) {
791         self.x.rem_assign(rhs.x);
792         self.y.rem_assign(rhs.y);
793         self.z.rem_assign(rhs.z);
794     }
795 }
796 
797 impl Rem<i64> for I64Vec3 {
798     type Output = Self;
799     #[inline]
rem(self, rhs: i64) -> Self800     fn rem(self, rhs: i64) -> Self {
801         Self {
802             x: self.x.rem(rhs),
803             y: self.y.rem(rhs),
804             z: self.z.rem(rhs),
805         }
806     }
807 }
808 
809 impl RemAssign<i64> for I64Vec3 {
810     #[inline]
rem_assign(&mut self, rhs: i64)811     fn rem_assign(&mut self, rhs: i64) {
812         self.x.rem_assign(rhs);
813         self.y.rem_assign(rhs);
814         self.z.rem_assign(rhs);
815     }
816 }
817 
818 impl Rem<I64Vec3> for i64 {
819     type Output = I64Vec3;
820     #[inline]
rem(self, rhs: I64Vec3) -> I64Vec3821     fn rem(self, rhs: I64Vec3) -> I64Vec3 {
822         I64Vec3 {
823             x: self.rem(rhs.x),
824             y: self.rem(rhs.y),
825             z: self.rem(rhs.z),
826         }
827     }
828 }
829 
830 #[cfg(not(target_arch = "spirv"))]
831 impl AsRef<[i64; 3]> for I64Vec3 {
832     #[inline]
as_ref(&self) -> &[i64; 3]833     fn as_ref(&self) -> &[i64; 3] {
834         unsafe { &*(self as *const I64Vec3 as *const [i64; 3]) }
835     }
836 }
837 
838 #[cfg(not(target_arch = "spirv"))]
839 impl AsMut<[i64; 3]> for I64Vec3 {
840     #[inline]
as_mut(&mut self) -> &mut [i64; 3]841     fn as_mut(&mut self) -> &mut [i64; 3] {
842         unsafe { &mut *(self as *mut I64Vec3 as *mut [i64; 3]) }
843     }
844 }
845 
846 impl Sum for I64Vec3 {
847     #[inline]
sum<I>(iter: I) -> Self where I: Iterator<Item = Self>,848     fn sum<I>(iter: I) -> Self
849     where
850         I: Iterator<Item = Self>,
851     {
852         iter.fold(Self::ZERO, Self::add)
853     }
854 }
855 
856 impl<'a> Sum<&'a Self> for I64Vec3 {
857     #[inline]
sum<I>(iter: I) -> Self where I: Iterator<Item = &'a Self>,858     fn sum<I>(iter: I) -> Self
859     where
860         I: Iterator<Item = &'a Self>,
861     {
862         iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
863     }
864 }
865 
866 impl Product for I64Vec3 {
867     #[inline]
product<I>(iter: I) -> Self where I: Iterator<Item = Self>,868     fn product<I>(iter: I) -> Self
869     where
870         I: Iterator<Item = Self>,
871     {
872         iter.fold(Self::ONE, Self::mul)
873     }
874 }
875 
876 impl<'a> Product<&'a Self> for I64Vec3 {
877     #[inline]
product<I>(iter: I) -> Self where I: Iterator<Item = &'a Self>,878     fn product<I>(iter: I) -> Self
879     where
880         I: Iterator<Item = &'a Self>,
881     {
882         iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
883     }
884 }
885 
886 impl Neg for I64Vec3 {
887     type Output = Self;
888     #[inline]
neg(self) -> Self889     fn neg(self) -> Self {
890         Self {
891             x: self.x.neg(),
892             y: self.y.neg(),
893             z: self.z.neg(),
894         }
895     }
896 }
897 
898 impl Not for I64Vec3 {
899     type Output = Self;
900     #[inline]
not(self) -> Self::Output901     fn not(self) -> Self::Output {
902         Self {
903             x: self.x.not(),
904             y: self.y.not(),
905             z: self.z.not(),
906         }
907     }
908 }
909 
910 impl BitAnd for I64Vec3 {
911     type Output = Self;
912     #[inline]
bitand(self, rhs: Self) -> Self::Output913     fn bitand(self, rhs: Self) -> Self::Output {
914         Self {
915             x: self.x.bitand(rhs.x),
916             y: self.y.bitand(rhs.y),
917             z: self.z.bitand(rhs.z),
918         }
919     }
920 }
921 
922 impl BitOr for I64Vec3 {
923     type Output = Self;
924     #[inline]
bitor(self, rhs: Self) -> Self::Output925     fn bitor(self, rhs: Self) -> Self::Output {
926         Self {
927             x: self.x.bitor(rhs.x),
928             y: self.y.bitor(rhs.y),
929             z: self.z.bitor(rhs.z),
930         }
931     }
932 }
933 
934 impl BitXor for I64Vec3 {
935     type Output = Self;
936     #[inline]
bitxor(self, rhs: Self) -> Self::Output937     fn bitxor(self, rhs: Self) -> Self::Output {
938         Self {
939             x: self.x.bitxor(rhs.x),
940             y: self.y.bitxor(rhs.y),
941             z: self.z.bitxor(rhs.z),
942         }
943     }
944 }
945 
946 impl BitAnd<i64> for I64Vec3 {
947     type Output = Self;
948     #[inline]
bitand(self, rhs: i64) -> Self::Output949     fn bitand(self, rhs: i64) -> Self::Output {
950         Self {
951             x: self.x.bitand(rhs),
952             y: self.y.bitand(rhs),
953             z: self.z.bitand(rhs),
954         }
955     }
956 }
957 
958 impl BitOr<i64> for I64Vec3 {
959     type Output = Self;
960     #[inline]
bitor(self, rhs: i64) -> Self::Output961     fn bitor(self, rhs: i64) -> Self::Output {
962         Self {
963             x: self.x.bitor(rhs),
964             y: self.y.bitor(rhs),
965             z: self.z.bitor(rhs),
966         }
967     }
968 }
969 
970 impl BitXor<i64> for I64Vec3 {
971     type Output = Self;
972     #[inline]
bitxor(self, rhs: i64) -> Self::Output973     fn bitxor(self, rhs: i64) -> Self::Output {
974         Self {
975             x: self.x.bitxor(rhs),
976             y: self.y.bitxor(rhs),
977             z: self.z.bitxor(rhs),
978         }
979     }
980 }
981 
982 impl Shl<i8> for I64Vec3 {
983     type Output = Self;
984     #[inline]
shl(self, rhs: i8) -> Self::Output985     fn shl(self, rhs: i8) -> Self::Output {
986         Self {
987             x: self.x.shl(rhs),
988             y: self.y.shl(rhs),
989             z: self.z.shl(rhs),
990         }
991     }
992 }
993 
994 impl Shr<i8> for I64Vec3 {
995     type Output = Self;
996     #[inline]
shr(self, rhs: i8) -> Self::Output997     fn shr(self, rhs: i8) -> Self::Output {
998         Self {
999             x: self.x.shr(rhs),
1000             y: self.y.shr(rhs),
1001             z: self.z.shr(rhs),
1002         }
1003     }
1004 }
1005 
1006 impl Shl<i16> for I64Vec3 {
1007     type Output = Self;
1008     #[inline]
shl(self, rhs: i16) -> Self::Output1009     fn shl(self, rhs: i16) -> Self::Output {
1010         Self {
1011             x: self.x.shl(rhs),
1012             y: self.y.shl(rhs),
1013             z: self.z.shl(rhs),
1014         }
1015     }
1016 }
1017 
1018 impl Shr<i16> for I64Vec3 {
1019     type Output = Self;
1020     #[inline]
shr(self, rhs: i16) -> Self::Output1021     fn shr(self, rhs: i16) -> Self::Output {
1022         Self {
1023             x: self.x.shr(rhs),
1024             y: self.y.shr(rhs),
1025             z: self.z.shr(rhs),
1026         }
1027     }
1028 }
1029 
1030 impl Shl<i32> for I64Vec3 {
1031     type Output = Self;
1032     #[inline]
shl(self, rhs: i32) -> Self::Output1033     fn shl(self, rhs: i32) -> Self::Output {
1034         Self {
1035             x: self.x.shl(rhs),
1036             y: self.y.shl(rhs),
1037             z: self.z.shl(rhs),
1038         }
1039     }
1040 }
1041 
1042 impl Shr<i32> for I64Vec3 {
1043     type Output = Self;
1044     #[inline]
shr(self, rhs: i32) -> Self::Output1045     fn shr(self, rhs: i32) -> Self::Output {
1046         Self {
1047             x: self.x.shr(rhs),
1048             y: self.y.shr(rhs),
1049             z: self.z.shr(rhs),
1050         }
1051     }
1052 }
1053 
1054 impl Shl<i64> for I64Vec3 {
1055     type Output = Self;
1056     #[inline]
shl(self, rhs: i64) -> Self::Output1057     fn shl(self, rhs: i64) -> Self::Output {
1058         Self {
1059             x: self.x.shl(rhs),
1060             y: self.y.shl(rhs),
1061             z: self.z.shl(rhs),
1062         }
1063     }
1064 }
1065 
1066 impl Shr<i64> for I64Vec3 {
1067     type Output = Self;
1068     #[inline]
shr(self, rhs: i64) -> Self::Output1069     fn shr(self, rhs: i64) -> Self::Output {
1070         Self {
1071             x: self.x.shr(rhs),
1072             y: self.y.shr(rhs),
1073             z: self.z.shr(rhs),
1074         }
1075     }
1076 }
1077 
1078 impl Shl<u8> for I64Vec3 {
1079     type Output = Self;
1080     #[inline]
shl(self, rhs: u8) -> Self::Output1081     fn shl(self, rhs: u8) -> Self::Output {
1082         Self {
1083             x: self.x.shl(rhs),
1084             y: self.y.shl(rhs),
1085             z: self.z.shl(rhs),
1086         }
1087     }
1088 }
1089 
1090 impl Shr<u8> for I64Vec3 {
1091     type Output = Self;
1092     #[inline]
shr(self, rhs: u8) -> Self::Output1093     fn shr(self, rhs: u8) -> Self::Output {
1094         Self {
1095             x: self.x.shr(rhs),
1096             y: self.y.shr(rhs),
1097             z: self.z.shr(rhs),
1098         }
1099     }
1100 }
1101 
1102 impl Shl<u16> for I64Vec3 {
1103     type Output = Self;
1104     #[inline]
shl(self, rhs: u16) -> Self::Output1105     fn shl(self, rhs: u16) -> Self::Output {
1106         Self {
1107             x: self.x.shl(rhs),
1108             y: self.y.shl(rhs),
1109             z: self.z.shl(rhs),
1110         }
1111     }
1112 }
1113 
1114 impl Shr<u16> for I64Vec3 {
1115     type Output = Self;
1116     #[inline]
shr(self, rhs: u16) -> Self::Output1117     fn shr(self, rhs: u16) -> Self::Output {
1118         Self {
1119             x: self.x.shr(rhs),
1120             y: self.y.shr(rhs),
1121             z: self.z.shr(rhs),
1122         }
1123     }
1124 }
1125 
1126 impl Shl<u32> for I64Vec3 {
1127     type Output = Self;
1128     #[inline]
shl(self, rhs: u32) -> Self::Output1129     fn shl(self, rhs: u32) -> Self::Output {
1130         Self {
1131             x: self.x.shl(rhs),
1132             y: self.y.shl(rhs),
1133             z: self.z.shl(rhs),
1134         }
1135     }
1136 }
1137 
1138 impl Shr<u32> for I64Vec3 {
1139     type Output = Self;
1140     #[inline]
shr(self, rhs: u32) -> Self::Output1141     fn shr(self, rhs: u32) -> Self::Output {
1142         Self {
1143             x: self.x.shr(rhs),
1144             y: self.y.shr(rhs),
1145             z: self.z.shr(rhs),
1146         }
1147     }
1148 }
1149 
1150 impl Shl<u64> for I64Vec3 {
1151     type Output = Self;
1152     #[inline]
shl(self, rhs: u64) -> Self::Output1153     fn shl(self, rhs: u64) -> Self::Output {
1154         Self {
1155             x: self.x.shl(rhs),
1156             y: self.y.shl(rhs),
1157             z: self.z.shl(rhs),
1158         }
1159     }
1160 }
1161 
1162 impl Shr<u64> for I64Vec3 {
1163     type Output = Self;
1164     #[inline]
shr(self, rhs: u64) -> Self::Output1165     fn shr(self, rhs: u64) -> Self::Output {
1166         Self {
1167             x: self.x.shr(rhs),
1168             y: self.y.shr(rhs),
1169             z: self.z.shr(rhs),
1170         }
1171     }
1172 }
1173 
1174 impl Shl<crate::IVec3> for I64Vec3 {
1175     type Output = Self;
1176     #[inline]
shl(self, rhs: crate::IVec3) -> Self::Output1177     fn shl(self, rhs: crate::IVec3) -> Self::Output {
1178         Self {
1179             x: self.x.shl(rhs.x),
1180             y: self.y.shl(rhs.y),
1181             z: self.z.shl(rhs.z),
1182         }
1183     }
1184 }
1185 
1186 impl Shr<crate::IVec3> for I64Vec3 {
1187     type Output = Self;
1188     #[inline]
shr(self, rhs: crate::IVec3) -> Self::Output1189     fn shr(self, rhs: crate::IVec3) -> Self::Output {
1190         Self {
1191             x: self.x.shr(rhs.x),
1192             y: self.y.shr(rhs.y),
1193             z: self.z.shr(rhs.z),
1194         }
1195     }
1196 }
1197 
1198 impl Shl<crate::UVec3> for I64Vec3 {
1199     type Output = Self;
1200     #[inline]
shl(self, rhs: crate::UVec3) -> Self::Output1201     fn shl(self, rhs: crate::UVec3) -> Self::Output {
1202         Self {
1203             x: self.x.shl(rhs.x),
1204             y: self.y.shl(rhs.y),
1205             z: self.z.shl(rhs.z),
1206         }
1207     }
1208 }
1209 
1210 impl Shr<crate::UVec3> for I64Vec3 {
1211     type Output = Self;
1212     #[inline]
shr(self, rhs: crate::UVec3) -> Self::Output1213     fn shr(self, rhs: crate::UVec3) -> Self::Output {
1214         Self {
1215             x: self.x.shr(rhs.x),
1216             y: self.y.shr(rhs.y),
1217             z: self.z.shr(rhs.z),
1218         }
1219     }
1220 }
1221 
1222 impl Index<usize> for I64Vec3 {
1223     type Output = i64;
1224     #[inline]
index(&self, index: usize) -> &Self::Output1225     fn index(&self, index: usize) -> &Self::Output {
1226         match index {
1227             0 => &self.x,
1228             1 => &self.y,
1229             2 => &self.z,
1230             _ => panic!("index out of bounds"),
1231         }
1232     }
1233 }
1234 
1235 impl IndexMut<usize> for I64Vec3 {
1236     #[inline]
index_mut(&mut self, index: usize) -> &mut Self::Output1237     fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1238         match index {
1239             0 => &mut self.x,
1240             1 => &mut self.y,
1241             2 => &mut self.z,
1242             _ => panic!("index out of bounds"),
1243         }
1244     }
1245 }
1246 
1247 #[cfg(not(target_arch = "spirv"))]
1248 impl fmt::Display for I64Vec3 {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result1249     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1250         write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
1251     }
1252 }
1253 
1254 #[cfg(not(target_arch = "spirv"))]
1255 impl fmt::Debug for I64Vec3 {
fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result1256     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1257         fmt.debug_tuple(stringify!(I64Vec3))
1258             .field(&self.x)
1259             .field(&self.y)
1260             .field(&self.z)
1261             .finish()
1262     }
1263 }
1264 
1265 impl From<[i64; 3]> for I64Vec3 {
1266     #[inline]
from(a: [i64; 3]) -> Self1267     fn from(a: [i64; 3]) -> Self {
1268         Self::new(a[0], a[1], a[2])
1269     }
1270 }
1271 
1272 impl From<I64Vec3> for [i64; 3] {
1273     #[inline]
from(v: I64Vec3) -> Self1274     fn from(v: I64Vec3) -> Self {
1275         [v.x, v.y, v.z]
1276     }
1277 }
1278 
1279 impl From<(i64, i64, i64)> for I64Vec3 {
1280     #[inline]
from(t: (i64, i64, i64)) -> Self1281     fn from(t: (i64, i64, i64)) -> Self {
1282         Self::new(t.0, t.1, t.2)
1283     }
1284 }
1285 
1286 impl From<I64Vec3> for (i64, i64, i64) {
1287     #[inline]
from(v: I64Vec3) -> Self1288     fn from(v: I64Vec3) -> Self {
1289         (v.x, v.y, v.z)
1290     }
1291 }
1292 
1293 impl From<(I64Vec2, i64)> for I64Vec3 {
1294     #[inline]
from((v, z): (I64Vec2, i64)) -> Self1295     fn from((v, z): (I64Vec2, i64)) -> Self {
1296         Self::new(v.x, v.y, z)
1297     }
1298 }
1299 
1300 impl From<I16Vec3> for I64Vec3 {
1301     #[inline]
from(v: I16Vec3) -> Self1302     fn from(v: I16Vec3) -> Self {
1303         Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
1304     }
1305 }
1306 
1307 impl From<U16Vec3> for I64Vec3 {
1308     #[inline]
from(v: U16Vec3) -> Self1309     fn from(v: U16Vec3) -> Self {
1310         Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
1311     }
1312 }
1313 
1314 impl From<IVec3> for I64Vec3 {
1315     #[inline]
from(v: IVec3) -> Self1316     fn from(v: IVec3) -> Self {
1317         Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
1318     }
1319 }
1320 
1321 impl From<UVec3> for I64Vec3 {
1322     #[inline]
from(v: UVec3) -> Self1323     fn from(v: UVec3) -> Self {
1324         Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
1325     }
1326 }
1327 
1328 impl TryFrom<U64Vec3> for I64Vec3 {
1329     type Error = core::num::TryFromIntError;
1330 
1331     #[inline]
try_from(v: U64Vec3) -> Result<Self, Self::Error>1332     fn try_from(v: U64Vec3) -> Result<Self, Self::Error> {
1333         Ok(Self::new(
1334             i64::try_from(v.x)?,
1335             i64::try_from(v.y)?,
1336             i64::try_from(v.z)?,
1337         ))
1338     }
1339 }
1340