glam/i64/
i64vec3.rs

1// Generated from vec.rs.tera template. Edit the template, not the generated file.
2
3use crate::{BVec3, BVec3A, I16Vec3, I64Vec2, I64Vec4, IVec3, U16Vec3, U64Vec3, UVec3};
4
5#[cfg(not(target_arch = "spirv"))]
6use core::fmt;
7use core::iter::{Product, Sum};
8use core::{f32, ops::*};
9
10/// Creates a 3-dimensional vector.
11#[inline(always)]
12#[must_use]
13pub 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))]
22pub struct I64Vec3 {
23    pub x: i64,
24    pub y: i64,
25    pub z: i64,
26}
27
28impl 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]
68    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]
75    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]
86    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]
97    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]
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]
115    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]
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]
135    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]
146    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]
155    pub fn truncate(self) -> I64Vec2 {
156        use crate::swizzles::Vec3Swizzles;
157        self.xy()
158    }
159
160    /// Creates a 3D vector from `self` with the given value of `x`.
161    #[inline]
162    #[must_use]
163    pub fn with_x(mut self, x: i64) -> Self {
164        self.x = x;
165        self
166    }
167
168    /// Creates a 3D vector from `self` with the given value of `y`.
169    #[inline]
170    #[must_use]
171    pub fn with_y(mut self, y: i64) -> Self {
172        self.y = y;
173        self
174    }
175
176    /// Creates a 3D vector from `self` with the given value of `z`.
177    #[inline]
178    #[must_use]
179    pub fn with_z(mut self, z: i64) -> Self {
180        self.z = z;
181        self
182    }
183
184    /// Computes the dot product of `self` and `rhs`.
185    #[inline]
186    #[must_use]
187    pub fn dot(self, rhs: Self) -> i64 {
188        (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z)
189    }
190
191    /// Returns a vector where every component is the dot product of `self` and `rhs`.
192    #[inline]
193    #[must_use]
194    pub fn dot_into_vec(self, rhs: Self) -> Self {
195        Self::splat(self.dot(rhs))
196    }
197
198    /// Computes the cross product of `self` and `rhs`.
199    #[inline]
200    #[must_use]
201    pub fn cross(self, rhs: Self) -> Self {
202        Self {
203            x: self.y * rhs.z - rhs.y * self.z,
204            y: self.z * rhs.x - rhs.z * self.x,
205            z: self.x * rhs.y - rhs.x * self.y,
206        }
207    }
208
209    /// Returns a vector containing the minimum values for each element of `self` and `rhs`.
210    ///
211    /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`.
212    #[inline]
213    #[must_use]
214    pub fn min(self, rhs: Self) -> Self {
215        Self {
216            x: self.x.min(rhs.x),
217            y: self.y.min(rhs.y),
218            z: self.z.min(rhs.z),
219        }
220    }
221
222    /// Returns a vector containing the maximum values for each element of `self` and `rhs`.
223    ///
224    /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`.
225    #[inline]
226    #[must_use]
227    pub fn max(self, rhs: Self) -> Self {
228        Self {
229            x: self.x.max(rhs.x),
230            y: self.y.max(rhs.y),
231            z: self.z.max(rhs.z),
232        }
233    }
234
235    /// Component-wise clamping of values, similar to [`i64::clamp`].
236    ///
237    /// Each element in `min` must be less-or-equal to the corresponding element in `max`.
238    ///
239    /// # Panics
240    ///
241    /// Will panic if `min` is greater than `max` when `glam_assert` is enabled.
242    #[inline]
243    #[must_use]
244    pub fn clamp(self, min: Self, max: Self) -> Self {
245        glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
246        self.max(min).min(max)
247    }
248
249    /// Returns the horizontal minimum of `self`.
250    ///
251    /// In other words this computes `min(x, y, ..)`.
252    #[inline]
253    #[must_use]
254    pub fn min_element(self) -> i64 {
255        self.x.min(self.y.min(self.z))
256    }
257
258    /// Returns the horizontal maximum of `self`.
259    ///
260    /// In other words this computes `max(x, y, ..)`.
261    #[inline]
262    #[must_use]
263    pub fn max_element(self) -> i64 {
264        self.x.max(self.y.max(self.z))
265    }
266
267    /// Returns the sum of all elements of `self`.
268    ///
269    /// In other words, this computes `self.x + self.y + ..`.
270    #[inline]
271    #[must_use]
272    pub fn element_sum(self) -> i64 {
273        self.x + self.y + self.z
274    }
275
276    /// Returns the product of all elements of `self`.
277    ///
278    /// In other words, this computes `self.x * self.y * ..`.
279    #[inline]
280    #[must_use]
281    pub fn element_product(self) -> i64 {
282        self.x * self.y * self.z
283    }
284
285    /// Returns a vector mask containing the result of a `==` comparison for each element of
286    /// `self` and `rhs`.
287    ///
288    /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
289    /// elements.
290    #[inline]
291    #[must_use]
292    pub fn cmpeq(self, rhs: Self) -> BVec3 {
293        BVec3::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y), self.z.eq(&rhs.z))
294    }
295
296    /// Returns a vector mask containing the result of a `!=` comparison for each element of
297    /// `self` and `rhs`.
298    ///
299    /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
300    /// elements.
301    #[inline]
302    #[must_use]
303    pub fn cmpne(self, rhs: Self) -> BVec3 {
304        BVec3::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y), self.z.ne(&rhs.z))
305    }
306
307    /// Returns a vector mask containing the result of a `>=` comparison for each element of
308    /// `self` and `rhs`.
309    ///
310    /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all
311    /// elements.
312    #[inline]
313    #[must_use]
314    pub fn cmpge(self, rhs: Self) -> BVec3 {
315        BVec3::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y), self.z.ge(&rhs.z))
316    }
317
318    /// Returns a vector mask containing the result of a `>` comparison for each element of
319    /// `self` and `rhs`.
320    ///
321    /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
322    /// elements.
323    #[inline]
324    #[must_use]
325    pub fn cmpgt(self, rhs: Self) -> BVec3 {
326        BVec3::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y), self.z.gt(&rhs.z))
327    }
328
329    /// Returns a vector mask containing the result of a `<=` comparison for each element of
330    /// `self` and `rhs`.
331    ///
332    /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all
333    /// elements.
334    #[inline]
335    #[must_use]
336    pub fn cmple(self, rhs: Self) -> BVec3 {
337        BVec3::new(self.x.le(&rhs.x), self.y.le(&rhs.y), self.z.le(&rhs.z))
338    }
339
340    /// Returns a vector mask containing the result of a `<` comparison for each element of
341    /// `self` and `rhs`.
342    ///
343    /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all
344    /// elements.
345    #[inline]
346    #[must_use]
347    pub fn cmplt(self, rhs: Self) -> BVec3 {
348        BVec3::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y), self.z.lt(&rhs.z))
349    }
350
351    /// Returns a vector containing the absolute value of each element of `self`.
352    #[inline]
353    #[must_use]
354    pub fn abs(self) -> Self {
355        Self {
356            x: self.x.abs(),
357            y: self.y.abs(),
358            z: self.z.abs(),
359        }
360    }
361
362    /// Returns a vector with elements representing the sign of `self`.
363    ///
364    ///  - `0` if the number is zero
365    ///  - `1` if the number is positive
366    ///  - `-1` if the number is negative
367    #[inline]
368    #[must_use]
369    pub fn signum(self) -> Self {
370        Self {
371            x: self.x.signum(),
372            y: self.y.signum(),
373            z: self.z.signum(),
374        }
375    }
376
377    /// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`.
378    ///
379    /// A negative element results in a `1` bit and a positive element in a `0` bit.  Element `x` goes
380    /// into the first lowest bit, element `y` into the second, etc.
381    #[inline]
382    #[must_use]
383    pub fn is_negative_bitmask(self) -> u32 {
384        (self.x.is_negative() as u32)
385            | (self.y.is_negative() as u32) << 1
386            | (self.z.is_negative() as u32) << 2
387    }
388
389    /// Computes the squared length of `self`.
390    #[doc(alias = "magnitude2")]
391    #[inline]
392    #[must_use]
393    pub fn length_squared(self) -> i64 {
394        self.dot(self)
395    }
396
397    /// Compute the squared euclidean distance between two points in space.
398    #[inline]
399    #[must_use]
400    pub fn distance_squared(self, rhs: Self) -> i64 {
401        (self - rhs).length_squared()
402    }
403
404    /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
405    ///
406    /// # Panics
407    /// This function will panic if any `rhs` element is 0 or the division results in overflow.
408    #[inline]
409    #[must_use]
410    pub fn div_euclid(self, rhs: Self) -> Self {
411        Self::new(
412            self.x.div_euclid(rhs.x),
413            self.y.div_euclid(rhs.y),
414            self.z.div_euclid(rhs.z),
415        )
416    }
417
418    /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`.
419    ///
420    /// # Panics
421    /// This function will panic if any `rhs` element is 0 or the division results in overflow.
422    ///
423    /// [Euclidean division]: i64::rem_euclid
424    #[inline]
425    #[must_use]
426    pub fn rem_euclid(self, rhs: Self) -> Self {
427        Self::new(
428            self.x.rem_euclid(rhs.x),
429            self.y.rem_euclid(rhs.y),
430            self.z.rem_euclid(rhs.z),
431        )
432    }
433
434    /// Casts all elements of `self` to `f32`.
435    #[inline]
436    #[must_use]
437    pub fn as_vec3(&self) -> crate::Vec3 {
438        crate::Vec3::new(self.x as f32, self.y as f32, self.z as f32)
439    }
440
441    /// Casts all elements of `self` to `f32`.
442    #[inline]
443    #[must_use]
444    pub fn as_vec3a(&self) -> crate::Vec3A {
445        crate::Vec3A::new(self.x as f32, self.y as f32, self.z as f32)
446    }
447
448    /// Casts all elements of `self` to `f64`.
449    #[inline]
450    #[must_use]
451    pub fn as_dvec3(&self) -> crate::DVec3 {
452        crate::DVec3::new(self.x as f64, self.y as f64, self.z as f64)
453    }
454
455    /// Casts all elements of `self` to `i16`.
456    #[inline]
457    #[must_use]
458    pub fn as_i16vec3(&self) -> crate::I16Vec3 {
459        crate::I16Vec3::new(self.x as i16, self.y as i16, self.z as i16)
460    }
461
462    /// Casts all elements of `self` to `u16`.
463    #[inline]
464    #[must_use]
465    pub fn as_u16vec3(&self) -> crate::U16Vec3 {
466        crate::U16Vec3::new(self.x as u16, self.y as u16, self.z as u16)
467    }
468
469    /// Casts all elements of `self` to `i32`.
470    #[inline]
471    #[must_use]
472    pub fn as_ivec3(&self) -> crate::IVec3 {
473        crate::IVec3::new(self.x as i32, self.y as i32, self.z as i32)
474    }
475
476    /// Casts all elements of `self` to `u32`.
477    #[inline]
478    #[must_use]
479    pub fn as_uvec3(&self) -> crate::UVec3 {
480        crate::UVec3::new(self.x as u32, self.y as u32, self.z as u32)
481    }
482
483    /// Casts all elements of `self` to `u64`.
484    #[inline]
485    #[must_use]
486    pub fn as_u64vec3(&self) -> crate::U64Vec3 {
487        crate::U64Vec3::new(self.x as u64, self.y as u64, self.z as u64)
488    }
489
490    /// Returns a vector containing the wrapping addition of `self` and `rhs`.
491    ///
492    /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
493    #[inline]
494    #[must_use]
495    pub const fn wrapping_add(self, rhs: Self) -> Self {
496        Self {
497            x: self.x.wrapping_add(rhs.x),
498            y: self.y.wrapping_add(rhs.y),
499            z: self.z.wrapping_add(rhs.z),
500        }
501    }
502
503    /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
504    ///
505    /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
506    #[inline]
507    #[must_use]
508    pub const fn wrapping_sub(self, rhs: Self) -> Self {
509        Self {
510            x: self.x.wrapping_sub(rhs.x),
511            y: self.y.wrapping_sub(rhs.y),
512            z: self.z.wrapping_sub(rhs.z),
513        }
514    }
515
516    /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
517    ///
518    /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
519    #[inline]
520    #[must_use]
521    pub const fn wrapping_mul(self, rhs: Self) -> Self {
522        Self {
523            x: self.x.wrapping_mul(rhs.x),
524            y: self.y.wrapping_mul(rhs.y),
525            z: self.z.wrapping_mul(rhs.z),
526        }
527    }
528
529    /// Returns a vector containing the wrapping division of `self` and `rhs`.
530    ///
531    /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
532    #[inline]
533    #[must_use]
534    pub const fn wrapping_div(self, rhs: Self) -> Self {
535        Self {
536            x: self.x.wrapping_div(rhs.x),
537            y: self.y.wrapping_div(rhs.y),
538            z: self.z.wrapping_div(rhs.z),
539        }
540    }
541
542    /// Returns a vector containing the saturating addition of `self` and `rhs`.
543    ///
544    /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
545    #[inline]
546    #[must_use]
547    pub const fn saturating_add(self, rhs: Self) -> Self {
548        Self {
549            x: self.x.saturating_add(rhs.x),
550            y: self.y.saturating_add(rhs.y),
551            z: self.z.saturating_add(rhs.z),
552        }
553    }
554
555    /// Returns a vector containing the saturating subtraction of `self` and `rhs`.
556    ///
557    /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`.
558    #[inline]
559    #[must_use]
560    pub const fn saturating_sub(self, rhs: Self) -> Self {
561        Self {
562            x: self.x.saturating_sub(rhs.x),
563            y: self.y.saturating_sub(rhs.y),
564            z: self.z.saturating_sub(rhs.z),
565        }
566    }
567
568    /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
569    ///
570    /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
571    #[inline]
572    #[must_use]
573    pub const fn saturating_mul(self, rhs: Self) -> Self {
574        Self {
575            x: self.x.saturating_mul(rhs.x),
576            y: self.y.saturating_mul(rhs.y),
577            z: self.z.saturating_mul(rhs.z),
578        }
579    }
580
581    /// Returns a vector containing the saturating division of `self` and `rhs`.
582    ///
583    /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
584    #[inline]
585    #[must_use]
586    pub const fn saturating_div(self, rhs: Self) -> Self {
587        Self {
588            x: self.x.saturating_div(rhs.x),
589            y: self.y.saturating_div(rhs.y),
590            z: self.z.saturating_div(rhs.z),
591        }
592    }
593
594    /// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`.
595    ///
596    /// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`.
597    #[inline]
598    #[must_use]
599    pub const fn wrapping_add_unsigned(self, rhs: U64Vec3) -> Self {
600        Self {
601            x: self.x.wrapping_add_unsigned(rhs.x),
602            y: self.y.wrapping_add_unsigned(rhs.y),
603            z: self.z.wrapping_add_unsigned(rhs.z),
604        }
605    }
606
607    /// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`.
608    ///
609    /// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`.
610    #[inline]
611    #[must_use]
612    pub const fn wrapping_sub_unsigned(self, rhs: U64Vec3) -> Self {
613        Self {
614            x: self.x.wrapping_sub_unsigned(rhs.x),
615            y: self.y.wrapping_sub_unsigned(rhs.y),
616            z: self.z.wrapping_sub_unsigned(rhs.z),
617        }
618    }
619
620    // Returns a vector containing the saturating addition of `self` and unsigned vector `rhs`.
621    ///
622    /// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
623    #[inline]
624    #[must_use]
625    pub const fn saturating_add_unsigned(self, rhs: U64Vec3) -> Self {
626        Self {
627            x: self.x.saturating_add_unsigned(rhs.x),
628            y: self.y.saturating_add_unsigned(rhs.y),
629            z: self.z.saturating_add_unsigned(rhs.z),
630        }
631    }
632
633    /// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`.
634    ///
635    /// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`.
636    #[inline]
637    #[must_use]
638    pub const fn saturating_sub_unsigned(self, rhs: U64Vec3) -> Self {
639        Self {
640            x: self.x.saturating_sub_unsigned(rhs.x),
641            y: self.y.saturating_sub_unsigned(rhs.y),
642            z: self.z.saturating_sub_unsigned(rhs.z),
643        }
644    }
645}
646
647impl Default for I64Vec3 {
648    #[inline(always)]
649    fn default() -> Self {
650        Self::ZERO
651    }
652}
653
654impl Div<I64Vec3> for I64Vec3 {
655    type Output = Self;
656    #[inline]
657    fn div(self, rhs: Self) -> Self {
658        Self {
659            x: self.x.div(rhs.x),
660            y: self.y.div(rhs.y),
661            z: self.z.div(rhs.z),
662        }
663    }
664}
665
666impl DivAssign<I64Vec3> for I64Vec3 {
667    #[inline]
668    fn div_assign(&mut self, rhs: Self) {
669        self.x.div_assign(rhs.x);
670        self.y.div_assign(rhs.y);
671        self.z.div_assign(rhs.z);
672    }
673}
674
675impl Div<i64> for I64Vec3 {
676    type Output = Self;
677    #[inline]
678    fn div(self, rhs: i64) -> Self {
679        Self {
680            x: self.x.div(rhs),
681            y: self.y.div(rhs),
682            z: self.z.div(rhs),
683        }
684    }
685}
686
687impl DivAssign<i64> for I64Vec3 {
688    #[inline]
689    fn div_assign(&mut self, rhs: i64) {
690        self.x.div_assign(rhs);
691        self.y.div_assign(rhs);
692        self.z.div_assign(rhs);
693    }
694}
695
696impl Div<I64Vec3> for i64 {
697    type Output = I64Vec3;
698    #[inline]
699    fn div(self, rhs: I64Vec3) -> I64Vec3 {
700        I64Vec3 {
701            x: self.div(rhs.x),
702            y: self.div(rhs.y),
703            z: self.div(rhs.z),
704        }
705    }
706}
707
708impl Mul<I64Vec3> for I64Vec3 {
709    type Output = Self;
710    #[inline]
711    fn mul(self, rhs: Self) -> Self {
712        Self {
713            x: self.x.mul(rhs.x),
714            y: self.y.mul(rhs.y),
715            z: self.z.mul(rhs.z),
716        }
717    }
718}
719
720impl MulAssign<I64Vec3> for I64Vec3 {
721    #[inline]
722    fn mul_assign(&mut self, rhs: Self) {
723        self.x.mul_assign(rhs.x);
724        self.y.mul_assign(rhs.y);
725        self.z.mul_assign(rhs.z);
726    }
727}
728
729impl Mul<i64> for I64Vec3 {
730    type Output = Self;
731    #[inline]
732    fn mul(self, rhs: i64) -> Self {
733        Self {
734            x: self.x.mul(rhs),
735            y: self.y.mul(rhs),
736            z: self.z.mul(rhs),
737        }
738    }
739}
740
741impl MulAssign<i64> for I64Vec3 {
742    #[inline]
743    fn mul_assign(&mut self, rhs: i64) {
744        self.x.mul_assign(rhs);
745        self.y.mul_assign(rhs);
746        self.z.mul_assign(rhs);
747    }
748}
749
750impl Mul<I64Vec3> for i64 {
751    type Output = I64Vec3;
752    #[inline]
753    fn mul(self, rhs: I64Vec3) -> I64Vec3 {
754        I64Vec3 {
755            x: self.mul(rhs.x),
756            y: self.mul(rhs.y),
757            z: self.mul(rhs.z),
758        }
759    }
760}
761
762impl Add<I64Vec3> for I64Vec3 {
763    type Output = Self;
764    #[inline]
765    fn add(self, rhs: Self) -> Self {
766        Self {
767            x: self.x.add(rhs.x),
768            y: self.y.add(rhs.y),
769            z: self.z.add(rhs.z),
770        }
771    }
772}
773
774impl AddAssign<I64Vec3> for I64Vec3 {
775    #[inline]
776    fn add_assign(&mut self, rhs: Self) {
777        self.x.add_assign(rhs.x);
778        self.y.add_assign(rhs.y);
779        self.z.add_assign(rhs.z);
780    }
781}
782
783impl Add<i64> for I64Vec3 {
784    type Output = Self;
785    #[inline]
786    fn add(self, rhs: i64) -> Self {
787        Self {
788            x: self.x.add(rhs),
789            y: self.y.add(rhs),
790            z: self.z.add(rhs),
791        }
792    }
793}
794
795impl AddAssign<i64> for I64Vec3 {
796    #[inline]
797    fn add_assign(&mut self, rhs: i64) {
798        self.x.add_assign(rhs);
799        self.y.add_assign(rhs);
800        self.z.add_assign(rhs);
801    }
802}
803
804impl Add<I64Vec3> for i64 {
805    type Output = I64Vec3;
806    #[inline]
807    fn add(self, rhs: I64Vec3) -> I64Vec3 {
808        I64Vec3 {
809            x: self.add(rhs.x),
810            y: self.add(rhs.y),
811            z: self.add(rhs.z),
812        }
813    }
814}
815
816impl Sub<I64Vec3> for I64Vec3 {
817    type Output = Self;
818    #[inline]
819    fn sub(self, rhs: Self) -> Self {
820        Self {
821            x: self.x.sub(rhs.x),
822            y: self.y.sub(rhs.y),
823            z: self.z.sub(rhs.z),
824        }
825    }
826}
827
828impl SubAssign<I64Vec3> for I64Vec3 {
829    #[inline]
830    fn sub_assign(&mut self, rhs: I64Vec3) {
831        self.x.sub_assign(rhs.x);
832        self.y.sub_assign(rhs.y);
833        self.z.sub_assign(rhs.z);
834    }
835}
836
837impl Sub<i64> for I64Vec3 {
838    type Output = Self;
839    #[inline]
840    fn sub(self, rhs: i64) -> Self {
841        Self {
842            x: self.x.sub(rhs),
843            y: self.y.sub(rhs),
844            z: self.z.sub(rhs),
845        }
846    }
847}
848
849impl SubAssign<i64> for I64Vec3 {
850    #[inline]
851    fn sub_assign(&mut self, rhs: i64) {
852        self.x.sub_assign(rhs);
853        self.y.sub_assign(rhs);
854        self.z.sub_assign(rhs);
855    }
856}
857
858impl Sub<I64Vec3> for i64 {
859    type Output = I64Vec3;
860    #[inline]
861    fn sub(self, rhs: I64Vec3) -> I64Vec3 {
862        I64Vec3 {
863            x: self.sub(rhs.x),
864            y: self.sub(rhs.y),
865            z: self.sub(rhs.z),
866        }
867    }
868}
869
870impl Rem<I64Vec3> for I64Vec3 {
871    type Output = Self;
872    #[inline]
873    fn rem(self, rhs: Self) -> Self {
874        Self {
875            x: self.x.rem(rhs.x),
876            y: self.y.rem(rhs.y),
877            z: self.z.rem(rhs.z),
878        }
879    }
880}
881
882impl RemAssign<I64Vec3> for I64Vec3 {
883    #[inline]
884    fn rem_assign(&mut self, rhs: Self) {
885        self.x.rem_assign(rhs.x);
886        self.y.rem_assign(rhs.y);
887        self.z.rem_assign(rhs.z);
888    }
889}
890
891impl Rem<i64> for I64Vec3 {
892    type Output = Self;
893    #[inline]
894    fn rem(self, rhs: i64) -> Self {
895        Self {
896            x: self.x.rem(rhs),
897            y: self.y.rem(rhs),
898            z: self.z.rem(rhs),
899        }
900    }
901}
902
903impl RemAssign<i64> for I64Vec3 {
904    #[inline]
905    fn rem_assign(&mut self, rhs: i64) {
906        self.x.rem_assign(rhs);
907        self.y.rem_assign(rhs);
908        self.z.rem_assign(rhs);
909    }
910}
911
912impl Rem<I64Vec3> for i64 {
913    type Output = I64Vec3;
914    #[inline]
915    fn rem(self, rhs: I64Vec3) -> I64Vec3 {
916        I64Vec3 {
917            x: self.rem(rhs.x),
918            y: self.rem(rhs.y),
919            z: self.rem(rhs.z),
920        }
921    }
922}
923
924#[cfg(not(target_arch = "spirv"))]
925impl AsRef<[i64; 3]> for I64Vec3 {
926    #[inline]
927    fn as_ref(&self) -> &[i64; 3] {
928        unsafe { &*(self as *const I64Vec3 as *const [i64; 3]) }
929    }
930}
931
932#[cfg(not(target_arch = "spirv"))]
933impl AsMut<[i64; 3]> for I64Vec3 {
934    #[inline]
935    fn as_mut(&mut self) -> &mut [i64; 3] {
936        unsafe { &mut *(self as *mut I64Vec3 as *mut [i64; 3]) }
937    }
938}
939
940impl Sum for I64Vec3 {
941    #[inline]
942    fn sum<I>(iter: I) -> Self
943    where
944        I: Iterator<Item = Self>,
945    {
946        iter.fold(Self::ZERO, Self::add)
947    }
948}
949
950impl<'a> Sum<&'a Self> for I64Vec3 {
951    #[inline]
952    fn sum<I>(iter: I) -> Self
953    where
954        I: Iterator<Item = &'a Self>,
955    {
956        iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
957    }
958}
959
960impl Product for I64Vec3 {
961    #[inline]
962    fn product<I>(iter: I) -> Self
963    where
964        I: Iterator<Item = Self>,
965    {
966        iter.fold(Self::ONE, Self::mul)
967    }
968}
969
970impl<'a> Product<&'a Self> for I64Vec3 {
971    #[inline]
972    fn product<I>(iter: I) -> Self
973    where
974        I: Iterator<Item = &'a Self>,
975    {
976        iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
977    }
978}
979
980impl Neg for I64Vec3 {
981    type Output = Self;
982    #[inline]
983    fn neg(self) -> Self {
984        Self {
985            x: self.x.neg(),
986            y: self.y.neg(),
987            z: self.z.neg(),
988        }
989    }
990}
991
992impl Not for I64Vec3 {
993    type Output = Self;
994    #[inline]
995    fn not(self) -> Self::Output {
996        Self {
997            x: self.x.not(),
998            y: self.y.not(),
999            z: self.z.not(),
1000        }
1001    }
1002}
1003
1004impl BitAnd for I64Vec3 {
1005    type Output = Self;
1006    #[inline]
1007    fn bitand(self, rhs: Self) -> Self::Output {
1008        Self {
1009            x: self.x.bitand(rhs.x),
1010            y: self.y.bitand(rhs.y),
1011            z: self.z.bitand(rhs.z),
1012        }
1013    }
1014}
1015
1016impl BitOr for I64Vec3 {
1017    type Output = Self;
1018    #[inline]
1019    fn bitor(self, rhs: Self) -> Self::Output {
1020        Self {
1021            x: self.x.bitor(rhs.x),
1022            y: self.y.bitor(rhs.y),
1023            z: self.z.bitor(rhs.z),
1024        }
1025    }
1026}
1027
1028impl BitXor for I64Vec3 {
1029    type Output = Self;
1030    #[inline]
1031    fn bitxor(self, rhs: Self) -> Self::Output {
1032        Self {
1033            x: self.x.bitxor(rhs.x),
1034            y: self.y.bitxor(rhs.y),
1035            z: self.z.bitxor(rhs.z),
1036        }
1037    }
1038}
1039
1040impl BitAnd<i64> for I64Vec3 {
1041    type Output = Self;
1042    #[inline]
1043    fn bitand(self, rhs: i64) -> Self::Output {
1044        Self {
1045            x: self.x.bitand(rhs),
1046            y: self.y.bitand(rhs),
1047            z: self.z.bitand(rhs),
1048        }
1049    }
1050}
1051
1052impl BitOr<i64> for I64Vec3 {
1053    type Output = Self;
1054    #[inline]
1055    fn bitor(self, rhs: i64) -> Self::Output {
1056        Self {
1057            x: self.x.bitor(rhs),
1058            y: self.y.bitor(rhs),
1059            z: self.z.bitor(rhs),
1060        }
1061    }
1062}
1063
1064impl BitXor<i64> for I64Vec3 {
1065    type Output = Self;
1066    #[inline]
1067    fn bitxor(self, rhs: i64) -> Self::Output {
1068        Self {
1069            x: self.x.bitxor(rhs),
1070            y: self.y.bitxor(rhs),
1071            z: self.z.bitxor(rhs),
1072        }
1073    }
1074}
1075
1076impl Shl<i8> for I64Vec3 {
1077    type Output = Self;
1078    #[inline]
1079    fn shl(self, rhs: i8) -> Self::Output {
1080        Self {
1081            x: self.x.shl(rhs),
1082            y: self.y.shl(rhs),
1083            z: self.z.shl(rhs),
1084        }
1085    }
1086}
1087
1088impl Shr<i8> for I64Vec3 {
1089    type Output = Self;
1090    #[inline]
1091    fn shr(self, rhs: i8) -> Self::Output {
1092        Self {
1093            x: self.x.shr(rhs),
1094            y: self.y.shr(rhs),
1095            z: self.z.shr(rhs),
1096        }
1097    }
1098}
1099
1100impl Shl<i16> for I64Vec3 {
1101    type Output = Self;
1102    #[inline]
1103    fn shl(self, rhs: i16) -> Self::Output {
1104        Self {
1105            x: self.x.shl(rhs),
1106            y: self.y.shl(rhs),
1107            z: self.z.shl(rhs),
1108        }
1109    }
1110}
1111
1112impl Shr<i16> for I64Vec3 {
1113    type Output = Self;
1114    #[inline]
1115    fn shr(self, rhs: i16) -> Self::Output {
1116        Self {
1117            x: self.x.shr(rhs),
1118            y: self.y.shr(rhs),
1119            z: self.z.shr(rhs),
1120        }
1121    }
1122}
1123
1124impl Shl<i32> for I64Vec3 {
1125    type Output = Self;
1126    #[inline]
1127    fn shl(self, rhs: i32) -> Self::Output {
1128        Self {
1129            x: self.x.shl(rhs),
1130            y: self.y.shl(rhs),
1131            z: self.z.shl(rhs),
1132        }
1133    }
1134}
1135
1136impl Shr<i32> for I64Vec3 {
1137    type Output = Self;
1138    #[inline]
1139    fn shr(self, rhs: i32) -> Self::Output {
1140        Self {
1141            x: self.x.shr(rhs),
1142            y: self.y.shr(rhs),
1143            z: self.z.shr(rhs),
1144        }
1145    }
1146}
1147
1148impl Shl<i64> for I64Vec3 {
1149    type Output = Self;
1150    #[inline]
1151    fn shl(self, rhs: i64) -> Self::Output {
1152        Self {
1153            x: self.x.shl(rhs),
1154            y: self.y.shl(rhs),
1155            z: self.z.shl(rhs),
1156        }
1157    }
1158}
1159
1160impl Shr<i64> for I64Vec3 {
1161    type Output = Self;
1162    #[inline]
1163    fn shr(self, rhs: i64) -> Self::Output {
1164        Self {
1165            x: self.x.shr(rhs),
1166            y: self.y.shr(rhs),
1167            z: self.z.shr(rhs),
1168        }
1169    }
1170}
1171
1172impl Shl<u8> for I64Vec3 {
1173    type Output = Self;
1174    #[inline]
1175    fn shl(self, rhs: u8) -> Self::Output {
1176        Self {
1177            x: self.x.shl(rhs),
1178            y: self.y.shl(rhs),
1179            z: self.z.shl(rhs),
1180        }
1181    }
1182}
1183
1184impl Shr<u8> for I64Vec3 {
1185    type Output = Self;
1186    #[inline]
1187    fn shr(self, rhs: u8) -> Self::Output {
1188        Self {
1189            x: self.x.shr(rhs),
1190            y: self.y.shr(rhs),
1191            z: self.z.shr(rhs),
1192        }
1193    }
1194}
1195
1196impl Shl<u16> for I64Vec3 {
1197    type Output = Self;
1198    #[inline]
1199    fn shl(self, rhs: u16) -> Self::Output {
1200        Self {
1201            x: self.x.shl(rhs),
1202            y: self.y.shl(rhs),
1203            z: self.z.shl(rhs),
1204        }
1205    }
1206}
1207
1208impl Shr<u16> for I64Vec3 {
1209    type Output = Self;
1210    #[inline]
1211    fn shr(self, rhs: u16) -> Self::Output {
1212        Self {
1213            x: self.x.shr(rhs),
1214            y: self.y.shr(rhs),
1215            z: self.z.shr(rhs),
1216        }
1217    }
1218}
1219
1220impl Shl<u32> for I64Vec3 {
1221    type Output = Self;
1222    #[inline]
1223    fn shl(self, rhs: u32) -> Self::Output {
1224        Self {
1225            x: self.x.shl(rhs),
1226            y: self.y.shl(rhs),
1227            z: self.z.shl(rhs),
1228        }
1229    }
1230}
1231
1232impl Shr<u32> for I64Vec3 {
1233    type Output = Self;
1234    #[inline]
1235    fn shr(self, rhs: u32) -> Self::Output {
1236        Self {
1237            x: self.x.shr(rhs),
1238            y: self.y.shr(rhs),
1239            z: self.z.shr(rhs),
1240        }
1241    }
1242}
1243
1244impl Shl<u64> for I64Vec3 {
1245    type Output = Self;
1246    #[inline]
1247    fn shl(self, rhs: u64) -> Self::Output {
1248        Self {
1249            x: self.x.shl(rhs),
1250            y: self.y.shl(rhs),
1251            z: self.z.shl(rhs),
1252        }
1253    }
1254}
1255
1256impl Shr<u64> for I64Vec3 {
1257    type Output = Self;
1258    #[inline]
1259    fn shr(self, rhs: u64) -> Self::Output {
1260        Self {
1261            x: self.x.shr(rhs),
1262            y: self.y.shr(rhs),
1263            z: self.z.shr(rhs),
1264        }
1265    }
1266}
1267
1268impl Shl<crate::IVec3> for I64Vec3 {
1269    type Output = Self;
1270    #[inline]
1271    fn shl(self, rhs: crate::IVec3) -> Self::Output {
1272        Self {
1273            x: self.x.shl(rhs.x),
1274            y: self.y.shl(rhs.y),
1275            z: self.z.shl(rhs.z),
1276        }
1277    }
1278}
1279
1280impl Shr<crate::IVec3> for I64Vec3 {
1281    type Output = Self;
1282    #[inline]
1283    fn shr(self, rhs: crate::IVec3) -> Self::Output {
1284        Self {
1285            x: self.x.shr(rhs.x),
1286            y: self.y.shr(rhs.y),
1287            z: self.z.shr(rhs.z),
1288        }
1289    }
1290}
1291
1292impl Shl<crate::UVec3> for I64Vec3 {
1293    type Output = Self;
1294    #[inline]
1295    fn shl(self, rhs: crate::UVec3) -> Self::Output {
1296        Self {
1297            x: self.x.shl(rhs.x),
1298            y: self.y.shl(rhs.y),
1299            z: self.z.shl(rhs.z),
1300        }
1301    }
1302}
1303
1304impl Shr<crate::UVec3> for I64Vec3 {
1305    type Output = Self;
1306    #[inline]
1307    fn shr(self, rhs: crate::UVec3) -> Self::Output {
1308        Self {
1309            x: self.x.shr(rhs.x),
1310            y: self.y.shr(rhs.y),
1311            z: self.z.shr(rhs.z),
1312        }
1313    }
1314}
1315
1316impl Index<usize> for I64Vec3 {
1317    type Output = i64;
1318    #[inline]
1319    fn index(&self, index: usize) -> &Self::Output {
1320        match index {
1321            0 => &self.x,
1322            1 => &self.y,
1323            2 => &self.z,
1324            _ => panic!("index out of bounds"),
1325        }
1326    }
1327}
1328
1329impl IndexMut<usize> for I64Vec3 {
1330    #[inline]
1331    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1332        match index {
1333            0 => &mut self.x,
1334            1 => &mut self.y,
1335            2 => &mut self.z,
1336            _ => panic!("index out of bounds"),
1337        }
1338    }
1339}
1340
1341#[cfg(not(target_arch = "spirv"))]
1342impl fmt::Display for I64Vec3 {
1343    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1344        write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
1345    }
1346}
1347
1348#[cfg(not(target_arch = "spirv"))]
1349impl fmt::Debug for I64Vec3 {
1350    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1351        fmt.debug_tuple(stringify!(I64Vec3))
1352            .field(&self.x)
1353            .field(&self.y)
1354            .field(&self.z)
1355            .finish()
1356    }
1357}
1358
1359impl From<[i64; 3]> for I64Vec3 {
1360    #[inline]
1361    fn from(a: [i64; 3]) -> Self {
1362        Self::new(a[0], a[1], a[2])
1363    }
1364}
1365
1366impl From<I64Vec3> for [i64; 3] {
1367    #[inline]
1368    fn from(v: I64Vec3) -> Self {
1369        [v.x, v.y, v.z]
1370    }
1371}
1372
1373impl From<(i64, i64, i64)> for I64Vec3 {
1374    #[inline]
1375    fn from(t: (i64, i64, i64)) -> Self {
1376        Self::new(t.0, t.1, t.2)
1377    }
1378}
1379
1380impl From<I64Vec3> for (i64, i64, i64) {
1381    #[inline]
1382    fn from(v: I64Vec3) -> Self {
1383        (v.x, v.y, v.z)
1384    }
1385}
1386
1387impl From<(I64Vec2, i64)> for I64Vec3 {
1388    #[inline]
1389    fn from((v, z): (I64Vec2, i64)) -> Self {
1390        Self::new(v.x, v.y, z)
1391    }
1392}
1393
1394impl From<I16Vec3> for I64Vec3 {
1395    #[inline]
1396    fn from(v: I16Vec3) -> Self {
1397        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
1398    }
1399}
1400
1401impl From<U16Vec3> for I64Vec3 {
1402    #[inline]
1403    fn from(v: U16Vec3) -> Self {
1404        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
1405    }
1406}
1407
1408impl From<IVec3> for I64Vec3 {
1409    #[inline]
1410    fn from(v: IVec3) -> Self {
1411        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
1412    }
1413}
1414
1415impl From<UVec3> for I64Vec3 {
1416    #[inline]
1417    fn from(v: UVec3) -> Self {
1418        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
1419    }
1420}
1421
1422impl TryFrom<U64Vec3> for I64Vec3 {
1423    type Error = core::num::TryFromIntError;
1424
1425    #[inline]
1426    fn try_from(v: U64Vec3) -> Result<Self, Self::Error> {
1427        Ok(Self::new(
1428            i64::try_from(v.x)?,
1429            i64::try_from(v.y)?,
1430            i64::try_from(v.z)?,
1431        ))
1432    }
1433}
1434
1435impl From<BVec3> for I64Vec3 {
1436    #[inline]
1437    fn from(v: BVec3) -> Self {
1438        Self::new(i64::from(v.x), i64::from(v.y), i64::from(v.z))
1439    }
1440}
1441
1442impl From<BVec3A> for I64Vec3 {
1443    #[inline]
1444    fn from(v: BVec3A) -> Self {
1445        let bool_array: [bool; 3] = v.into();
1446        Self::new(
1447            i64::from(bool_array[0]),
1448            i64::from(bool_array[1]),
1449            i64::from(bool_array[2]),
1450        )
1451    }
1452}