1use crate::{BVec2, I16Vec2, I64Vec3, IVec2, U16Vec2, U64Vec2, UVec2};
4
5#[cfg(not(target_arch = "spirv"))]
6use core::fmt;
7use core::iter::{Product, Sum};
8use core::{f32, ops::*};
9
10#[inline(always)]
12#[must_use]
13pub const fn i64vec2(x: i64, y: i64) -> I64Vec2 {
14 I64Vec2::new(x, y)
15}
16
17#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
19#[derive(Clone, Copy, PartialEq, Eq)]
20#[cfg_attr(feature = "cuda", repr(align(16)))]
21#[cfg_attr(not(target_arch = "spirv"), repr(C))]
22#[cfg_attr(target_arch = "spirv", repr(simd))]
23pub struct I64Vec2 {
24 pub x: i64,
25 pub y: i64,
26}
27
28impl I64Vec2 {
29 pub const ZERO: Self = Self::splat(0);
31
32 pub const ONE: Self = Self::splat(1);
34
35 pub const NEG_ONE: Self = Self::splat(-1);
37
38 pub const MIN: Self = Self::splat(i64::MIN);
40
41 pub const MAX: Self = Self::splat(i64::MAX);
43
44 pub const X: Self = Self::new(1, 0);
46
47 pub const Y: Self = Self::new(0, 1);
49
50 pub const NEG_X: Self = Self::new(-1, 0);
52
53 pub const NEG_Y: Self = Self::new(0, -1);
55
56 pub const AXES: [Self; 2] = [Self::X, Self::Y];
58
59 #[inline(always)]
61 #[must_use]
62 pub const fn new(x: i64, y: i64) -> Self {
63 Self { x, y }
64 }
65
66 #[inline]
68 #[must_use]
69 pub const fn splat(v: i64) -> Self {
70 Self { x: v, y: v }
71 }
72
73 #[inline]
79 #[must_use]
80 pub fn select(mask: BVec2, if_true: Self, if_false: Self) -> Self {
81 Self {
82 x: if mask.test(0) { if_true.x } else { if_false.x },
83 y: if mask.test(1) { if_true.y } else { if_false.y },
84 }
85 }
86
87 #[inline]
89 #[must_use]
90 pub const fn from_array(a: [i64; 2]) -> Self {
91 Self::new(a[0], a[1])
92 }
93
94 #[inline]
96 #[must_use]
97 pub const fn to_array(&self) -> [i64; 2] {
98 [self.x, self.y]
99 }
100
101 #[inline]
107 #[must_use]
108 pub const fn from_slice(slice: &[i64]) -> Self {
109 Self::new(slice[0], slice[1])
110 }
111
112 #[inline]
118 pub fn write_to_slice(self, slice: &mut [i64]) {
119 slice[0] = self.x;
120 slice[1] = self.y;
121 }
122
123 #[inline]
125 #[must_use]
126 pub const fn extend(self, z: i64) -> I64Vec3 {
127 I64Vec3::new(self.x, self.y, z)
128 }
129
130 #[inline]
132 #[must_use]
133 pub fn with_x(mut self, x: i64) -> Self {
134 self.x = x;
135 self
136 }
137
138 #[inline]
140 #[must_use]
141 pub fn with_y(mut self, y: i64) -> Self {
142 self.y = y;
143 self
144 }
145
146 #[inline]
148 #[must_use]
149 pub fn dot(self, rhs: Self) -> i64 {
150 (self.x * rhs.x) + (self.y * rhs.y)
151 }
152
153 #[inline]
155 #[must_use]
156 pub fn dot_into_vec(self, rhs: Self) -> Self {
157 Self::splat(self.dot(rhs))
158 }
159
160 #[inline]
164 #[must_use]
165 pub fn min(self, rhs: Self) -> Self {
166 Self {
167 x: self.x.min(rhs.x),
168 y: self.y.min(rhs.y),
169 }
170 }
171
172 #[inline]
176 #[must_use]
177 pub fn max(self, rhs: Self) -> Self {
178 Self {
179 x: self.x.max(rhs.x),
180 y: self.y.max(rhs.y),
181 }
182 }
183
184 #[inline]
192 #[must_use]
193 pub fn clamp(self, min: Self, max: Self) -> Self {
194 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
195 self.max(min).min(max)
196 }
197
198 #[inline]
202 #[must_use]
203 pub fn min_element(self) -> i64 {
204 self.x.min(self.y)
205 }
206
207 #[inline]
211 #[must_use]
212 pub fn max_element(self) -> i64 {
213 self.x.max(self.y)
214 }
215
216 #[inline]
220 #[must_use]
221 pub fn element_sum(self) -> i64 {
222 self.x + self.y
223 }
224
225 #[inline]
229 #[must_use]
230 pub fn element_product(self) -> i64 {
231 self.x * self.y
232 }
233
234 #[inline]
240 #[must_use]
241 pub fn cmpeq(self, rhs: Self) -> BVec2 {
242 BVec2::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y))
243 }
244
245 #[inline]
251 #[must_use]
252 pub fn cmpne(self, rhs: Self) -> BVec2 {
253 BVec2::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y))
254 }
255
256 #[inline]
262 #[must_use]
263 pub fn cmpge(self, rhs: Self) -> BVec2 {
264 BVec2::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y))
265 }
266
267 #[inline]
273 #[must_use]
274 pub fn cmpgt(self, rhs: Self) -> BVec2 {
275 BVec2::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y))
276 }
277
278 #[inline]
284 #[must_use]
285 pub fn cmple(self, rhs: Self) -> BVec2 {
286 BVec2::new(self.x.le(&rhs.x), self.y.le(&rhs.y))
287 }
288
289 #[inline]
295 #[must_use]
296 pub fn cmplt(self, rhs: Self) -> BVec2 {
297 BVec2::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y))
298 }
299
300 #[inline]
302 #[must_use]
303 pub fn abs(self) -> Self {
304 Self {
305 x: self.x.abs(),
306 y: self.y.abs(),
307 }
308 }
309
310 #[inline]
316 #[must_use]
317 pub fn signum(self) -> Self {
318 Self {
319 x: self.x.signum(),
320 y: self.y.signum(),
321 }
322 }
323
324 #[inline]
329 #[must_use]
330 pub fn is_negative_bitmask(self) -> u32 {
331 (self.x.is_negative() as u32) | (self.y.is_negative() as u32) << 1
332 }
333
334 #[doc(alias = "magnitude2")]
336 #[inline]
337 #[must_use]
338 pub fn length_squared(self) -> i64 {
339 self.dot(self)
340 }
341
342 #[inline]
344 #[must_use]
345 pub fn distance_squared(self, rhs: Self) -> i64 {
346 (self - rhs).length_squared()
347 }
348
349 #[inline]
354 #[must_use]
355 pub fn div_euclid(self, rhs: Self) -> Self {
356 Self::new(self.x.div_euclid(rhs.x), self.y.div_euclid(rhs.y))
357 }
358
359 #[inline]
366 #[must_use]
367 pub fn rem_euclid(self, rhs: Self) -> Self {
368 Self::new(self.x.rem_euclid(rhs.x), self.y.rem_euclid(rhs.y))
369 }
370
371 #[inline]
373 #[must_use]
374 pub fn perp(self) -> Self {
375 Self {
376 x: -self.y,
377 y: self.x,
378 }
379 }
380
381 #[doc(alias = "wedge")]
384 #[doc(alias = "cross")]
385 #[doc(alias = "determinant")]
386 #[inline]
387 #[must_use]
388 pub fn perp_dot(self, rhs: Self) -> i64 {
389 (self.x * rhs.y) - (self.y * rhs.x)
390 }
391
392 #[inline]
396 #[must_use]
397 pub fn rotate(self, rhs: Self) -> Self {
398 Self {
399 x: self.x * rhs.x - self.y * rhs.y,
400 y: self.y * rhs.x + self.x * rhs.y,
401 }
402 }
403
404 #[inline]
406 #[must_use]
407 pub fn as_vec2(&self) -> crate::Vec2 {
408 crate::Vec2::new(self.x as f32, self.y as f32)
409 }
410
411 #[inline]
413 #[must_use]
414 pub fn as_dvec2(&self) -> crate::DVec2 {
415 crate::DVec2::new(self.x as f64, self.y as f64)
416 }
417
418 #[inline]
420 #[must_use]
421 pub fn as_i16vec2(&self) -> crate::I16Vec2 {
422 crate::I16Vec2::new(self.x as i16, self.y as i16)
423 }
424
425 #[inline]
427 #[must_use]
428 pub fn as_u16vec2(&self) -> crate::U16Vec2 {
429 crate::U16Vec2::new(self.x as u16, self.y as u16)
430 }
431
432 #[inline]
434 #[must_use]
435 pub fn as_ivec2(&self) -> crate::IVec2 {
436 crate::IVec2::new(self.x as i32, self.y as i32)
437 }
438
439 #[inline]
441 #[must_use]
442 pub fn as_uvec2(&self) -> crate::UVec2 {
443 crate::UVec2::new(self.x as u32, self.y as u32)
444 }
445
446 #[inline]
448 #[must_use]
449 pub fn as_u64vec2(&self) -> crate::U64Vec2 {
450 crate::U64Vec2::new(self.x as u64, self.y as u64)
451 }
452
453 #[inline]
457 #[must_use]
458 pub const fn wrapping_add(self, rhs: Self) -> Self {
459 Self {
460 x: self.x.wrapping_add(rhs.x),
461 y: self.y.wrapping_add(rhs.y),
462 }
463 }
464
465 #[inline]
469 #[must_use]
470 pub const fn wrapping_sub(self, rhs: Self) -> Self {
471 Self {
472 x: self.x.wrapping_sub(rhs.x),
473 y: self.y.wrapping_sub(rhs.y),
474 }
475 }
476
477 #[inline]
481 #[must_use]
482 pub const fn wrapping_mul(self, rhs: Self) -> Self {
483 Self {
484 x: self.x.wrapping_mul(rhs.x),
485 y: self.y.wrapping_mul(rhs.y),
486 }
487 }
488
489 #[inline]
493 #[must_use]
494 pub const fn wrapping_div(self, rhs: Self) -> Self {
495 Self {
496 x: self.x.wrapping_div(rhs.x),
497 y: self.y.wrapping_div(rhs.y),
498 }
499 }
500
501 #[inline]
505 #[must_use]
506 pub const fn saturating_add(self, rhs: Self) -> Self {
507 Self {
508 x: self.x.saturating_add(rhs.x),
509 y: self.y.saturating_add(rhs.y),
510 }
511 }
512
513 #[inline]
517 #[must_use]
518 pub const fn saturating_sub(self, rhs: Self) -> Self {
519 Self {
520 x: self.x.saturating_sub(rhs.x),
521 y: self.y.saturating_sub(rhs.y),
522 }
523 }
524
525 #[inline]
529 #[must_use]
530 pub const fn saturating_mul(self, rhs: Self) -> Self {
531 Self {
532 x: self.x.saturating_mul(rhs.x),
533 y: self.y.saturating_mul(rhs.y),
534 }
535 }
536
537 #[inline]
541 #[must_use]
542 pub const fn saturating_div(self, rhs: Self) -> Self {
543 Self {
544 x: self.x.saturating_div(rhs.x),
545 y: self.y.saturating_div(rhs.y),
546 }
547 }
548
549 #[inline]
553 #[must_use]
554 pub const fn wrapping_add_unsigned(self, rhs: U64Vec2) -> Self {
555 Self {
556 x: self.x.wrapping_add_unsigned(rhs.x),
557 y: self.y.wrapping_add_unsigned(rhs.y),
558 }
559 }
560
561 #[inline]
565 #[must_use]
566 pub const fn wrapping_sub_unsigned(self, rhs: U64Vec2) -> Self {
567 Self {
568 x: self.x.wrapping_sub_unsigned(rhs.x),
569 y: self.y.wrapping_sub_unsigned(rhs.y),
570 }
571 }
572
573 #[inline]
577 #[must_use]
578 pub const fn saturating_add_unsigned(self, rhs: U64Vec2) -> Self {
579 Self {
580 x: self.x.saturating_add_unsigned(rhs.x),
581 y: self.y.saturating_add_unsigned(rhs.y),
582 }
583 }
584
585 #[inline]
589 #[must_use]
590 pub const fn saturating_sub_unsigned(self, rhs: U64Vec2) -> Self {
591 Self {
592 x: self.x.saturating_sub_unsigned(rhs.x),
593 y: self.y.saturating_sub_unsigned(rhs.y),
594 }
595 }
596}
597
598impl Default for I64Vec2 {
599 #[inline(always)]
600 fn default() -> Self {
601 Self::ZERO
602 }
603}
604
605impl Div<I64Vec2> for I64Vec2 {
606 type Output = Self;
607 #[inline]
608 fn div(self, rhs: Self) -> Self {
609 Self {
610 x: self.x.div(rhs.x),
611 y: self.y.div(rhs.y),
612 }
613 }
614}
615
616impl DivAssign<I64Vec2> for I64Vec2 {
617 #[inline]
618 fn div_assign(&mut self, rhs: Self) {
619 self.x.div_assign(rhs.x);
620 self.y.div_assign(rhs.y);
621 }
622}
623
624impl Div<i64> for I64Vec2 {
625 type Output = Self;
626 #[inline]
627 fn div(self, rhs: i64) -> Self {
628 Self {
629 x: self.x.div(rhs),
630 y: self.y.div(rhs),
631 }
632 }
633}
634
635impl DivAssign<i64> for I64Vec2 {
636 #[inline]
637 fn div_assign(&mut self, rhs: i64) {
638 self.x.div_assign(rhs);
639 self.y.div_assign(rhs);
640 }
641}
642
643impl Div<I64Vec2> for i64 {
644 type Output = I64Vec2;
645 #[inline]
646 fn div(self, rhs: I64Vec2) -> I64Vec2 {
647 I64Vec2 {
648 x: self.div(rhs.x),
649 y: self.div(rhs.y),
650 }
651 }
652}
653
654impl Mul<I64Vec2> for I64Vec2 {
655 type Output = Self;
656 #[inline]
657 fn mul(self, rhs: Self) -> Self {
658 Self {
659 x: self.x.mul(rhs.x),
660 y: self.y.mul(rhs.y),
661 }
662 }
663}
664
665impl MulAssign<I64Vec2> for I64Vec2 {
666 #[inline]
667 fn mul_assign(&mut self, rhs: Self) {
668 self.x.mul_assign(rhs.x);
669 self.y.mul_assign(rhs.y);
670 }
671}
672
673impl Mul<i64> for I64Vec2 {
674 type Output = Self;
675 #[inline]
676 fn mul(self, rhs: i64) -> Self {
677 Self {
678 x: self.x.mul(rhs),
679 y: self.y.mul(rhs),
680 }
681 }
682}
683
684impl MulAssign<i64> for I64Vec2 {
685 #[inline]
686 fn mul_assign(&mut self, rhs: i64) {
687 self.x.mul_assign(rhs);
688 self.y.mul_assign(rhs);
689 }
690}
691
692impl Mul<I64Vec2> for i64 {
693 type Output = I64Vec2;
694 #[inline]
695 fn mul(self, rhs: I64Vec2) -> I64Vec2 {
696 I64Vec2 {
697 x: self.mul(rhs.x),
698 y: self.mul(rhs.y),
699 }
700 }
701}
702
703impl Add<I64Vec2> for I64Vec2 {
704 type Output = Self;
705 #[inline]
706 fn add(self, rhs: Self) -> Self {
707 Self {
708 x: self.x.add(rhs.x),
709 y: self.y.add(rhs.y),
710 }
711 }
712}
713
714impl AddAssign<I64Vec2> for I64Vec2 {
715 #[inline]
716 fn add_assign(&mut self, rhs: Self) {
717 self.x.add_assign(rhs.x);
718 self.y.add_assign(rhs.y);
719 }
720}
721
722impl Add<i64> for I64Vec2 {
723 type Output = Self;
724 #[inline]
725 fn add(self, rhs: i64) -> Self {
726 Self {
727 x: self.x.add(rhs),
728 y: self.y.add(rhs),
729 }
730 }
731}
732
733impl AddAssign<i64> for I64Vec2 {
734 #[inline]
735 fn add_assign(&mut self, rhs: i64) {
736 self.x.add_assign(rhs);
737 self.y.add_assign(rhs);
738 }
739}
740
741impl Add<I64Vec2> for i64 {
742 type Output = I64Vec2;
743 #[inline]
744 fn add(self, rhs: I64Vec2) -> I64Vec2 {
745 I64Vec2 {
746 x: self.add(rhs.x),
747 y: self.add(rhs.y),
748 }
749 }
750}
751
752impl Sub<I64Vec2> for I64Vec2 {
753 type Output = Self;
754 #[inline]
755 fn sub(self, rhs: Self) -> Self {
756 Self {
757 x: self.x.sub(rhs.x),
758 y: self.y.sub(rhs.y),
759 }
760 }
761}
762
763impl SubAssign<I64Vec2> for I64Vec2 {
764 #[inline]
765 fn sub_assign(&mut self, rhs: I64Vec2) {
766 self.x.sub_assign(rhs.x);
767 self.y.sub_assign(rhs.y);
768 }
769}
770
771impl Sub<i64> for I64Vec2 {
772 type Output = Self;
773 #[inline]
774 fn sub(self, rhs: i64) -> Self {
775 Self {
776 x: self.x.sub(rhs),
777 y: self.y.sub(rhs),
778 }
779 }
780}
781
782impl SubAssign<i64> for I64Vec2 {
783 #[inline]
784 fn sub_assign(&mut self, rhs: i64) {
785 self.x.sub_assign(rhs);
786 self.y.sub_assign(rhs);
787 }
788}
789
790impl Sub<I64Vec2> for i64 {
791 type Output = I64Vec2;
792 #[inline]
793 fn sub(self, rhs: I64Vec2) -> I64Vec2 {
794 I64Vec2 {
795 x: self.sub(rhs.x),
796 y: self.sub(rhs.y),
797 }
798 }
799}
800
801impl Rem<I64Vec2> for I64Vec2 {
802 type Output = Self;
803 #[inline]
804 fn rem(self, rhs: Self) -> Self {
805 Self {
806 x: self.x.rem(rhs.x),
807 y: self.y.rem(rhs.y),
808 }
809 }
810}
811
812impl RemAssign<I64Vec2> for I64Vec2 {
813 #[inline]
814 fn rem_assign(&mut self, rhs: Self) {
815 self.x.rem_assign(rhs.x);
816 self.y.rem_assign(rhs.y);
817 }
818}
819
820impl Rem<i64> for I64Vec2 {
821 type Output = Self;
822 #[inline]
823 fn rem(self, rhs: i64) -> Self {
824 Self {
825 x: self.x.rem(rhs),
826 y: self.y.rem(rhs),
827 }
828 }
829}
830
831impl RemAssign<i64> for I64Vec2 {
832 #[inline]
833 fn rem_assign(&mut self, rhs: i64) {
834 self.x.rem_assign(rhs);
835 self.y.rem_assign(rhs);
836 }
837}
838
839impl Rem<I64Vec2> for i64 {
840 type Output = I64Vec2;
841 #[inline]
842 fn rem(self, rhs: I64Vec2) -> I64Vec2 {
843 I64Vec2 {
844 x: self.rem(rhs.x),
845 y: self.rem(rhs.y),
846 }
847 }
848}
849
850#[cfg(not(target_arch = "spirv"))]
851impl AsRef<[i64; 2]> for I64Vec2 {
852 #[inline]
853 fn as_ref(&self) -> &[i64; 2] {
854 unsafe { &*(self as *const I64Vec2 as *const [i64; 2]) }
855 }
856}
857
858#[cfg(not(target_arch = "spirv"))]
859impl AsMut<[i64; 2]> for I64Vec2 {
860 #[inline]
861 fn as_mut(&mut self) -> &mut [i64; 2] {
862 unsafe { &mut *(self as *mut I64Vec2 as *mut [i64; 2]) }
863 }
864}
865
866impl Sum for I64Vec2 {
867 #[inline]
868 fn sum<I>(iter: I) -> Self
869 where
870 I: Iterator<Item = Self>,
871 {
872 iter.fold(Self::ZERO, Self::add)
873 }
874}
875
876impl<'a> Sum<&'a Self> for I64Vec2 {
877 #[inline]
878 fn sum<I>(iter: I) -> Self
879 where
880 I: Iterator<Item = &'a Self>,
881 {
882 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
883 }
884}
885
886impl Product for I64Vec2 {
887 #[inline]
888 fn product<I>(iter: I) -> Self
889 where
890 I: Iterator<Item = Self>,
891 {
892 iter.fold(Self::ONE, Self::mul)
893 }
894}
895
896impl<'a> Product<&'a Self> for I64Vec2 {
897 #[inline]
898 fn product<I>(iter: I) -> Self
899 where
900 I: Iterator<Item = &'a Self>,
901 {
902 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
903 }
904}
905
906impl Neg for I64Vec2 {
907 type Output = Self;
908 #[inline]
909 fn neg(self) -> Self {
910 Self {
911 x: self.x.neg(),
912 y: self.y.neg(),
913 }
914 }
915}
916
917impl Not for I64Vec2 {
918 type Output = Self;
919 #[inline]
920 fn not(self) -> Self::Output {
921 Self {
922 x: self.x.not(),
923 y: self.y.not(),
924 }
925 }
926}
927
928impl BitAnd for I64Vec2 {
929 type Output = Self;
930 #[inline]
931 fn bitand(self, rhs: Self) -> Self::Output {
932 Self {
933 x: self.x.bitand(rhs.x),
934 y: self.y.bitand(rhs.y),
935 }
936 }
937}
938
939impl BitOr for I64Vec2 {
940 type Output = Self;
941 #[inline]
942 fn bitor(self, rhs: Self) -> Self::Output {
943 Self {
944 x: self.x.bitor(rhs.x),
945 y: self.y.bitor(rhs.y),
946 }
947 }
948}
949
950impl BitXor for I64Vec2 {
951 type Output = Self;
952 #[inline]
953 fn bitxor(self, rhs: Self) -> Self::Output {
954 Self {
955 x: self.x.bitxor(rhs.x),
956 y: self.y.bitxor(rhs.y),
957 }
958 }
959}
960
961impl BitAnd<i64> for I64Vec2 {
962 type Output = Self;
963 #[inline]
964 fn bitand(self, rhs: i64) -> Self::Output {
965 Self {
966 x: self.x.bitand(rhs),
967 y: self.y.bitand(rhs),
968 }
969 }
970}
971
972impl BitOr<i64> for I64Vec2 {
973 type Output = Self;
974 #[inline]
975 fn bitor(self, rhs: i64) -> Self::Output {
976 Self {
977 x: self.x.bitor(rhs),
978 y: self.y.bitor(rhs),
979 }
980 }
981}
982
983impl BitXor<i64> for I64Vec2 {
984 type Output = Self;
985 #[inline]
986 fn bitxor(self, rhs: i64) -> Self::Output {
987 Self {
988 x: self.x.bitxor(rhs),
989 y: self.y.bitxor(rhs),
990 }
991 }
992}
993
994impl Shl<i8> for I64Vec2 {
995 type Output = Self;
996 #[inline]
997 fn shl(self, rhs: i8) -> Self::Output {
998 Self {
999 x: self.x.shl(rhs),
1000 y: self.y.shl(rhs),
1001 }
1002 }
1003}
1004
1005impl Shr<i8> for I64Vec2 {
1006 type Output = Self;
1007 #[inline]
1008 fn shr(self, rhs: i8) -> Self::Output {
1009 Self {
1010 x: self.x.shr(rhs),
1011 y: self.y.shr(rhs),
1012 }
1013 }
1014}
1015
1016impl Shl<i16> for I64Vec2 {
1017 type Output = Self;
1018 #[inline]
1019 fn shl(self, rhs: i16) -> Self::Output {
1020 Self {
1021 x: self.x.shl(rhs),
1022 y: self.y.shl(rhs),
1023 }
1024 }
1025}
1026
1027impl Shr<i16> for I64Vec2 {
1028 type Output = Self;
1029 #[inline]
1030 fn shr(self, rhs: i16) -> Self::Output {
1031 Self {
1032 x: self.x.shr(rhs),
1033 y: self.y.shr(rhs),
1034 }
1035 }
1036}
1037
1038impl Shl<i32> for I64Vec2 {
1039 type Output = Self;
1040 #[inline]
1041 fn shl(self, rhs: i32) -> Self::Output {
1042 Self {
1043 x: self.x.shl(rhs),
1044 y: self.y.shl(rhs),
1045 }
1046 }
1047}
1048
1049impl Shr<i32> for I64Vec2 {
1050 type Output = Self;
1051 #[inline]
1052 fn shr(self, rhs: i32) -> Self::Output {
1053 Self {
1054 x: self.x.shr(rhs),
1055 y: self.y.shr(rhs),
1056 }
1057 }
1058}
1059
1060impl Shl<i64> for I64Vec2 {
1061 type Output = Self;
1062 #[inline]
1063 fn shl(self, rhs: i64) -> Self::Output {
1064 Self {
1065 x: self.x.shl(rhs),
1066 y: self.y.shl(rhs),
1067 }
1068 }
1069}
1070
1071impl Shr<i64> for I64Vec2 {
1072 type Output = Self;
1073 #[inline]
1074 fn shr(self, rhs: i64) -> Self::Output {
1075 Self {
1076 x: self.x.shr(rhs),
1077 y: self.y.shr(rhs),
1078 }
1079 }
1080}
1081
1082impl Shl<u8> for I64Vec2 {
1083 type Output = Self;
1084 #[inline]
1085 fn shl(self, rhs: u8) -> Self::Output {
1086 Self {
1087 x: self.x.shl(rhs),
1088 y: self.y.shl(rhs),
1089 }
1090 }
1091}
1092
1093impl Shr<u8> for I64Vec2 {
1094 type Output = Self;
1095 #[inline]
1096 fn shr(self, rhs: u8) -> Self::Output {
1097 Self {
1098 x: self.x.shr(rhs),
1099 y: self.y.shr(rhs),
1100 }
1101 }
1102}
1103
1104impl Shl<u16> for I64Vec2 {
1105 type Output = Self;
1106 #[inline]
1107 fn shl(self, rhs: u16) -> Self::Output {
1108 Self {
1109 x: self.x.shl(rhs),
1110 y: self.y.shl(rhs),
1111 }
1112 }
1113}
1114
1115impl Shr<u16> for I64Vec2 {
1116 type Output = Self;
1117 #[inline]
1118 fn shr(self, rhs: u16) -> Self::Output {
1119 Self {
1120 x: self.x.shr(rhs),
1121 y: self.y.shr(rhs),
1122 }
1123 }
1124}
1125
1126impl Shl<u32> for I64Vec2 {
1127 type Output = Self;
1128 #[inline]
1129 fn shl(self, rhs: u32) -> Self::Output {
1130 Self {
1131 x: self.x.shl(rhs),
1132 y: self.y.shl(rhs),
1133 }
1134 }
1135}
1136
1137impl Shr<u32> for I64Vec2 {
1138 type Output = Self;
1139 #[inline]
1140 fn shr(self, rhs: u32) -> Self::Output {
1141 Self {
1142 x: self.x.shr(rhs),
1143 y: self.y.shr(rhs),
1144 }
1145 }
1146}
1147
1148impl Shl<u64> for I64Vec2 {
1149 type Output = Self;
1150 #[inline]
1151 fn shl(self, rhs: u64) -> Self::Output {
1152 Self {
1153 x: self.x.shl(rhs),
1154 y: self.y.shl(rhs),
1155 }
1156 }
1157}
1158
1159impl Shr<u64> for I64Vec2 {
1160 type Output = Self;
1161 #[inline]
1162 fn shr(self, rhs: u64) -> Self::Output {
1163 Self {
1164 x: self.x.shr(rhs),
1165 y: self.y.shr(rhs),
1166 }
1167 }
1168}
1169
1170impl Shl<crate::IVec2> for I64Vec2 {
1171 type Output = Self;
1172 #[inline]
1173 fn shl(self, rhs: crate::IVec2) -> Self::Output {
1174 Self {
1175 x: self.x.shl(rhs.x),
1176 y: self.y.shl(rhs.y),
1177 }
1178 }
1179}
1180
1181impl Shr<crate::IVec2> for I64Vec2 {
1182 type Output = Self;
1183 #[inline]
1184 fn shr(self, rhs: crate::IVec2) -> Self::Output {
1185 Self {
1186 x: self.x.shr(rhs.x),
1187 y: self.y.shr(rhs.y),
1188 }
1189 }
1190}
1191
1192impl Shl<crate::UVec2> for I64Vec2 {
1193 type Output = Self;
1194 #[inline]
1195 fn shl(self, rhs: crate::UVec2) -> Self::Output {
1196 Self {
1197 x: self.x.shl(rhs.x),
1198 y: self.y.shl(rhs.y),
1199 }
1200 }
1201}
1202
1203impl Shr<crate::UVec2> for I64Vec2 {
1204 type Output = Self;
1205 #[inline]
1206 fn shr(self, rhs: crate::UVec2) -> Self::Output {
1207 Self {
1208 x: self.x.shr(rhs.x),
1209 y: self.y.shr(rhs.y),
1210 }
1211 }
1212}
1213
1214impl Index<usize> for I64Vec2 {
1215 type Output = i64;
1216 #[inline]
1217 fn index(&self, index: usize) -> &Self::Output {
1218 match index {
1219 0 => &self.x,
1220 1 => &self.y,
1221 _ => panic!("index out of bounds"),
1222 }
1223 }
1224}
1225
1226impl IndexMut<usize> for I64Vec2 {
1227 #[inline]
1228 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1229 match index {
1230 0 => &mut self.x,
1231 1 => &mut self.y,
1232 _ => panic!("index out of bounds"),
1233 }
1234 }
1235}
1236
1237#[cfg(not(target_arch = "spirv"))]
1238impl fmt::Display for I64Vec2 {
1239 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1240 write!(f, "[{}, {}]", self.x, self.y)
1241 }
1242}
1243
1244#[cfg(not(target_arch = "spirv"))]
1245impl fmt::Debug for I64Vec2 {
1246 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1247 fmt.debug_tuple(stringify!(I64Vec2))
1248 .field(&self.x)
1249 .field(&self.y)
1250 .finish()
1251 }
1252}
1253
1254impl From<[i64; 2]> for I64Vec2 {
1255 #[inline]
1256 fn from(a: [i64; 2]) -> Self {
1257 Self::new(a[0], a[1])
1258 }
1259}
1260
1261impl From<I64Vec2> for [i64; 2] {
1262 #[inline]
1263 fn from(v: I64Vec2) -> Self {
1264 [v.x, v.y]
1265 }
1266}
1267
1268impl From<(i64, i64)> for I64Vec2 {
1269 #[inline]
1270 fn from(t: (i64, i64)) -> Self {
1271 Self::new(t.0, t.1)
1272 }
1273}
1274
1275impl From<I64Vec2> for (i64, i64) {
1276 #[inline]
1277 fn from(v: I64Vec2) -> Self {
1278 (v.x, v.y)
1279 }
1280}
1281
1282impl From<I16Vec2> for I64Vec2 {
1283 #[inline]
1284 fn from(v: I16Vec2) -> Self {
1285 Self::new(i64::from(v.x), i64::from(v.y))
1286 }
1287}
1288
1289impl From<U16Vec2> for I64Vec2 {
1290 #[inline]
1291 fn from(v: U16Vec2) -> Self {
1292 Self::new(i64::from(v.x), i64::from(v.y))
1293 }
1294}
1295
1296impl From<IVec2> for I64Vec2 {
1297 #[inline]
1298 fn from(v: IVec2) -> Self {
1299 Self::new(i64::from(v.x), i64::from(v.y))
1300 }
1301}
1302
1303impl From<UVec2> for I64Vec2 {
1304 #[inline]
1305 fn from(v: UVec2) -> Self {
1306 Self::new(i64::from(v.x), i64::from(v.y))
1307 }
1308}
1309
1310impl TryFrom<U64Vec2> for I64Vec2 {
1311 type Error = core::num::TryFromIntError;
1312
1313 #[inline]
1314 fn try_from(v: U64Vec2) -> Result<Self, Self::Error> {
1315 Ok(Self::new(i64::try_from(v.x)?, i64::try_from(v.y)?))
1316 }
1317}
1318
1319impl From<BVec2> for I64Vec2 {
1320 #[inline]
1321 fn from(v: BVec2) -> Self {
1322 Self::new(i64::from(v.x), i64::from(v.y))
1323 }
1324}