glam/i64/
i64vec3.rs

1// Generated from vec.rs.tera template. Edit the template, not the generated file.
2
3use crate::{
4    BVec3, BVec3A, I16Vec3, I64Vec2, I64Vec4, I8Vec3, IVec3, U16Vec3, U64Vec3, U8Vec3, USizeVec3,
5    UVec3,
6};
7
8use core::fmt;
9use core::iter::{Product, Sum};
10use core::{f32, ops::*};
11
12/// Creates a 3-dimensional vector.
13#[inline(always)]
14#[must_use]
15pub const fn i64vec3(x: i64, y: i64, z: i64) -> I64Vec3 {
16    I64Vec3::new(x, y, z)
17}
18
19/// A 3-dimensional vector.
20#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
21#[derive(Clone, Copy, PartialEq, Eq)]
22#[cfg_attr(not(target_arch = "spirv"), repr(C))]
23#[cfg_attr(target_arch = "spirv", repr(simd))]
24pub struct I64Vec3 {
25    pub x: i64,
26    pub y: i64,
27    pub z: i64,
28}
29
30impl I64Vec3 {
31    /// All zeroes.
32    pub const ZERO: Self = Self::splat(0);
33
34    /// All ones.
35    pub const ONE: Self = Self::splat(1);
36
37    /// All negative ones.
38    pub const NEG_ONE: Self = Self::splat(-1);
39
40    /// All `i64::MIN`.
41    pub const MIN: Self = Self::splat(i64::MIN);
42
43    /// All `i64::MAX`.
44    pub const MAX: Self = Self::splat(i64::MAX);
45
46    /// A unit vector pointing along the positive X axis.
47    pub const X: Self = Self::new(1, 0, 0);
48
49    /// A unit vector pointing along the positive Y axis.
50    pub const Y: Self = Self::new(0, 1, 0);
51
52    /// A unit vector pointing along the positive Z axis.
53    pub const Z: Self = Self::new(0, 0, 1);
54
55    /// A unit vector pointing along the negative X axis.
56    pub const NEG_X: Self = Self::new(-1, 0, 0);
57
58    /// A unit vector pointing along the negative Y axis.
59    pub const NEG_Y: Self = Self::new(0, -1, 0);
60
61    /// A unit vector pointing along the negative Z axis.
62    pub const NEG_Z: Self = Self::new(0, 0, -1);
63
64    /// The unit axes.
65    pub const AXES: [Self; 3] = [Self::X, Self::Y, Self::Z];
66
67    /// Creates a new vector.
68    #[inline(always)]
69    #[must_use]
70    pub const fn new(x: i64, y: i64, z: i64) -> Self {
71        Self { x, y, z }
72    }
73
74    /// Creates a vector with all elements set to `v`.
75    #[inline]
76    #[must_use]
77    pub const fn splat(v: i64) -> Self {
78        Self { x: v, y: v, z: v }
79    }
80
81    /// Returns a vector containing each element of `self` modified by a mapping function `f`.
82    #[inline]
83    #[must_use]
84    pub fn map<F>(self, f: F) -> Self
85    where
86        F: Fn(i64) -> i64,
87    {
88        Self::new(f(self.x), f(self.y), f(self.z))
89    }
90
91    /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use
92    /// for each element of `self`.
93    ///
94    /// A true element in the mask uses the corresponding element from `if_true`, and false
95    /// uses the element from `if_false`.
96    #[inline]
97    #[must_use]
98    pub fn select(mask: BVec3, if_true: Self, if_false: Self) -> Self {
99        Self {
100            x: if mask.test(0) { if_true.x } else { if_false.x },
101            y: if mask.test(1) { if_true.y } else { if_false.y },
102            z: if mask.test(2) { if_true.z } else { if_false.z },
103        }
104    }
105
106    /// Creates a new vector from an array.
107    #[inline]
108    #[must_use]
109    pub const fn from_array(a: [i64; 3]) -> Self {
110        Self::new(a[0], a[1], a[2])
111    }
112
113    /// `[x, y, z]`
114    #[inline]
115    #[must_use]
116    pub const fn to_array(&self) -> [i64; 3] {
117        [self.x, self.y, self.z]
118    }
119
120    /// Creates a vector from the first 3 values in `slice`.
121    ///
122    /// # Panics
123    ///
124    /// Panics if `slice` is less than 3 elements long.
125    #[inline]
126    #[must_use]
127    pub const fn from_slice(slice: &[i64]) -> Self {
128        assert!(slice.len() >= 3);
129        Self::new(slice[0], slice[1], slice[2])
130    }
131
132    /// Writes the elements of `self` to the first 3 elements in `slice`.
133    ///
134    /// # Panics
135    ///
136    /// Panics if `slice` is less than 3 elements long.
137    #[inline]
138    pub fn write_to_slice(self, slice: &mut [i64]) {
139        slice[..3].copy_from_slice(&self.to_array());
140    }
141
142    /// Internal method for creating a 3D vector from a 4D vector, discarding `w`.
143    #[allow(dead_code)]
144    #[inline]
145    #[must_use]
146    pub(crate) fn from_vec4(v: I64Vec4) -> Self {
147        Self {
148            x: v.x,
149            y: v.y,
150            z: v.z,
151        }
152    }
153
154    /// Creates a 4D vector from `self` and the given `w` value.
155    #[inline]
156    #[must_use]
157    pub fn extend(self, w: i64) -> I64Vec4 {
158        I64Vec4::new(self.x, self.y, self.z, w)
159    }
160
161    /// Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`.
162    ///
163    /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()].
164    #[inline]
165    #[must_use]
166    pub fn truncate(self) -> I64Vec2 {
167        use crate::swizzles::Vec3Swizzles;
168        self.xy()
169    }
170
171    /// Creates a 3D vector from `self` with the given value of `x`.
172    #[inline]
173    #[must_use]
174    pub fn with_x(mut self, x: i64) -> Self {
175        self.x = x;
176        self
177    }
178
179    /// Creates a 3D vector from `self` with the given value of `y`.
180    #[inline]
181    #[must_use]
182    pub fn with_y(mut self, y: i64) -> Self {
183        self.y = y;
184        self
185    }
186
187    /// Creates a 3D vector from `self` with the given value of `z`.
188    #[inline]
189    #[must_use]
190    pub fn with_z(mut self, z: i64) -> Self {
191        self.z = z;
192        self
193    }
194
195    /// Computes the dot product of `self` and `rhs`.
196    #[inline]
197    #[must_use]
198    pub fn dot(self, rhs: Self) -> i64 {
199        (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z)
200    }
201
202    /// Returns a vector where every component is the dot product of `self` and `rhs`.
203    #[inline]
204    #[must_use]
205    pub fn dot_into_vec(self, rhs: Self) -> Self {
206        Self::splat(self.dot(rhs))
207    }
208
209    /// Computes the cross product of `self` and `rhs`.
210    #[inline]
211    #[must_use]
212    pub fn cross(self, rhs: Self) -> Self {
213        Self {
214            x: self.y * rhs.z - rhs.y * self.z,
215            y: self.z * rhs.x - rhs.z * self.x,
216            z: self.x * rhs.y - rhs.x * self.y,
217        }
218    }
219
220    /// Returns a vector containing the minimum values for each element of `self` and `rhs`.
221    ///
222    /// In other words this computes `[min(x, rhs.x), min(self.y, rhs.y), ..]`.
223    #[inline]
224    #[must_use]
225    pub fn min(self, rhs: Self) -> Self {
226        Self {
227            x: if self.x < rhs.x { self.x } else { rhs.x },
228            y: if self.y < rhs.y { self.y } else { rhs.y },
229            z: if self.z < rhs.z { self.z } else { rhs.z },
230        }
231    }
232
233    /// Returns a vector containing the maximum values for each element of `self` and `rhs`.
234    ///
235    /// In other words this computes `[max(self.x, rhs.x), max(self.y, rhs.y), ..]`.
236    #[inline]
237    #[must_use]
238    pub fn max(self, rhs: Self) -> Self {
239        Self {
240            x: if self.x > rhs.x { self.x } else { rhs.x },
241            y: if self.y > rhs.y { self.y } else { rhs.y },
242            z: if self.z > rhs.z { self.z } else { rhs.z },
243        }
244    }
245
246    /// Component-wise clamping of values, similar to [`i64::clamp`].
247    ///
248    /// Each element in `min` must be less-or-equal to the corresponding element in `max`.
249    ///
250    /// # Panics
251    ///
252    /// Will panic if `min` is greater than `max` when `glam_assert` is enabled.
253    #[inline]
254    #[must_use]
255    pub fn clamp(self, min: Self, max: Self) -> Self {
256        glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
257        self.max(min).min(max)
258    }
259
260    /// Returns the horizontal minimum of `self`.
261    ///
262    /// In other words this computes `min(x, y, ..)`.
263    #[inline]
264    #[must_use]
265    pub fn min_element(self) -> i64 {
266        let min = |a, b| if a < b { a } else { b };
267        min(self.x, min(self.y, self.z))
268    }
269
270    /// Returns the horizontal maximum of `self`.
271    ///
272    /// In other words this computes `max(x, y, ..)`.
273    #[inline]
274    #[must_use]
275    pub fn max_element(self) -> i64 {
276        let max = |a, b| if a > b { a } else { b };
277        max(self.x, max(self.y, self.z))
278    }
279
280    /// Returns the index of the first minimum element of `self`.
281    #[doc(alias = "argmin")]
282    #[inline]
283    #[must_use]
284    pub fn min_position(self) -> usize {
285        let mut min = self.x;
286        let mut index = 0;
287        if self.y < min {
288            min = self.y;
289            index = 1;
290        }
291        if self.z < min {
292            index = 2;
293        }
294        index
295    }
296
297    /// Returns the index of the first maximum element of `self`.
298    #[doc(alias = "argmax")]
299    #[inline]
300    #[must_use]
301    pub fn max_position(self) -> usize {
302        let mut max = self.x;
303        let mut index = 0;
304        if self.y > max {
305            max = self.y;
306            index = 1;
307        }
308        if self.z > max {
309            index = 2;
310        }
311        index
312    }
313
314    /// Returns the sum of all elements of `self`.
315    ///
316    /// In other words, this computes `self.x + self.y + ..`.
317    #[inline]
318    #[must_use]
319    pub fn element_sum(self) -> i64 {
320        self.x + self.y + self.z
321    }
322
323    /// Returns the product of all elements of `self`.
324    ///
325    /// In other words, this computes `self.x * self.y * ..`.
326    #[inline]
327    #[must_use]
328    pub fn element_product(self) -> i64 {
329        self.x * self.y * self.z
330    }
331
332    /// Returns a vector mask containing the result of a `==` comparison for each element of
333    /// `self` and `rhs`.
334    ///
335    /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
336    /// elements.
337    #[inline]
338    #[must_use]
339    pub fn cmpeq(self, rhs: Self) -> BVec3 {
340        BVec3::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y), self.z.eq(&rhs.z))
341    }
342
343    /// Returns a vector mask containing the result of a `!=` comparison for each element of
344    /// `self` and `rhs`.
345    ///
346    /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
347    /// elements.
348    #[inline]
349    #[must_use]
350    pub fn cmpne(self, rhs: Self) -> BVec3 {
351        BVec3::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y), self.z.ne(&rhs.z))
352    }
353
354    /// Returns a vector mask containing the result of a `>=` comparison for each element of
355    /// `self` and `rhs`.
356    ///
357    /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all
358    /// elements.
359    #[inline]
360    #[must_use]
361    pub fn cmpge(self, rhs: Self) -> BVec3 {
362        BVec3::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y), self.z.ge(&rhs.z))
363    }
364
365    /// Returns a vector mask containing the result of a `>` comparison for each element of
366    /// `self` and `rhs`.
367    ///
368    /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
369    /// elements.
370    #[inline]
371    #[must_use]
372    pub fn cmpgt(self, rhs: Self) -> BVec3 {
373        BVec3::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y), self.z.gt(&rhs.z))
374    }
375
376    /// Returns a vector mask containing the result of a `<=` comparison for each element of
377    /// `self` and `rhs`.
378    ///
379    /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all
380    /// elements.
381    #[inline]
382    #[must_use]
383    pub fn cmple(self, rhs: Self) -> BVec3 {
384        BVec3::new(self.x.le(&rhs.x), self.y.le(&rhs.y), self.z.le(&rhs.z))
385    }
386
387    /// Returns a vector mask containing the result of a `<` comparison for each element of
388    /// `self` and `rhs`.
389    ///
390    /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all
391    /// elements.
392    #[inline]
393    #[must_use]
394    pub fn cmplt(self, rhs: Self) -> BVec3 {
395        BVec3::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y), self.z.lt(&rhs.z))
396    }
397
398    /// Returns a vector containing the absolute value of each element of `self`.
399    #[inline]
400    #[must_use]
401    pub fn abs(self) -> Self {
402        Self {
403            x: self.x.abs(),
404            y: self.y.abs(),
405            z: self.z.abs(),
406        }
407    }
408
409    /// Returns a vector with elements representing the sign of `self`.
410    ///
411    ///  - `0` if the number is zero
412    ///  - `1` if the number is positive
413    ///  - `-1` if the number is negative
414    #[inline]
415    #[must_use]
416    pub fn signum(self) -> Self {
417        Self {
418            x: self.x.signum(),
419            y: self.y.signum(),
420            z: self.z.signum(),
421        }
422    }
423
424    /// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`.
425    ///
426    /// A negative element results in a `1` bit and a positive element in a `0` bit.  Element `x` goes
427    /// into the first lowest bit, element `y` into the second, etc.
428    ///
429    /// An element is negative if it has a negative sign, including -0.0, NaNs with negative sign
430    /// bit and negative infinity.
431    #[inline]
432    #[must_use]
433    pub fn is_negative_bitmask(self) -> u32 {
434        (self.x.is_negative() as u32)
435            | ((self.y.is_negative() as u32) << 1)
436            | ((self.z.is_negative() as u32) << 2)
437    }
438
439    /// Computes the squared length of `self`.
440    #[doc(alias = "magnitude2")]
441    #[inline]
442    #[must_use]
443    pub fn length_squared(self) -> i64 {
444        self.dot(self)
445    }
446
447    /// Compute the squared euclidean distance between two points in space.
448    #[inline]
449    #[must_use]
450    pub fn distance_squared(self, rhs: Self) -> i64 {
451        (self - rhs).length_squared()
452    }
453
454    /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
455    ///
456    /// # Panics
457    /// This function will panic if any `rhs` element is 0 or the division results in overflow.
458    #[inline]
459    #[must_use]
460    pub fn div_euclid(self, rhs: Self) -> Self {
461        Self::new(
462            self.x.div_euclid(rhs.x),
463            self.y.div_euclid(rhs.y),
464            self.z.div_euclid(rhs.z),
465        )
466    }
467
468    /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`.
469    ///
470    /// # Panics
471    /// This function will panic if any `rhs` element is 0 or the division results in overflow.
472    ///
473    /// [Euclidean division]: i64::rem_euclid
474    #[inline]
475    #[must_use]
476    pub fn rem_euclid(self, rhs: Self) -> Self {
477        Self::new(
478            self.x.rem_euclid(rhs.x),
479            self.y.rem_euclid(rhs.y),
480            self.z.rem_euclid(rhs.z),
481        )
482    }
483
484    /// Computes the [manhattan distance] between two points.
485    ///
486    /// # Overflow
487    /// This method may overflow if the result is greater than [`u64::MAX`].
488    ///
489    /// See also [`checked_manhattan_distance`][I64Vec3::checked_manhattan_distance].
490    ///
491    /// [manhattan distance]: https://en.wikipedia.org/wiki/Taxicab_geometry
492    #[inline]
493    #[must_use]
494    pub fn manhattan_distance(self, other: Self) -> u64 {
495        self.x.abs_diff(other.x) + self.y.abs_diff(other.y) + self.z.abs_diff(other.z)
496    }
497
498    /// Computes the [manhattan distance] between two points.
499    ///
500    /// This will returns [`None`] if the result is greater than [`u64::MAX`].
501    ///
502    /// [manhattan distance]: https://en.wikipedia.org/wiki/Taxicab_geometry
503    #[inline]
504    #[must_use]
505    pub fn checked_manhattan_distance(self, other: Self) -> Option<u64> {
506        let d = self.x.abs_diff(other.x);
507        let d = d.checked_add(self.y.abs_diff(other.y))?;
508        d.checked_add(self.z.abs_diff(other.z))
509    }
510
511    /// Computes the [chebyshev distance] between two points.
512    ///
513    /// [chebyshev distance]: https://en.wikipedia.org/wiki/Chebyshev_distance
514    #[inline]
515    #[must_use]
516    pub fn chebyshev_distance(self, other: Self) -> u64 {
517        // Note: the compiler will eventually optimize out the loop
518        [
519            self.x.abs_diff(other.x),
520            self.y.abs_diff(other.y),
521            self.z.abs_diff(other.z),
522        ]
523        .into_iter()
524        .max()
525        .unwrap()
526    }
527
528    /// Casts all elements of `self` to `f32`.
529    #[inline]
530    #[must_use]
531    pub fn as_vec3(&self) -> crate::Vec3 {
532        crate::Vec3::new(self.x as f32, self.y as f32, self.z as f32)
533    }
534
535    /// Casts all elements of `self` to `f32`.
536    #[inline]
537    #[must_use]
538    pub fn as_vec3a(&self) -> crate::Vec3A {
539        crate::Vec3A::new(self.x as f32, self.y as f32, self.z as f32)
540    }
541
542    /// Casts all elements of `self` to `f64`.
543    #[inline]
544    #[must_use]
545    pub fn as_dvec3(&self) -> crate::DVec3 {
546        crate::DVec3::new(self.x as f64, self.y as f64, self.z as f64)
547    }
548
549    /// Casts all elements of `self` to `i8`.
550    #[inline]
551    #[must_use]
552    pub fn as_i8vec3(&self) -> crate::I8Vec3 {
553        crate::I8Vec3::new(self.x as i8, self.y as i8, self.z as i8)
554    }
555
556    /// Casts all elements of `self` to `u8`.
557    #[inline]
558    #[must_use]
559    pub fn as_u8vec3(&self) -> crate::U8Vec3 {
560        crate::U8Vec3::new(self.x as u8, self.y as u8, self.z as u8)
561    }
562
563    /// Casts all elements of `self` to `i16`.
564    #[inline]
565    #[must_use]
566    pub fn as_i16vec3(&self) -> crate::I16Vec3 {
567        crate::I16Vec3::new(self.x as i16, self.y as i16, self.z as i16)
568    }
569
570    /// Casts all elements of `self` to `u16`.
571    #[inline]
572    #[must_use]
573    pub fn as_u16vec3(&self) -> crate::U16Vec3 {
574        crate::U16Vec3::new(self.x as u16, self.y as u16, self.z as u16)
575    }
576
577    /// Casts all elements of `self` to `i32`.
578    #[inline]
579    #[must_use]
580    pub fn as_ivec3(&self) -> crate::IVec3 {
581        crate::IVec3::new(self.x as i32, self.y as i32, self.z as i32)
582    }
583
584    /// Casts all elements of `self` to `u32`.
585    #[inline]
586    #[must_use]
587    pub fn as_uvec3(&self) -> crate::UVec3 {
588        crate::UVec3::new(self.x as u32, self.y as u32, self.z as u32)
589    }
590
591    /// Casts all elements of `self` to `u64`.
592    #[inline]
593    #[must_use]
594    pub fn as_u64vec3(&self) -> crate::U64Vec3 {
595        crate::U64Vec3::new(self.x as u64, self.y as u64, self.z as u64)
596    }
597
598    /// Casts all elements of `self` to `usize`.
599    #[inline]
600    #[must_use]
601    pub fn as_usizevec3(&self) -> crate::USizeVec3 {
602        crate::USizeVec3::new(self.x as usize, self.y as usize, self.z as usize)
603    }
604
605    /// Returns a vector containing the wrapping addition of `self` and `rhs`.
606    ///
607    /// In other words this computes `Some([self.x + rhs.x, self.y + rhs.y, ..])` but returns `None` on any overflow.
608    #[inline]
609    #[must_use]
610    pub const fn checked_add(self, rhs: Self) -> Option<Self> {
611        let x = match self.x.checked_add(rhs.x) {
612            Some(v) => v,
613            None => return None,
614        };
615        let y = match self.y.checked_add(rhs.y) {
616            Some(v) => v,
617            None => return None,
618        };
619        let z = match self.z.checked_add(rhs.z) {
620            Some(v) => v,
621            None => return None,
622        };
623
624        Some(Self { x, y, z })
625    }
626
627    /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
628    ///
629    /// In other words this computes `Some([self.x - rhs.x, self.y - rhs.y, ..])` but returns `None` on any overflow.
630    #[inline]
631    #[must_use]
632    pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
633        let x = match self.x.checked_sub(rhs.x) {
634            Some(v) => v,
635            None => return None,
636        };
637        let y = match self.y.checked_sub(rhs.y) {
638            Some(v) => v,
639            None => return None,
640        };
641        let z = match self.z.checked_sub(rhs.z) {
642            Some(v) => v,
643            None => return None,
644        };
645
646        Some(Self { x, y, z })
647    }
648
649    /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
650    ///
651    /// In other words this computes `Some([self.x * rhs.x, self.y * rhs.y, ..])` but returns `None` on any overflow.
652    #[inline]
653    #[must_use]
654    pub const fn checked_mul(self, rhs: Self) -> Option<Self> {
655        let x = match self.x.checked_mul(rhs.x) {
656            Some(v) => v,
657            None => return None,
658        };
659        let y = match self.y.checked_mul(rhs.y) {
660            Some(v) => v,
661            None => return None,
662        };
663        let z = match self.z.checked_mul(rhs.z) {
664            Some(v) => v,
665            None => return None,
666        };
667
668        Some(Self { x, y, z })
669    }
670
671    /// Returns a vector containing the wrapping division of `self` and `rhs`.
672    ///
673    /// In other words this computes `Some([self.x / rhs.x, self.y / rhs.y, ..])` but returns `None` on any division by zero.
674    #[inline]
675    #[must_use]
676    pub const fn checked_div(self, rhs: Self) -> Option<Self> {
677        let x = match self.x.checked_div(rhs.x) {
678            Some(v) => v,
679            None => return None,
680        };
681        let y = match self.y.checked_div(rhs.y) {
682            Some(v) => v,
683            None => return None,
684        };
685        let z = match self.z.checked_div(rhs.z) {
686            Some(v) => v,
687            None => return None,
688        };
689
690        Some(Self { x, y, z })
691    }
692
693    /// Returns a vector containing the wrapping addition of `self` and `rhs`.
694    ///
695    /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
696    #[inline]
697    #[must_use]
698    pub const fn wrapping_add(self, rhs: Self) -> Self {
699        Self {
700            x: self.x.wrapping_add(rhs.x),
701            y: self.y.wrapping_add(rhs.y),
702            z: self.z.wrapping_add(rhs.z),
703        }
704    }
705
706    /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
707    ///
708    /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
709    #[inline]
710    #[must_use]
711    pub const fn wrapping_sub(self, rhs: Self) -> Self {
712        Self {
713            x: self.x.wrapping_sub(rhs.x),
714            y: self.y.wrapping_sub(rhs.y),
715            z: self.z.wrapping_sub(rhs.z),
716        }
717    }
718
719    /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
720    ///
721    /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
722    #[inline]
723    #[must_use]
724    pub const fn wrapping_mul(self, rhs: Self) -> Self {
725        Self {
726            x: self.x.wrapping_mul(rhs.x),
727            y: self.y.wrapping_mul(rhs.y),
728            z: self.z.wrapping_mul(rhs.z),
729        }
730    }
731
732    /// Returns a vector containing the wrapping division of `self` and `rhs`.
733    ///
734    /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
735    #[inline]
736    #[must_use]
737    pub const fn wrapping_div(self, rhs: Self) -> Self {
738        Self {
739            x: self.x.wrapping_div(rhs.x),
740            y: self.y.wrapping_div(rhs.y),
741            z: self.z.wrapping_div(rhs.z),
742        }
743    }
744
745    /// Returns a vector containing the saturating addition of `self` and `rhs`.
746    ///
747    /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
748    #[inline]
749    #[must_use]
750    pub const fn saturating_add(self, rhs: Self) -> Self {
751        Self {
752            x: self.x.saturating_add(rhs.x),
753            y: self.y.saturating_add(rhs.y),
754            z: self.z.saturating_add(rhs.z),
755        }
756    }
757
758    /// Returns a vector containing the saturating subtraction of `self` and `rhs`.
759    ///
760    /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`.
761    #[inline]
762    #[must_use]
763    pub const fn saturating_sub(self, rhs: Self) -> Self {
764        Self {
765            x: self.x.saturating_sub(rhs.x),
766            y: self.y.saturating_sub(rhs.y),
767            z: self.z.saturating_sub(rhs.z),
768        }
769    }
770
771    /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
772    ///
773    /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
774    #[inline]
775    #[must_use]
776    pub const fn saturating_mul(self, rhs: Self) -> Self {
777        Self {
778            x: self.x.saturating_mul(rhs.x),
779            y: self.y.saturating_mul(rhs.y),
780            z: self.z.saturating_mul(rhs.z),
781        }
782    }
783
784    /// Returns a vector containing the saturating division of `self` and `rhs`.
785    ///
786    /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
787    #[inline]
788    #[must_use]
789    pub const fn saturating_div(self, rhs: Self) -> Self {
790        Self {
791            x: self.x.saturating_div(rhs.x),
792            y: self.y.saturating_div(rhs.y),
793            z: self.z.saturating_div(rhs.z),
794        }
795    }
796
797    /// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`.
798    ///
799    /// In other words this computes `Some([self.x + rhs.x, self.y + rhs.y, ..])` but returns `None` on any overflow.
800    #[inline]
801    #[must_use]
802    pub const fn checked_add_unsigned(self, rhs: U64Vec3) -> Option<Self> {
803        let x = match self.x.checked_add_unsigned(rhs.x) {
804            Some(v) => v,
805            None => return None,
806        };
807        let y = match self.y.checked_add_unsigned(rhs.y) {
808            Some(v) => v,
809            None => return None,
810        };
811        let z = match self.z.checked_add_unsigned(rhs.z) {
812            Some(v) => v,
813            None => return None,
814        };
815
816        Some(Self { x, y, z })
817    }
818
819    /// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`.
820    ///
821    /// In other words this computes `Some([self.x - rhs.x, self.y - rhs.y, ..])` but returns `None` on any overflow.
822    #[inline]
823    #[must_use]
824    pub const fn checked_sub_unsigned(self, rhs: U64Vec3) -> Option<Self> {
825        let x = match self.x.checked_sub_unsigned(rhs.x) {
826            Some(v) => v,
827            None => return None,
828        };
829        let y = match self.y.checked_sub_unsigned(rhs.y) {
830            Some(v) => v,
831            None => return None,
832        };
833        let z = match self.z.checked_sub_unsigned(rhs.z) {
834            Some(v) => v,
835            None => return None,
836        };
837
838        Some(Self { x, y, z })
839    }
840
841    /// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`.
842    ///
843    /// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`.
844    #[inline]
845    #[must_use]
846    pub const fn wrapping_add_unsigned(self, rhs: U64Vec3) -> Self {
847        Self {
848            x: self.x.wrapping_add_unsigned(rhs.x),
849            y: self.y.wrapping_add_unsigned(rhs.y),
850            z: self.z.wrapping_add_unsigned(rhs.z),
851        }
852    }
853
854    /// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`.
855    ///
856    /// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`.
857    #[inline]
858    #[must_use]
859    pub const fn wrapping_sub_unsigned(self, rhs: U64Vec3) -> Self {
860        Self {
861            x: self.x.wrapping_sub_unsigned(rhs.x),
862            y: self.y.wrapping_sub_unsigned(rhs.y),
863            z: self.z.wrapping_sub_unsigned(rhs.z),
864        }
865    }
866
867    // Returns a vector containing the saturating addition of `self` and unsigned vector `rhs`.
868    ///
869    /// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
870    #[inline]
871    #[must_use]
872    pub const fn saturating_add_unsigned(self, rhs: U64Vec3) -> Self {
873        Self {
874            x: self.x.saturating_add_unsigned(rhs.x),
875            y: self.y.saturating_add_unsigned(rhs.y),
876            z: self.z.saturating_add_unsigned(rhs.z),
877        }
878    }
879
880    /// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`.
881    ///
882    /// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`.
883    #[inline]
884    #[must_use]
885    pub const fn saturating_sub_unsigned(self, rhs: U64Vec3) -> Self {
886        Self {
887            x: self.x.saturating_sub_unsigned(rhs.x),
888            y: self.y.saturating_sub_unsigned(rhs.y),
889            z: self.z.saturating_sub_unsigned(rhs.z),
890        }
891    }
892}
893
894impl Default for I64Vec3 {
895    #[inline(always)]
896    fn default() -> Self {
897        Self::ZERO
898    }
899}
900
901impl Div<I64Vec3> for I64Vec3 {
902    type Output = Self;
903    #[inline]
904    fn div(self, rhs: Self) -> Self {
905        Self {
906            x: self.x.div(rhs.x),
907            y: self.y.div(rhs.y),
908            z: self.z.div(rhs.z),
909        }
910    }
911}
912
913impl Div<&I64Vec3> for I64Vec3 {
914    type Output = I64Vec3;
915    #[inline]
916    fn div(self, rhs: &I64Vec3) -> I64Vec3 {
917        self.div(*rhs)
918    }
919}
920
921impl Div<&I64Vec3> for &I64Vec3 {
922    type Output = I64Vec3;
923    #[inline]
924    fn div(self, rhs: &I64Vec3) -> I64Vec3 {
925        (*self).div(*rhs)
926    }
927}
928
929impl Div<I64Vec3> for &I64Vec3 {
930    type Output = I64Vec3;
931    #[inline]
932    fn div(self, rhs: I64Vec3) -> I64Vec3 {
933        (*self).div(rhs)
934    }
935}
936
937impl DivAssign<I64Vec3> for I64Vec3 {
938    #[inline]
939    fn div_assign(&mut self, rhs: Self) {
940        self.x.div_assign(rhs.x);
941        self.y.div_assign(rhs.y);
942        self.z.div_assign(rhs.z);
943    }
944}
945
946impl DivAssign<&I64Vec3> for I64Vec3 {
947    #[inline]
948    fn div_assign(&mut self, rhs: &I64Vec3) {
949        self.div_assign(*rhs)
950    }
951}
952
953impl Div<i64> for I64Vec3 {
954    type Output = Self;
955    #[inline]
956    fn div(self, rhs: i64) -> Self {
957        Self {
958            x: self.x.div(rhs),
959            y: self.y.div(rhs),
960            z: self.z.div(rhs),
961        }
962    }
963}
964
965impl Div<&i64> for I64Vec3 {
966    type Output = I64Vec3;
967    #[inline]
968    fn div(self, rhs: &i64) -> I64Vec3 {
969        self.div(*rhs)
970    }
971}
972
973impl Div<&i64> for &I64Vec3 {
974    type Output = I64Vec3;
975    #[inline]
976    fn div(self, rhs: &i64) -> I64Vec3 {
977        (*self).div(*rhs)
978    }
979}
980
981impl Div<i64> for &I64Vec3 {
982    type Output = I64Vec3;
983    #[inline]
984    fn div(self, rhs: i64) -> I64Vec3 {
985        (*self).div(rhs)
986    }
987}
988
989impl DivAssign<i64> for I64Vec3 {
990    #[inline]
991    fn div_assign(&mut self, rhs: i64) {
992        self.x.div_assign(rhs);
993        self.y.div_assign(rhs);
994        self.z.div_assign(rhs);
995    }
996}
997
998impl DivAssign<&i64> for I64Vec3 {
999    #[inline]
1000    fn div_assign(&mut self, rhs: &i64) {
1001        self.div_assign(*rhs)
1002    }
1003}
1004
1005impl Div<I64Vec3> for i64 {
1006    type Output = I64Vec3;
1007    #[inline]
1008    fn div(self, rhs: I64Vec3) -> I64Vec3 {
1009        I64Vec3 {
1010            x: self.div(rhs.x),
1011            y: self.div(rhs.y),
1012            z: self.div(rhs.z),
1013        }
1014    }
1015}
1016
1017impl Div<&I64Vec3> for i64 {
1018    type Output = I64Vec3;
1019    #[inline]
1020    fn div(self, rhs: &I64Vec3) -> I64Vec3 {
1021        self.div(*rhs)
1022    }
1023}
1024
1025impl Div<&I64Vec3> for &i64 {
1026    type Output = I64Vec3;
1027    #[inline]
1028    fn div(self, rhs: &I64Vec3) -> I64Vec3 {
1029        (*self).div(*rhs)
1030    }
1031}
1032
1033impl Div<I64Vec3> for &i64 {
1034    type Output = I64Vec3;
1035    #[inline]
1036    fn div(self, rhs: I64Vec3) -> I64Vec3 {
1037        (*self).div(rhs)
1038    }
1039}
1040
1041impl Mul<I64Vec3> for I64Vec3 {
1042    type Output = Self;
1043    #[inline]
1044    fn mul(self, rhs: Self) -> Self {
1045        Self {
1046            x: self.x.mul(rhs.x),
1047            y: self.y.mul(rhs.y),
1048            z: self.z.mul(rhs.z),
1049        }
1050    }
1051}
1052
1053impl Mul<&I64Vec3> for I64Vec3 {
1054    type Output = I64Vec3;
1055    #[inline]
1056    fn mul(self, rhs: &I64Vec3) -> I64Vec3 {
1057        self.mul(*rhs)
1058    }
1059}
1060
1061impl Mul<&I64Vec3> for &I64Vec3 {
1062    type Output = I64Vec3;
1063    #[inline]
1064    fn mul(self, rhs: &I64Vec3) -> I64Vec3 {
1065        (*self).mul(*rhs)
1066    }
1067}
1068
1069impl Mul<I64Vec3> for &I64Vec3 {
1070    type Output = I64Vec3;
1071    #[inline]
1072    fn mul(self, rhs: I64Vec3) -> I64Vec3 {
1073        (*self).mul(rhs)
1074    }
1075}
1076
1077impl MulAssign<I64Vec3> for I64Vec3 {
1078    #[inline]
1079    fn mul_assign(&mut self, rhs: Self) {
1080        self.x.mul_assign(rhs.x);
1081        self.y.mul_assign(rhs.y);
1082        self.z.mul_assign(rhs.z);
1083    }
1084}
1085
1086impl MulAssign<&I64Vec3> for I64Vec3 {
1087    #[inline]
1088    fn mul_assign(&mut self, rhs: &I64Vec3) {
1089        self.mul_assign(*rhs)
1090    }
1091}
1092
1093impl Mul<i64> for I64Vec3 {
1094    type Output = Self;
1095    #[inline]
1096    fn mul(self, rhs: i64) -> Self {
1097        Self {
1098            x: self.x.mul(rhs),
1099            y: self.y.mul(rhs),
1100            z: self.z.mul(rhs),
1101        }
1102    }
1103}
1104
1105impl Mul<&i64> for I64Vec3 {
1106    type Output = I64Vec3;
1107    #[inline]
1108    fn mul(self, rhs: &i64) -> I64Vec3 {
1109        self.mul(*rhs)
1110    }
1111}
1112
1113impl Mul<&i64> for &I64Vec3 {
1114    type Output = I64Vec3;
1115    #[inline]
1116    fn mul(self, rhs: &i64) -> I64Vec3 {
1117        (*self).mul(*rhs)
1118    }
1119}
1120
1121impl Mul<i64> for &I64Vec3 {
1122    type Output = I64Vec3;
1123    #[inline]
1124    fn mul(self, rhs: i64) -> I64Vec3 {
1125        (*self).mul(rhs)
1126    }
1127}
1128
1129impl MulAssign<i64> for I64Vec3 {
1130    #[inline]
1131    fn mul_assign(&mut self, rhs: i64) {
1132        self.x.mul_assign(rhs);
1133        self.y.mul_assign(rhs);
1134        self.z.mul_assign(rhs);
1135    }
1136}
1137
1138impl MulAssign<&i64> for I64Vec3 {
1139    #[inline]
1140    fn mul_assign(&mut self, rhs: &i64) {
1141        self.mul_assign(*rhs)
1142    }
1143}
1144
1145impl Mul<I64Vec3> for i64 {
1146    type Output = I64Vec3;
1147    #[inline]
1148    fn mul(self, rhs: I64Vec3) -> I64Vec3 {
1149        I64Vec3 {
1150            x: self.mul(rhs.x),
1151            y: self.mul(rhs.y),
1152            z: self.mul(rhs.z),
1153        }
1154    }
1155}
1156
1157impl Mul<&I64Vec3> for i64 {
1158    type Output = I64Vec3;
1159    #[inline]
1160    fn mul(self, rhs: &I64Vec3) -> I64Vec3 {
1161        self.mul(*rhs)
1162    }
1163}
1164
1165impl Mul<&I64Vec3> for &i64 {
1166    type Output = I64Vec3;
1167    #[inline]
1168    fn mul(self, rhs: &I64Vec3) -> I64Vec3 {
1169        (*self).mul(*rhs)
1170    }
1171}
1172
1173impl Mul<I64Vec3> for &i64 {
1174    type Output = I64Vec3;
1175    #[inline]
1176    fn mul(self, rhs: I64Vec3) -> I64Vec3 {
1177        (*self).mul(rhs)
1178    }
1179}
1180
1181impl Add<I64Vec3> for I64Vec3 {
1182    type Output = Self;
1183    #[inline]
1184    fn add(self, rhs: Self) -> Self {
1185        Self {
1186            x: self.x.add(rhs.x),
1187            y: self.y.add(rhs.y),
1188            z: self.z.add(rhs.z),
1189        }
1190    }
1191}
1192
1193impl Add<&I64Vec3> for I64Vec3 {
1194    type Output = I64Vec3;
1195    #[inline]
1196    fn add(self, rhs: &I64Vec3) -> I64Vec3 {
1197        self.add(*rhs)
1198    }
1199}
1200
1201impl Add<&I64Vec3> for &I64Vec3 {
1202    type Output = I64Vec3;
1203    #[inline]
1204    fn add(self, rhs: &I64Vec3) -> I64Vec3 {
1205        (*self).add(*rhs)
1206    }
1207}
1208
1209impl Add<I64Vec3> for &I64Vec3 {
1210    type Output = I64Vec3;
1211    #[inline]
1212    fn add(self, rhs: I64Vec3) -> I64Vec3 {
1213        (*self).add(rhs)
1214    }
1215}
1216
1217impl AddAssign<I64Vec3> for I64Vec3 {
1218    #[inline]
1219    fn add_assign(&mut self, rhs: Self) {
1220        self.x.add_assign(rhs.x);
1221        self.y.add_assign(rhs.y);
1222        self.z.add_assign(rhs.z);
1223    }
1224}
1225
1226impl AddAssign<&I64Vec3> for I64Vec3 {
1227    #[inline]
1228    fn add_assign(&mut self, rhs: &I64Vec3) {
1229        self.add_assign(*rhs)
1230    }
1231}
1232
1233impl Add<i64> for I64Vec3 {
1234    type Output = Self;
1235    #[inline]
1236    fn add(self, rhs: i64) -> Self {
1237        Self {
1238            x: self.x.add(rhs),
1239            y: self.y.add(rhs),
1240            z: self.z.add(rhs),
1241        }
1242    }
1243}
1244
1245impl Add<&i64> for I64Vec3 {
1246    type Output = I64Vec3;
1247    #[inline]
1248    fn add(self, rhs: &i64) -> I64Vec3 {
1249        self.add(*rhs)
1250    }
1251}
1252
1253impl Add<&i64> for &I64Vec3 {
1254    type Output = I64Vec3;
1255    #[inline]
1256    fn add(self, rhs: &i64) -> I64Vec3 {
1257        (*self).add(*rhs)
1258    }
1259}
1260
1261impl Add<i64> for &I64Vec3 {
1262    type Output = I64Vec3;
1263    #[inline]
1264    fn add(self, rhs: i64) -> I64Vec3 {
1265        (*self).add(rhs)
1266    }
1267}
1268
1269impl AddAssign<i64> for I64Vec3 {
1270    #[inline]
1271    fn add_assign(&mut self, rhs: i64) {
1272        self.x.add_assign(rhs);
1273        self.y.add_assign(rhs);
1274        self.z.add_assign(rhs);
1275    }
1276}
1277
1278impl AddAssign<&i64> for I64Vec3 {
1279    #[inline]
1280    fn add_assign(&mut self, rhs: &i64) {
1281        self.add_assign(*rhs)
1282    }
1283}
1284
1285impl Add<I64Vec3> for i64 {
1286    type Output = I64Vec3;
1287    #[inline]
1288    fn add(self, rhs: I64Vec3) -> I64Vec3 {
1289        I64Vec3 {
1290            x: self.add(rhs.x),
1291            y: self.add(rhs.y),
1292            z: self.add(rhs.z),
1293        }
1294    }
1295}
1296
1297impl Add<&I64Vec3> for i64 {
1298    type Output = I64Vec3;
1299    #[inline]
1300    fn add(self, rhs: &I64Vec3) -> I64Vec3 {
1301        self.add(*rhs)
1302    }
1303}
1304
1305impl Add<&I64Vec3> for &i64 {
1306    type Output = I64Vec3;
1307    #[inline]
1308    fn add(self, rhs: &I64Vec3) -> I64Vec3 {
1309        (*self).add(*rhs)
1310    }
1311}
1312
1313impl Add<I64Vec3> for &i64 {
1314    type Output = I64Vec3;
1315    #[inline]
1316    fn add(self, rhs: I64Vec3) -> I64Vec3 {
1317        (*self).add(rhs)
1318    }
1319}
1320
1321impl Sub<I64Vec3> for I64Vec3 {
1322    type Output = Self;
1323    #[inline]
1324    fn sub(self, rhs: Self) -> Self {
1325        Self {
1326            x: self.x.sub(rhs.x),
1327            y: self.y.sub(rhs.y),
1328            z: self.z.sub(rhs.z),
1329        }
1330    }
1331}
1332
1333impl Sub<&I64Vec3> for I64Vec3 {
1334    type Output = I64Vec3;
1335    #[inline]
1336    fn sub(self, rhs: &I64Vec3) -> I64Vec3 {
1337        self.sub(*rhs)
1338    }
1339}
1340
1341impl Sub<&I64Vec3> for &I64Vec3 {
1342    type Output = I64Vec3;
1343    #[inline]
1344    fn sub(self, rhs: &I64Vec3) -> I64Vec3 {
1345        (*self).sub(*rhs)
1346    }
1347}
1348
1349impl Sub<I64Vec3> for &I64Vec3 {
1350    type Output = I64Vec3;
1351    #[inline]
1352    fn sub(self, rhs: I64Vec3) -> I64Vec3 {
1353        (*self).sub(rhs)
1354    }
1355}
1356
1357impl SubAssign<I64Vec3> for I64Vec3 {
1358    #[inline]
1359    fn sub_assign(&mut self, rhs: I64Vec3) {
1360        self.x.sub_assign(rhs.x);
1361        self.y.sub_assign(rhs.y);
1362        self.z.sub_assign(rhs.z);
1363    }
1364}
1365
1366impl SubAssign<&I64Vec3> for I64Vec3 {
1367    #[inline]
1368    fn sub_assign(&mut self, rhs: &I64Vec3) {
1369        self.sub_assign(*rhs)
1370    }
1371}
1372
1373impl Sub<i64> for I64Vec3 {
1374    type Output = Self;
1375    #[inline]
1376    fn sub(self, rhs: i64) -> Self {
1377        Self {
1378            x: self.x.sub(rhs),
1379            y: self.y.sub(rhs),
1380            z: self.z.sub(rhs),
1381        }
1382    }
1383}
1384
1385impl Sub<&i64> for I64Vec3 {
1386    type Output = I64Vec3;
1387    #[inline]
1388    fn sub(self, rhs: &i64) -> I64Vec3 {
1389        self.sub(*rhs)
1390    }
1391}
1392
1393impl Sub<&i64> for &I64Vec3 {
1394    type Output = I64Vec3;
1395    #[inline]
1396    fn sub(self, rhs: &i64) -> I64Vec3 {
1397        (*self).sub(*rhs)
1398    }
1399}
1400
1401impl Sub<i64> for &I64Vec3 {
1402    type Output = I64Vec3;
1403    #[inline]
1404    fn sub(self, rhs: i64) -> I64Vec3 {
1405        (*self).sub(rhs)
1406    }
1407}
1408
1409impl SubAssign<i64> for I64Vec3 {
1410    #[inline]
1411    fn sub_assign(&mut self, rhs: i64) {
1412        self.x.sub_assign(rhs);
1413        self.y.sub_assign(rhs);
1414        self.z.sub_assign(rhs);
1415    }
1416}
1417
1418impl SubAssign<&i64> for I64Vec3 {
1419    #[inline]
1420    fn sub_assign(&mut self, rhs: &i64) {
1421        self.sub_assign(*rhs)
1422    }
1423}
1424
1425impl Sub<I64Vec3> for i64 {
1426    type Output = I64Vec3;
1427    #[inline]
1428    fn sub(self, rhs: I64Vec3) -> I64Vec3 {
1429        I64Vec3 {
1430            x: self.sub(rhs.x),
1431            y: self.sub(rhs.y),
1432            z: self.sub(rhs.z),
1433        }
1434    }
1435}
1436
1437impl Sub<&I64Vec3> for i64 {
1438    type Output = I64Vec3;
1439    #[inline]
1440    fn sub(self, rhs: &I64Vec3) -> I64Vec3 {
1441        self.sub(*rhs)
1442    }
1443}
1444
1445impl Sub<&I64Vec3> for &i64 {
1446    type Output = I64Vec3;
1447    #[inline]
1448    fn sub(self, rhs: &I64Vec3) -> I64Vec3 {
1449        (*self).sub(*rhs)
1450    }
1451}
1452
1453impl Sub<I64Vec3> for &i64 {
1454    type Output = I64Vec3;
1455    #[inline]
1456    fn sub(self, rhs: I64Vec3) -> I64Vec3 {
1457        (*self).sub(rhs)
1458    }
1459}
1460
1461impl Rem<I64Vec3> for I64Vec3 {
1462    type Output = Self;
1463    #[inline]
1464    fn rem(self, rhs: Self) -> Self {
1465        Self {
1466            x: self.x.rem(rhs.x),
1467            y: self.y.rem(rhs.y),
1468            z: self.z.rem(rhs.z),
1469        }
1470    }
1471}
1472
1473impl Rem<&I64Vec3> for I64Vec3 {
1474    type Output = I64Vec3;
1475    #[inline]
1476    fn rem(self, rhs: &I64Vec3) -> I64Vec3 {
1477        self.rem(*rhs)
1478    }
1479}
1480
1481impl Rem<&I64Vec3> for &I64Vec3 {
1482    type Output = I64Vec3;
1483    #[inline]
1484    fn rem(self, rhs: &I64Vec3) -> I64Vec3 {
1485        (*self).rem(*rhs)
1486    }
1487}
1488
1489impl Rem<I64Vec3> for &I64Vec3 {
1490    type Output = I64Vec3;
1491    #[inline]
1492    fn rem(self, rhs: I64Vec3) -> I64Vec3 {
1493        (*self).rem(rhs)
1494    }
1495}
1496
1497impl RemAssign<I64Vec3> for I64Vec3 {
1498    #[inline]
1499    fn rem_assign(&mut self, rhs: Self) {
1500        self.x.rem_assign(rhs.x);
1501        self.y.rem_assign(rhs.y);
1502        self.z.rem_assign(rhs.z);
1503    }
1504}
1505
1506impl RemAssign<&I64Vec3> for I64Vec3 {
1507    #[inline]
1508    fn rem_assign(&mut self, rhs: &I64Vec3) {
1509        self.rem_assign(*rhs)
1510    }
1511}
1512
1513impl Rem<i64> for I64Vec3 {
1514    type Output = Self;
1515    #[inline]
1516    fn rem(self, rhs: i64) -> Self {
1517        Self {
1518            x: self.x.rem(rhs),
1519            y: self.y.rem(rhs),
1520            z: self.z.rem(rhs),
1521        }
1522    }
1523}
1524
1525impl Rem<&i64> for I64Vec3 {
1526    type Output = I64Vec3;
1527    #[inline]
1528    fn rem(self, rhs: &i64) -> I64Vec3 {
1529        self.rem(*rhs)
1530    }
1531}
1532
1533impl Rem<&i64> for &I64Vec3 {
1534    type Output = I64Vec3;
1535    #[inline]
1536    fn rem(self, rhs: &i64) -> I64Vec3 {
1537        (*self).rem(*rhs)
1538    }
1539}
1540
1541impl Rem<i64> for &I64Vec3 {
1542    type Output = I64Vec3;
1543    #[inline]
1544    fn rem(self, rhs: i64) -> I64Vec3 {
1545        (*self).rem(rhs)
1546    }
1547}
1548
1549impl RemAssign<i64> for I64Vec3 {
1550    #[inline]
1551    fn rem_assign(&mut self, rhs: i64) {
1552        self.x.rem_assign(rhs);
1553        self.y.rem_assign(rhs);
1554        self.z.rem_assign(rhs);
1555    }
1556}
1557
1558impl RemAssign<&i64> for I64Vec3 {
1559    #[inline]
1560    fn rem_assign(&mut self, rhs: &i64) {
1561        self.rem_assign(*rhs)
1562    }
1563}
1564
1565impl Rem<I64Vec3> for i64 {
1566    type Output = I64Vec3;
1567    #[inline]
1568    fn rem(self, rhs: I64Vec3) -> I64Vec3 {
1569        I64Vec3 {
1570            x: self.rem(rhs.x),
1571            y: self.rem(rhs.y),
1572            z: self.rem(rhs.z),
1573        }
1574    }
1575}
1576
1577impl Rem<&I64Vec3> for i64 {
1578    type Output = I64Vec3;
1579    #[inline]
1580    fn rem(self, rhs: &I64Vec3) -> I64Vec3 {
1581        self.rem(*rhs)
1582    }
1583}
1584
1585impl Rem<&I64Vec3> for &i64 {
1586    type Output = I64Vec3;
1587    #[inline]
1588    fn rem(self, rhs: &I64Vec3) -> I64Vec3 {
1589        (*self).rem(*rhs)
1590    }
1591}
1592
1593impl Rem<I64Vec3> for &i64 {
1594    type Output = I64Vec3;
1595    #[inline]
1596    fn rem(self, rhs: I64Vec3) -> I64Vec3 {
1597        (*self).rem(rhs)
1598    }
1599}
1600
1601#[cfg(not(target_arch = "spirv"))]
1602impl AsRef<[i64; 3]> for I64Vec3 {
1603    #[inline]
1604    fn as_ref(&self) -> &[i64; 3] {
1605        unsafe { &*(self as *const I64Vec3 as *const [i64; 3]) }
1606    }
1607}
1608
1609#[cfg(not(target_arch = "spirv"))]
1610impl AsMut<[i64; 3]> for I64Vec3 {
1611    #[inline]
1612    fn as_mut(&mut self) -> &mut [i64; 3] {
1613        unsafe { &mut *(self as *mut I64Vec3 as *mut [i64; 3]) }
1614    }
1615}
1616
1617impl Sum for I64Vec3 {
1618    #[inline]
1619    fn sum<I>(iter: I) -> Self
1620    where
1621        I: Iterator<Item = Self>,
1622    {
1623        iter.fold(Self::ZERO, Self::add)
1624    }
1625}
1626
1627impl<'a> Sum<&'a Self> for I64Vec3 {
1628    #[inline]
1629    fn sum<I>(iter: I) -> Self
1630    where
1631        I: Iterator<Item = &'a Self>,
1632    {
1633        iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1634    }
1635}
1636
1637impl Product for I64Vec3 {
1638    #[inline]
1639    fn product<I>(iter: I) -> Self
1640    where
1641        I: Iterator<Item = Self>,
1642    {
1643        iter.fold(Self::ONE, Self::mul)
1644    }
1645}
1646
1647impl<'a> Product<&'a Self> for I64Vec3 {
1648    #[inline]
1649    fn product<I>(iter: I) -> Self
1650    where
1651        I: Iterator<Item = &'a Self>,
1652    {
1653        iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1654    }
1655}
1656
1657impl Neg for I64Vec3 {
1658    type Output = Self;
1659    #[inline]
1660    fn neg(self) -> Self {
1661        Self {
1662            x: self.x.neg(),
1663            y: self.y.neg(),
1664            z: self.z.neg(),
1665        }
1666    }
1667}
1668
1669impl Neg for &I64Vec3 {
1670    type Output = I64Vec3;
1671    #[inline]
1672    fn neg(self) -> I64Vec3 {
1673        (*self).neg()
1674    }
1675}
1676
1677impl Not for I64Vec3 {
1678    type Output = Self;
1679    #[inline]
1680    fn not(self) -> Self::Output {
1681        Self {
1682            x: self.x.not(),
1683            y: self.y.not(),
1684            z: self.z.not(),
1685        }
1686    }
1687}
1688
1689impl BitAnd for I64Vec3 {
1690    type Output = Self;
1691    #[inline]
1692    fn bitand(self, rhs: Self) -> Self::Output {
1693        Self {
1694            x: self.x.bitand(rhs.x),
1695            y: self.y.bitand(rhs.y),
1696            z: self.z.bitand(rhs.z),
1697        }
1698    }
1699}
1700
1701impl BitOr for I64Vec3 {
1702    type Output = Self;
1703    #[inline]
1704    fn bitor(self, rhs: Self) -> Self::Output {
1705        Self {
1706            x: self.x.bitor(rhs.x),
1707            y: self.y.bitor(rhs.y),
1708            z: self.z.bitor(rhs.z),
1709        }
1710    }
1711}
1712
1713impl BitXor for I64Vec3 {
1714    type Output = Self;
1715    #[inline]
1716    fn bitxor(self, rhs: Self) -> Self::Output {
1717        Self {
1718            x: self.x.bitxor(rhs.x),
1719            y: self.y.bitxor(rhs.y),
1720            z: self.z.bitxor(rhs.z),
1721        }
1722    }
1723}
1724
1725impl BitAnd<i64> for I64Vec3 {
1726    type Output = Self;
1727    #[inline]
1728    fn bitand(self, rhs: i64) -> Self::Output {
1729        Self {
1730            x: self.x.bitand(rhs),
1731            y: self.y.bitand(rhs),
1732            z: self.z.bitand(rhs),
1733        }
1734    }
1735}
1736
1737impl BitOr<i64> for I64Vec3 {
1738    type Output = Self;
1739    #[inline]
1740    fn bitor(self, rhs: i64) -> Self::Output {
1741        Self {
1742            x: self.x.bitor(rhs),
1743            y: self.y.bitor(rhs),
1744            z: self.z.bitor(rhs),
1745        }
1746    }
1747}
1748
1749impl BitXor<i64> for I64Vec3 {
1750    type Output = Self;
1751    #[inline]
1752    fn bitxor(self, rhs: i64) -> Self::Output {
1753        Self {
1754            x: self.x.bitxor(rhs),
1755            y: self.y.bitxor(rhs),
1756            z: self.z.bitxor(rhs),
1757        }
1758    }
1759}
1760
1761impl Shl<i8> for I64Vec3 {
1762    type Output = Self;
1763    #[inline]
1764    fn shl(self, rhs: i8) -> Self::Output {
1765        Self {
1766            x: self.x.shl(rhs),
1767            y: self.y.shl(rhs),
1768            z: self.z.shl(rhs),
1769        }
1770    }
1771}
1772
1773impl Shr<i8> for I64Vec3 {
1774    type Output = Self;
1775    #[inline]
1776    fn shr(self, rhs: i8) -> Self::Output {
1777        Self {
1778            x: self.x.shr(rhs),
1779            y: self.y.shr(rhs),
1780            z: self.z.shr(rhs),
1781        }
1782    }
1783}
1784
1785impl Shl<i16> for I64Vec3 {
1786    type Output = Self;
1787    #[inline]
1788    fn shl(self, rhs: i16) -> Self::Output {
1789        Self {
1790            x: self.x.shl(rhs),
1791            y: self.y.shl(rhs),
1792            z: self.z.shl(rhs),
1793        }
1794    }
1795}
1796
1797impl Shr<i16> for I64Vec3 {
1798    type Output = Self;
1799    #[inline]
1800    fn shr(self, rhs: i16) -> Self::Output {
1801        Self {
1802            x: self.x.shr(rhs),
1803            y: self.y.shr(rhs),
1804            z: self.z.shr(rhs),
1805        }
1806    }
1807}
1808
1809impl Shl<i32> for I64Vec3 {
1810    type Output = Self;
1811    #[inline]
1812    fn shl(self, rhs: i32) -> Self::Output {
1813        Self {
1814            x: self.x.shl(rhs),
1815            y: self.y.shl(rhs),
1816            z: self.z.shl(rhs),
1817        }
1818    }
1819}
1820
1821impl Shr<i32> for I64Vec3 {
1822    type Output = Self;
1823    #[inline]
1824    fn shr(self, rhs: i32) -> Self::Output {
1825        Self {
1826            x: self.x.shr(rhs),
1827            y: self.y.shr(rhs),
1828            z: self.z.shr(rhs),
1829        }
1830    }
1831}
1832
1833impl Shl<i64> for I64Vec3 {
1834    type Output = Self;
1835    #[inline]
1836    fn shl(self, rhs: i64) -> Self::Output {
1837        Self {
1838            x: self.x.shl(rhs),
1839            y: self.y.shl(rhs),
1840            z: self.z.shl(rhs),
1841        }
1842    }
1843}
1844
1845impl Shr<i64> for I64Vec3 {
1846    type Output = Self;
1847    #[inline]
1848    fn shr(self, rhs: i64) -> Self::Output {
1849        Self {
1850            x: self.x.shr(rhs),
1851            y: self.y.shr(rhs),
1852            z: self.z.shr(rhs),
1853        }
1854    }
1855}
1856
1857impl Shl<u8> for I64Vec3 {
1858    type Output = Self;
1859    #[inline]
1860    fn shl(self, rhs: u8) -> Self::Output {
1861        Self {
1862            x: self.x.shl(rhs),
1863            y: self.y.shl(rhs),
1864            z: self.z.shl(rhs),
1865        }
1866    }
1867}
1868
1869impl Shr<u8> for I64Vec3 {
1870    type Output = Self;
1871    #[inline]
1872    fn shr(self, rhs: u8) -> Self::Output {
1873        Self {
1874            x: self.x.shr(rhs),
1875            y: self.y.shr(rhs),
1876            z: self.z.shr(rhs),
1877        }
1878    }
1879}
1880
1881impl Shl<u16> for I64Vec3 {
1882    type Output = Self;
1883    #[inline]
1884    fn shl(self, rhs: u16) -> Self::Output {
1885        Self {
1886            x: self.x.shl(rhs),
1887            y: self.y.shl(rhs),
1888            z: self.z.shl(rhs),
1889        }
1890    }
1891}
1892
1893impl Shr<u16> for I64Vec3 {
1894    type Output = Self;
1895    #[inline]
1896    fn shr(self, rhs: u16) -> Self::Output {
1897        Self {
1898            x: self.x.shr(rhs),
1899            y: self.y.shr(rhs),
1900            z: self.z.shr(rhs),
1901        }
1902    }
1903}
1904
1905impl Shl<u32> for I64Vec3 {
1906    type Output = Self;
1907    #[inline]
1908    fn shl(self, rhs: u32) -> Self::Output {
1909        Self {
1910            x: self.x.shl(rhs),
1911            y: self.y.shl(rhs),
1912            z: self.z.shl(rhs),
1913        }
1914    }
1915}
1916
1917impl Shr<u32> for I64Vec3 {
1918    type Output = Self;
1919    #[inline]
1920    fn shr(self, rhs: u32) -> Self::Output {
1921        Self {
1922            x: self.x.shr(rhs),
1923            y: self.y.shr(rhs),
1924            z: self.z.shr(rhs),
1925        }
1926    }
1927}
1928
1929impl Shl<u64> for I64Vec3 {
1930    type Output = Self;
1931    #[inline]
1932    fn shl(self, rhs: u64) -> Self::Output {
1933        Self {
1934            x: self.x.shl(rhs),
1935            y: self.y.shl(rhs),
1936            z: self.z.shl(rhs),
1937        }
1938    }
1939}
1940
1941impl Shr<u64> for I64Vec3 {
1942    type Output = Self;
1943    #[inline]
1944    fn shr(self, rhs: u64) -> Self::Output {
1945        Self {
1946            x: self.x.shr(rhs),
1947            y: self.y.shr(rhs),
1948            z: self.z.shr(rhs),
1949        }
1950    }
1951}
1952
1953impl Shl<crate::IVec3> for I64Vec3 {
1954    type Output = Self;
1955    #[inline]
1956    fn shl(self, rhs: crate::IVec3) -> Self::Output {
1957        Self {
1958            x: self.x.shl(rhs.x),
1959            y: self.y.shl(rhs.y),
1960            z: self.z.shl(rhs.z),
1961        }
1962    }
1963}
1964
1965impl Shr<crate::IVec3> for I64Vec3 {
1966    type Output = Self;
1967    #[inline]
1968    fn shr(self, rhs: crate::IVec3) -> Self::Output {
1969        Self {
1970            x: self.x.shr(rhs.x),
1971            y: self.y.shr(rhs.y),
1972            z: self.z.shr(rhs.z),
1973        }
1974    }
1975}
1976
1977impl Shl<crate::UVec3> for I64Vec3 {
1978    type Output = Self;
1979    #[inline]
1980    fn shl(self, rhs: crate::UVec3) -> Self::Output {
1981        Self {
1982            x: self.x.shl(rhs.x),
1983            y: self.y.shl(rhs.y),
1984            z: self.z.shl(rhs.z),
1985        }
1986    }
1987}
1988
1989impl Shr<crate::UVec3> for I64Vec3 {
1990    type Output = Self;
1991    #[inline]
1992    fn shr(self, rhs: crate::UVec3) -> Self::Output {
1993        Self {
1994            x: self.x.shr(rhs.x),
1995            y: self.y.shr(rhs.y),
1996            z: self.z.shr(rhs.z),
1997        }
1998    }
1999}
2000
2001impl Index<usize> for I64Vec3 {
2002    type Output = i64;
2003    #[inline]
2004    fn index(&self, index: usize) -> &Self::Output {
2005        match index {
2006            0 => &self.x,
2007            1 => &self.y,
2008            2 => &self.z,
2009            _ => panic!("index out of bounds"),
2010        }
2011    }
2012}
2013
2014impl IndexMut<usize> for I64Vec3 {
2015    #[inline]
2016    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
2017        match index {
2018            0 => &mut self.x,
2019            1 => &mut self.y,
2020            2 => &mut self.z,
2021            _ => panic!("index out of bounds"),
2022        }
2023    }
2024}
2025
2026impl fmt::Display for I64Vec3 {
2027    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2028        write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
2029    }
2030}
2031
2032impl fmt::Debug for I64Vec3 {
2033    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2034        fmt.debug_tuple(stringify!(I64Vec3))
2035            .field(&self.x)
2036            .field(&self.y)
2037            .field(&self.z)
2038            .finish()
2039    }
2040}
2041
2042impl From<[i64; 3]> for I64Vec3 {
2043    #[inline]
2044    fn from(a: [i64; 3]) -> Self {
2045        Self::new(a[0], a[1], a[2])
2046    }
2047}
2048
2049impl From<I64Vec3> for [i64; 3] {
2050    #[inline]
2051    fn from(v: I64Vec3) -> Self {
2052        [v.x, v.y, v.z]
2053    }
2054}
2055
2056impl From<(i64, i64, i64)> for I64Vec3 {
2057    #[inline]
2058    fn from(t: (i64, i64, i64)) -> Self {
2059        Self::new(t.0, t.1, t.2)
2060    }
2061}
2062
2063impl From<I64Vec3> for (i64, i64, i64) {
2064    #[inline]
2065    fn from(v: I64Vec3) -> Self {
2066        (v.x, v.y, v.z)
2067    }
2068}
2069
2070impl From<(I64Vec2, i64)> for I64Vec3 {
2071    #[inline]
2072    fn from((v, z): (I64Vec2, i64)) -> Self {
2073        Self::new(v.x, v.y, z)
2074    }
2075}
2076
2077impl From<I8Vec3> for I64Vec3 {
2078    #[inline]
2079    fn from(v: I8Vec3) -> Self {
2080        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
2081    }
2082}
2083
2084impl From<U8Vec3> for I64Vec3 {
2085    #[inline]
2086    fn from(v: U8Vec3) -> Self {
2087        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
2088    }
2089}
2090
2091impl From<I16Vec3> for I64Vec3 {
2092    #[inline]
2093    fn from(v: I16Vec3) -> Self {
2094        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
2095    }
2096}
2097
2098impl From<U16Vec3> for I64Vec3 {
2099    #[inline]
2100    fn from(v: U16Vec3) -> Self {
2101        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
2102    }
2103}
2104
2105impl From<IVec3> for I64Vec3 {
2106    #[inline]
2107    fn from(v: IVec3) -> Self {
2108        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
2109    }
2110}
2111
2112impl From<UVec3> for I64Vec3 {
2113    #[inline]
2114    fn from(v: UVec3) -> Self {
2115        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
2116    }
2117}
2118
2119impl TryFrom<U64Vec3> for I64Vec3 {
2120    type Error = core::num::TryFromIntError;
2121
2122    #[inline]
2123    fn try_from(v: U64Vec3) -> Result<Self, Self::Error> {
2124        Ok(Self::new(
2125            i64::try_from(v.x)?,
2126            i64::try_from(v.y)?,
2127            i64::try_from(v.z)?,
2128        ))
2129    }
2130}
2131
2132impl TryFrom<USizeVec3> for I64Vec3 {
2133    type Error = core::num::TryFromIntError;
2134
2135    #[inline]
2136    fn try_from(v: USizeVec3) -> Result<Self, Self::Error> {
2137        Ok(Self::new(
2138            i64::try_from(v.x)?,
2139            i64::try_from(v.y)?,
2140            i64::try_from(v.z)?,
2141        ))
2142    }
2143}
2144
2145impl From<BVec3> for I64Vec3 {
2146    #[inline]
2147    fn from(v: BVec3) -> Self {
2148        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
2149    }
2150}
2151
2152impl From<BVec3A> for I64Vec3 {
2153    #[inline]
2154    fn from(v: BVec3A) -> Self {
2155        let bool_array: [bool; 3] = v.into();
2156        Self::new(
2157            i64::from(bool_array[0]),
2158            i64::from(bool_array[1]),
2159            i64::from(bool_array[2]),
2160        )
2161    }
2162}