1use crate::{
4 BVec3, BVec3A, I16Vec2, I16Vec4, I64Vec3, I8Vec3, IVec3, U16Vec3, U64Vec3, U8Vec3, UVec3,
5};
6
7use core::fmt;
8use core::iter::{Product, Sum};
9use core::{f32, ops::*};
10
11#[inline(always)]
13#[must_use]
14pub const fn i16vec3(x: i16, y: i16, z: i16) -> I16Vec3 {
15 I16Vec3::new(x, y, z)
16}
17
18#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
20#[derive(Clone, Copy, PartialEq, Eq)]
21#[cfg_attr(not(target_arch = "spirv"), repr(C))]
22#[cfg_attr(target_arch = "spirv", repr(simd))]
23pub struct I16Vec3 {
24 pub x: i16,
25 pub y: i16,
26 pub z: i16,
27}
28
29impl I16Vec3 {
30 pub const ZERO: Self = Self::splat(0);
32
33 pub const ONE: Self = Self::splat(1);
35
36 pub const NEG_ONE: Self = Self::splat(-1);
38
39 pub const MIN: Self = Self::splat(i16::MIN);
41
42 pub const MAX: Self = Self::splat(i16::MAX);
44
45 pub const X: Self = Self::new(1, 0, 0);
47
48 pub const Y: Self = Self::new(0, 1, 0);
50
51 pub const Z: Self = Self::new(0, 0, 1);
53
54 pub const NEG_X: Self = Self::new(-1, 0, 0);
56
57 pub const NEG_Y: Self = Self::new(0, -1, 0);
59
60 pub const NEG_Z: Self = Self::new(0, 0, -1);
62
63 pub const AXES: [Self; 3] = [Self::X, Self::Y, Self::Z];
65
66 #[inline(always)]
68 #[must_use]
69 pub const fn new(x: i16, y: i16, z: i16) -> Self {
70 Self { x, y, z }
71 }
72
73 #[inline]
75 #[must_use]
76 pub const fn splat(v: i16) -> Self {
77 Self { x: v, y: v, z: v }
78 }
79
80 #[inline]
82 #[must_use]
83 pub fn map<F>(self, f: F) -> Self
84 where
85 F: Fn(i16) -> i16,
86 {
87 Self::new(f(self.x), f(self.y), f(self.z))
88 }
89
90 #[inline]
96 #[must_use]
97 pub fn select(mask: BVec3, if_true: Self, if_false: Self) -> Self {
98 Self {
99 x: if mask.test(0) { if_true.x } else { if_false.x },
100 y: if mask.test(1) { if_true.y } else { if_false.y },
101 z: if mask.test(2) { if_true.z } else { if_false.z },
102 }
103 }
104
105 #[inline]
107 #[must_use]
108 pub const fn from_array(a: [i16; 3]) -> Self {
109 Self::new(a[0], a[1], a[2])
110 }
111
112 #[inline]
114 #[must_use]
115 pub const fn to_array(&self) -> [i16; 3] {
116 [self.x, self.y, self.z]
117 }
118
119 #[inline]
125 #[must_use]
126 pub const fn from_slice(slice: &[i16]) -> Self {
127 assert!(slice.len() >= 3);
128 Self::new(slice[0], slice[1], slice[2])
129 }
130
131 #[inline]
137 pub fn write_to_slice(self, slice: &mut [i16]) {
138 slice[..3].copy_from_slice(&self.to_array());
139 }
140
141 #[allow(dead_code)]
143 #[inline]
144 #[must_use]
145 pub(crate) fn from_vec4(v: I16Vec4) -> Self {
146 Self {
147 x: v.x,
148 y: v.y,
149 z: v.z,
150 }
151 }
152
153 #[inline]
155 #[must_use]
156 pub fn extend(self, w: i16) -> I16Vec4 {
157 I16Vec4::new(self.x, self.y, self.z, w)
158 }
159
160 #[inline]
164 #[must_use]
165 pub fn truncate(self) -> I16Vec2 {
166 use crate::swizzles::Vec3Swizzles;
167 self.xy()
168 }
169
170 #[inline]
172 #[must_use]
173 pub fn with_x(mut self, x: i16) -> Self {
174 self.x = x;
175 self
176 }
177
178 #[inline]
180 #[must_use]
181 pub fn with_y(mut self, y: i16) -> Self {
182 self.y = y;
183 self
184 }
185
186 #[inline]
188 #[must_use]
189 pub fn with_z(mut self, z: i16) -> Self {
190 self.z = z;
191 self
192 }
193
194 #[inline]
196 #[must_use]
197 pub fn dot(self, rhs: Self) -> i16 {
198 (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z)
199 }
200
201 #[inline]
203 #[must_use]
204 pub fn dot_into_vec(self, rhs: Self) -> Self {
205 Self::splat(self.dot(rhs))
206 }
207
208 #[inline]
210 #[must_use]
211 pub fn cross(self, rhs: Self) -> Self {
212 Self {
213 x: self.y * rhs.z - rhs.y * self.z,
214 y: self.z * rhs.x - rhs.z * self.x,
215 z: self.x * rhs.y - rhs.x * self.y,
216 }
217 }
218
219 #[inline]
223 #[must_use]
224 pub fn min(self, rhs: Self) -> Self {
225 Self {
226 x: self.x.min(rhs.x),
227 y: self.y.min(rhs.y),
228 z: self.z.min(rhs.z),
229 }
230 }
231
232 #[inline]
236 #[must_use]
237 pub fn max(self, rhs: Self) -> Self {
238 Self {
239 x: self.x.max(rhs.x),
240 y: self.y.max(rhs.y),
241 z: self.z.max(rhs.z),
242 }
243 }
244
245 #[inline]
253 #[must_use]
254 pub fn clamp(self, min: Self, max: Self) -> Self {
255 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
256 self.max(min).min(max)
257 }
258
259 #[inline]
263 #[must_use]
264 pub fn min_element(self) -> i16 {
265 self.x.min(self.y.min(self.z))
266 }
267
268 #[inline]
272 #[must_use]
273 pub fn max_element(self) -> i16 {
274 self.x.max(self.y.max(self.z))
275 }
276
277 #[inline]
281 #[must_use]
282 pub fn element_sum(self) -> i16 {
283 self.x + self.y + self.z
284 }
285
286 #[inline]
290 #[must_use]
291 pub fn element_product(self) -> i16 {
292 self.x * self.y * self.z
293 }
294
295 #[inline]
301 #[must_use]
302 pub fn cmpeq(self, rhs: Self) -> BVec3 {
303 BVec3::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y), self.z.eq(&rhs.z))
304 }
305
306 #[inline]
312 #[must_use]
313 pub fn cmpne(self, rhs: Self) -> BVec3 {
314 BVec3::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y), self.z.ne(&rhs.z))
315 }
316
317 #[inline]
323 #[must_use]
324 pub fn cmpge(self, rhs: Self) -> BVec3 {
325 BVec3::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y), self.z.ge(&rhs.z))
326 }
327
328 #[inline]
334 #[must_use]
335 pub fn cmpgt(self, rhs: Self) -> BVec3 {
336 BVec3::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y), self.z.gt(&rhs.z))
337 }
338
339 #[inline]
345 #[must_use]
346 pub fn cmple(self, rhs: Self) -> BVec3 {
347 BVec3::new(self.x.le(&rhs.x), self.y.le(&rhs.y), self.z.le(&rhs.z))
348 }
349
350 #[inline]
356 #[must_use]
357 pub fn cmplt(self, rhs: Self) -> BVec3 {
358 BVec3::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y), self.z.lt(&rhs.z))
359 }
360
361 #[inline]
363 #[must_use]
364 pub fn abs(self) -> Self {
365 Self {
366 x: self.x.abs(),
367 y: self.y.abs(),
368 z: self.z.abs(),
369 }
370 }
371
372 #[inline]
378 #[must_use]
379 pub fn signum(self) -> Self {
380 Self {
381 x: self.x.signum(),
382 y: self.y.signum(),
383 z: self.z.signum(),
384 }
385 }
386
387 #[inline]
392 #[must_use]
393 pub fn is_negative_bitmask(self) -> u32 {
394 (self.x.is_negative() as u32)
395 | (self.y.is_negative() as u32) << 1
396 | (self.z.is_negative() as u32) << 2
397 }
398
399 #[doc(alias = "magnitude2")]
401 #[inline]
402 #[must_use]
403 pub fn length_squared(self) -> i16 {
404 self.dot(self)
405 }
406
407 #[inline]
409 #[must_use]
410 pub fn distance_squared(self, rhs: Self) -> i16 {
411 (self - rhs).length_squared()
412 }
413
414 #[inline]
419 #[must_use]
420 pub fn div_euclid(self, rhs: Self) -> Self {
421 Self::new(
422 self.x.div_euclid(rhs.x),
423 self.y.div_euclid(rhs.y),
424 self.z.div_euclid(rhs.z),
425 )
426 }
427
428 #[inline]
435 #[must_use]
436 pub fn rem_euclid(self, rhs: Self) -> Self {
437 Self::new(
438 self.x.rem_euclid(rhs.x),
439 self.y.rem_euclid(rhs.y),
440 self.z.rem_euclid(rhs.z),
441 )
442 }
443
444 #[inline]
446 #[must_use]
447 pub fn as_vec3(&self) -> crate::Vec3 {
448 crate::Vec3::new(self.x as f32, self.y as f32, self.z as f32)
449 }
450
451 #[inline]
453 #[must_use]
454 pub fn as_vec3a(&self) -> crate::Vec3A {
455 crate::Vec3A::new(self.x as f32, self.y as f32, self.z as f32)
456 }
457
458 #[inline]
460 #[must_use]
461 pub fn as_dvec3(&self) -> crate::DVec3 {
462 crate::DVec3::new(self.x as f64, self.y as f64, self.z as f64)
463 }
464
465 #[inline]
467 #[must_use]
468 pub fn as_i8vec3(&self) -> crate::I8Vec3 {
469 crate::I8Vec3::new(self.x as i8, self.y as i8, self.z as i8)
470 }
471
472 #[inline]
474 #[must_use]
475 pub fn as_u8vec3(&self) -> crate::U8Vec3 {
476 crate::U8Vec3::new(self.x as u8, self.y as u8, self.z as u8)
477 }
478
479 #[inline]
481 #[must_use]
482 pub fn as_u16vec3(&self) -> crate::U16Vec3 {
483 crate::U16Vec3::new(self.x as u16, self.y as u16, self.z as u16)
484 }
485
486 #[inline]
488 #[must_use]
489 pub fn as_ivec3(&self) -> crate::IVec3 {
490 crate::IVec3::new(self.x as i32, self.y as i32, self.z as i32)
491 }
492
493 #[inline]
495 #[must_use]
496 pub fn as_uvec3(&self) -> crate::UVec3 {
497 crate::UVec3::new(self.x as u32, self.y as u32, self.z as u32)
498 }
499
500 #[inline]
502 #[must_use]
503 pub fn as_i64vec3(&self) -> crate::I64Vec3 {
504 crate::I64Vec3::new(self.x as i64, self.y as i64, self.z as i64)
505 }
506
507 #[inline]
509 #[must_use]
510 pub fn as_u64vec3(&self) -> crate::U64Vec3 {
511 crate::U64Vec3::new(self.x as u64, self.y as u64, self.z as u64)
512 }
513
514 #[inline]
518 #[must_use]
519 pub const fn wrapping_add(self, rhs: Self) -> Self {
520 Self {
521 x: self.x.wrapping_add(rhs.x),
522 y: self.y.wrapping_add(rhs.y),
523 z: self.z.wrapping_add(rhs.z),
524 }
525 }
526
527 #[inline]
531 #[must_use]
532 pub const fn wrapping_sub(self, rhs: Self) -> Self {
533 Self {
534 x: self.x.wrapping_sub(rhs.x),
535 y: self.y.wrapping_sub(rhs.y),
536 z: self.z.wrapping_sub(rhs.z),
537 }
538 }
539
540 #[inline]
544 #[must_use]
545 pub const fn wrapping_mul(self, rhs: Self) -> Self {
546 Self {
547 x: self.x.wrapping_mul(rhs.x),
548 y: self.y.wrapping_mul(rhs.y),
549 z: self.z.wrapping_mul(rhs.z),
550 }
551 }
552
553 #[inline]
557 #[must_use]
558 pub const fn wrapping_div(self, rhs: Self) -> Self {
559 Self {
560 x: self.x.wrapping_div(rhs.x),
561 y: self.y.wrapping_div(rhs.y),
562 z: self.z.wrapping_div(rhs.z),
563 }
564 }
565
566 #[inline]
570 #[must_use]
571 pub const fn saturating_add(self, rhs: Self) -> Self {
572 Self {
573 x: self.x.saturating_add(rhs.x),
574 y: self.y.saturating_add(rhs.y),
575 z: self.z.saturating_add(rhs.z),
576 }
577 }
578
579 #[inline]
583 #[must_use]
584 pub const fn saturating_sub(self, rhs: Self) -> Self {
585 Self {
586 x: self.x.saturating_sub(rhs.x),
587 y: self.y.saturating_sub(rhs.y),
588 z: self.z.saturating_sub(rhs.z),
589 }
590 }
591
592 #[inline]
596 #[must_use]
597 pub const fn saturating_mul(self, rhs: Self) -> Self {
598 Self {
599 x: self.x.saturating_mul(rhs.x),
600 y: self.y.saturating_mul(rhs.y),
601 z: self.z.saturating_mul(rhs.z),
602 }
603 }
604
605 #[inline]
609 #[must_use]
610 pub const fn saturating_div(self, rhs: Self) -> Self {
611 Self {
612 x: self.x.saturating_div(rhs.x),
613 y: self.y.saturating_div(rhs.y),
614 z: self.z.saturating_div(rhs.z),
615 }
616 }
617
618 #[inline]
622 #[must_use]
623 pub const fn wrapping_add_unsigned(self, rhs: U16Vec3) -> Self {
624 Self {
625 x: self.x.wrapping_add_unsigned(rhs.x),
626 y: self.y.wrapping_add_unsigned(rhs.y),
627 z: self.z.wrapping_add_unsigned(rhs.z),
628 }
629 }
630
631 #[inline]
635 #[must_use]
636 pub const fn wrapping_sub_unsigned(self, rhs: U16Vec3) -> Self {
637 Self {
638 x: self.x.wrapping_sub_unsigned(rhs.x),
639 y: self.y.wrapping_sub_unsigned(rhs.y),
640 z: self.z.wrapping_sub_unsigned(rhs.z),
641 }
642 }
643
644 #[inline]
648 #[must_use]
649 pub const fn saturating_add_unsigned(self, rhs: U16Vec3) -> Self {
650 Self {
651 x: self.x.saturating_add_unsigned(rhs.x),
652 y: self.y.saturating_add_unsigned(rhs.y),
653 z: self.z.saturating_add_unsigned(rhs.z),
654 }
655 }
656
657 #[inline]
661 #[must_use]
662 pub const fn saturating_sub_unsigned(self, rhs: U16Vec3) -> Self {
663 Self {
664 x: self.x.saturating_sub_unsigned(rhs.x),
665 y: self.y.saturating_sub_unsigned(rhs.y),
666 z: self.z.saturating_sub_unsigned(rhs.z),
667 }
668 }
669}
670
671impl Default for I16Vec3 {
672 #[inline(always)]
673 fn default() -> Self {
674 Self::ZERO
675 }
676}
677
678impl Div<I16Vec3> for I16Vec3 {
679 type Output = Self;
680 #[inline]
681 fn div(self, rhs: Self) -> Self {
682 Self {
683 x: self.x.div(rhs.x),
684 y: self.y.div(rhs.y),
685 z: self.z.div(rhs.z),
686 }
687 }
688}
689
690impl Div<&I16Vec3> for I16Vec3 {
691 type Output = I16Vec3;
692 #[inline]
693 fn div(self, rhs: &I16Vec3) -> I16Vec3 {
694 self.div(*rhs)
695 }
696}
697
698impl Div<&I16Vec3> for &I16Vec3 {
699 type Output = I16Vec3;
700 #[inline]
701 fn div(self, rhs: &I16Vec3) -> I16Vec3 {
702 (*self).div(*rhs)
703 }
704}
705
706impl Div<I16Vec3> for &I16Vec3 {
707 type Output = I16Vec3;
708 #[inline]
709 fn div(self, rhs: I16Vec3) -> I16Vec3 {
710 (*self).div(rhs)
711 }
712}
713
714impl DivAssign<I16Vec3> for I16Vec3 {
715 #[inline]
716 fn div_assign(&mut self, rhs: Self) {
717 self.x.div_assign(rhs.x);
718 self.y.div_assign(rhs.y);
719 self.z.div_assign(rhs.z);
720 }
721}
722
723impl DivAssign<&Self> for I16Vec3 {
724 #[inline]
725 fn div_assign(&mut self, rhs: &Self) {
726 self.div_assign(*rhs)
727 }
728}
729
730impl Div<i16> for I16Vec3 {
731 type Output = Self;
732 #[inline]
733 fn div(self, rhs: i16) -> Self {
734 Self {
735 x: self.x.div(rhs),
736 y: self.y.div(rhs),
737 z: self.z.div(rhs),
738 }
739 }
740}
741
742impl Div<&i16> for I16Vec3 {
743 type Output = I16Vec3;
744 #[inline]
745 fn div(self, rhs: &i16) -> I16Vec3 {
746 self.div(*rhs)
747 }
748}
749
750impl Div<&i16> for &I16Vec3 {
751 type Output = I16Vec3;
752 #[inline]
753 fn div(self, rhs: &i16) -> I16Vec3 {
754 (*self).div(*rhs)
755 }
756}
757
758impl Div<i16> for &I16Vec3 {
759 type Output = I16Vec3;
760 #[inline]
761 fn div(self, rhs: i16) -> I16Vec3 {
762 (*self).div(rhs)
763 }
764}
765
766impl DivAssign<i16> for I16Vec3 {
767 #[inline]
768 fn div_assign(&mut self, rhs: i16) {
769 self.x.div_assign(rhs);
770 self.y.div_assign(rhs);
771 self.z.div_assign(rhs);
772 }
773}
774
775impl DivAssign<&i16> for I16Vec3 {
776 #[inline]
777 fn div_assign(&mut self, rhs: &i16) {
778 self.div_assign(*rhs)
779 }
780}
781
782impl Div<I16Vec3> for i16 {
783 type Output = I16Vec3;
784 #[inline]
785 fn div(self, rhs: I16Vec3) -> I16Vec3 {
786 I16Vec3 {
787 x: self.div(rhs.x),
788 y: self.div(rhs.y),
789 z: self.div(rhs.z),
790 }
791 }
792}
793
794impl Div<&I16Vec3> for i16 {
795 type Output = I16Vec3;
796 #[inline]
797 fn div(self, rhs: &I16Vec3) -> I16Vec3 {
798 self.div(*rhs)
799 }
800}
801
802impl Div<&I16Vec3> for &i16 {
803 type Output = I16Vec3;
804 #[inline]
805 fn div(self, rhs: &I16Vec3) -> I16Vec3 {
806 (*self).div(*rhs)
807 }
808}
809
810impl Div<I16Vec3> for &i16 {
811 type Output = I16Vec3;
812 #[inline]
813 fn div(self, rhs: I16Vec3) -> I16Vec3 {
814 (*self).div(rhs)
815 }
816}
817
818impl Mul<I16Vec3> for I16Vec3 {
819 type Output = Self;
820 #[inline]
821 fn mul(self, rhs: Self) -> Self {
822 Self {
823 x: self.x.mul(rhs.x),
824 y: self.y.mul(rhs.y),
825 z: self.z.mul(rhs.z),
826 }
827 }
828}
829
830impl Mul<&I16Vec3> for I16Vec3 {
831 type Output = I16Vec3;
832 #[inline]
833 fn mul(self, rhs: &I16Vec3) -> I16Vec3 {
834 self.mul(*rhs)
835 }
836}
837
838impl Mul<&I16Vec3> for &I16Vec3 {
839 type Output = I16Vec3;
840 #[inline]
841 fn mul(self, rhs: &I16Vec3) -> I16Vec3 {
842 (*self).mul(*rhs)
843 }
844}
845
846impl Mul<I16Vec3> for &I16Vec3 {
847 type Output = I16Vec3;
848 #[inline]
849 fn mul(self, rhs: I16Vec3) -> I16Vec3 {
850 (*self).mul(rhs)
851 }
852}
853
854impl MulAssign<I16Vec3> for I16Vec3 {
855 #[inline]
856 fn mul_assign(&mut self, rhs: Self) {
857 self.x.mul_assign(rhs.x);
858 self.y.mul_assign(rhs.y);
859 self.z.mul_assign(rhs.z);
860 }
861}
862
863impl MulAssign<&Self> for I16Vec3 {
864 #[inline]
865 fn mul_assign(&mut self, rhs: &Self) {
866 self.mul_assign(*rhs)
867 }
868}
869
870impl Mul<i16> for I16Vec3 {
871 type Output = Self;
872 #[inline]
873 fn mul(self, rhs: i16) -> Self {
874 Self {
875 x: self.x.mul(rhs),
876 y: self.y.mul(rhs),
877 z: self.z.mul(rhs),
878 }
879 }
880}
881
882impl Mul<&i16> for I16Vec3 {
883 type Output = I16Vec3;
884 #[inline]
885 fn mul(self, rhs: &i16) -> I16Vec3 {
886 self.mul(*rhs)
887 }
888}
889
890impl Mul<&i16> for &I16Vec3 {
891 type Output = I16Vec3;
892 #[inline]
893 fn mul(self, rhs: &i16) -> I16Vec3 {
894 (*self).mul(*rhs)
895 }
896}
897
898impl Mul<i16> for &I16Vec3 {
899 type Output = I16Vec3;
900 #[inline]
901 fn mul(self, rhs: i16) -> I16Vec3 {
902 (*self).mul(rhs)
903 }
904}
905
906impl MulAssign<i16> for I16Vec3 {
907 #[inline]
908 fn mul_assign(&mut self, rhs: i16) {
909 self.x.mul_assign(rhs);
910 self.y.mul_assign(rhs);
911 self.z.mul_assign(rhs);
912 }
913}
914
915impl MulAssign<&i16> for I16Vec3 {
916 #[inline]
917 fn mul_assign(&mut self, rhs: &i16) {
918 self.mul_assign(*rhs)
919 }
920}
921
922impl Mul<I16Vec3> for i16 {
923 type Output = I16Vec3;
924 #[inline]
925 fn mul(self, rhs: I16Vec3) -> I16Vec3 {
926 I16Vec3 {
927 x: self.mul(rhs.x),
928 y: self.mul(rhs.y),
929 z: self.mul(rhs.z),
930 }
931 }
932}
933
934impl Mul<&I16Vec3> for i16 {
935 type Output = I16Vec3;
936 #[inline]
937 fn mul(self, rhs: &I16Vec3) -> I16Vec3 {
938 self.mul(*rhs)
939 }
940}
941
942impl Mul<&I16Vec3> for &i16 {
943 type Output = I16Vec3;
944 #[inline]
945 fn mul(self, rhs: &I16Vec3) -> I16Vec3 {
946 (*self).mul(*rhs)
947 }
948}
949
950impl Mul<I16Vec3> for &i16 {
951 type Output = I16Vec3;
952 #[inline]
953 fn mul(self, rhs: I16Vec3) -> I16Vec3 {
954 (*self).mul(rhs)
955 }
956}
957
958impl Add<I16Vec3> for I16Vec3 {
959 type Output = Self;
960 #[inline]
961 fn add(self, rhs: Self) -> Self {
962 Self {
963 x: self.x.add(rhs.x),
964 y: self.y.add(rhs.y),
965 z: self.z.add(rhs.z),
966 }
967 }
968}
969
970impl Add<&I16Vec3> for I16Vec3 {
971 type Output = I16Vec3;
972 #[inline]
973 fn add(self, rhs: &I16Vec3) -> I16Vec3 {
974 self.add(*rhs)
975 }
976}
977
978impl Add<&I16Vec3> for &I16Vec3 {
979 type Output = I16Vec3;
980 #[inline]
981 fn add(self, rhs: &I16Vec3) -> I16Vec3 {
982 (*self).add(*rhs)
983 }
984}
985
986impl Add<I16Vec3> for &I16Vec3 {
987 type Output = I16Vec3;
988 #[inline]
989 fn add(self, rhs: I16Vec3) -> I16Vec3 {
990 (*self).add(rhs)
991 }
992}
993
994impl AddAssign<I16Vec3> for I16Vec3 {
995 #[inline]
996 fn add_assign(&mut self, rhs: Self) {
997 self.x.add_assign(rhs.x);
998 self.y.add_assign(rhs.y);
999 self.z.add_assign(rhs.z);
1000 }
1001}
1002
1003impl AddAssign<&Self> for I16Vec3 {
1004 #[inline]
1005 fn add_assign(&mut self, rhs: &Self) {
1006 self.add_assign(*rhs)
1007 }
1008}
1009
1010impl Add<i16> for I16Vec3 {
1011 type Output = Self;
1012 #[inline]
1013 fn add(self, rhs: i16) -> Self {
1014 Self {
1015 x: self.x.add(rhs),
1016 y: self.y.add(rhs),
1017 z: self.z.add(rhs),
1018 }
1019 }
1020}
1021
1022impl Add<&i16> for I16Vec3 {
1023 type Output = I16Vec3;
1024 #[inline]
1025 fn add(self, rhs: &i16) -> I16Vec3 {
1026 self.add(*rhs)
1027 }
1028}
1029
1030impl Add<&i16> for &I16Vec3 {
1031 type Output = I16Vec3;
1032 #[inline]
1033 fn add(self, rhs: &i16) -> I16Vec3 {
1034 (*self).add(*rhs)
1035 }
1036}
1037
1038impl Add<i16> for &I16Vec3 {
1039 type Output = I16Vec3;
1040 #[inline]
1041 fn add(self, rhs: i16) -> I16Vec3 {
1042 (*self).add(rhs)
1043 }
1044}
1045
1046impl AddAssign<i16> for I16Vec3 {
1047 #[inline]
1048 fn add_assign(&mut self, rhs: i16) {
1049 self.x.add_assign(rhs);
1050 self.y.add_assign(rhs);
1051 self.z.add_assign(rhs);
1052 }
1053}
1054
1055impl AddAssign<&i16> for I16Vec3 {
1056 #[inline]
1057 fn add_assign(&mut self, rhs: &i16) {
1058 self.add_assign(*rhs)
1059 }
1060}
1061
1062impl Add<I16Vec3> for i16 {
1063 type Output = I16Vec3;
1064 #[inline]
1065 fn add(self, rhs: I16Vec3) -> I16Vec3 {
1066 I16Vec3 {
1067 x: self.add(rhs.x),
1068 y: self.add(rhs.y),
1069 z: self.add(rhs.z),
1070 }
1071 }
1072}
1073
1074impl Add<&I16Vec3> for i16 {
1075 type Output = I16Vec3;
1076 #[inline]
1077 fn add(self, rhs: &I16Vec3) -> I16Vec3 {
1078 self.add(*rhs)
1079 }
1080}
1081
1082impl Add<&I16Vec3> for &i16 {
1083 type Output = I16Vec3;
1084 #[inline]
1085 fn add(self, rhs: &I16Vec3) -> I16Vec3 {
1086 (*self).add(*rhs)
1087 }
1088}
1089
1090impl Add<I16Vec3> for &i16 {
1091 type Output = I16Vec3;
1092 #[inline]
1093 fn add(self, rhs: I16Vec3) -> I16Vec3 {
1094 (*self).add(rhs)
1095 }
1096}
1097
1098impl Sub<I16Vec3> for I16Vec3 {
1099 type Output = Self;
1100 #[inline]
1101 fn sub(self, rhs: Self) -> Self {
1102 Self {
1103 x: self.x.sub(rhs.x),
1104 y: self.y.sub(rhs.y),
1105 z: self.z.sub(rhs.z),
1106 }
1107 }
1108}
1109
1110impl Sub<&I16Vec3> for I16Vec3 {
1111 type Output = I16Vec3;
1112 #[inline]
1113 fn sub(self, rhs: &I16Vec3) -> I16Vec3 {
1114 self.sub(*rhs)
1115 }
1116}
1117
1118impl Sub<&I16Vec3> for &I16Vec3 {
1119 type Output = I16Vec3;
1120 #[inline]
1121 fn sub(self, rhs: &I16Vec3) -> I16Vec3 {
1122 (*self).sub(*rhs)
1123 }
1124}
1125
1126impl Sub<I16Vec3> for &I16Vec3 {
1127 type Output = I16Vec3;
1128 #[inline]
1129 fn sub(self, rhs: I16Vec3) -> I16Vec3 {
1130 (*self).sub(rhs)
1131 }
1132}
1133
1134impl SubAssign<I16Vec3> for I16Vec3 {
1135 #[inline]
1136 fn sub_assign(&mut self, rhs: I16Vec3) {
1137 self.x.sub_assign(rhs.x);
1138 self.y.sub_assign(rhs.y);
1139 self.z.sub_assign(rhs.z);
1140 }
1141}
1142
1143impl SubAssign<&Self> for I16Vec3 {
1144 #[inline]
1145 fn sub_assign(&mut self, rhs: &Self) {
1146 self.sub_assign(*rhs)
1147 }
1148}
1149
1150impl Sub<i16> for I16Vec3 {
1151 type Output = Self;
1152 #[inline]
1153 fn sub(self, rhs: i16) -> Self {
1154 Self {
1155 x: self.x.sub(rhs),
1156 y: self.y.sub(rhs),
1157 z: self.z.sub(rhs),
1158 }
1159 }
1160}
1161
1162impl Sub<&i16> for I16Vec3 {
1163 type Output = I16Vec3;
1164 #[inline]
1165 fn sub(self, rhs: &i16) -> I16Vec3 {
1166 self.sub(*rhs)
1167 }
1168}
1169
1170impl Sub<&i16> for &I16Vec3 {
1171 type Output = I16Vec3;
1172 #[inline]
1173 fn sub(self, rhs: &i16) -> I16Vec3 {
1174 (*self).sub(*rhs)
1175 }
1176}
1177
1178impl Sub<i16> for &I16Vec3 {
1179 type Output = I16Vec3;
1180 #[inline]
1181 fn sub(self, rhs: i16) -> I16Vec3 {
1182 (*self).sub(rhs)
1183 }
1184}
1185
1186impl SubAssign<i16> for I16Vec3 {
1187 #[inline]
1188 fn sub_assign(&mut self, rhs: i16) {
1189 self.x.sub_assign(rhs);
1190 self.y.sub_assign(rhs);
1191 self.z.sub_assign(rhs);
1192 }
1193}
1194
1195impl SubAssign<&i16> for I16Vec3 {
1196 #[inline]
1197 fn sub_assign(&mut self, rhs: &i16) {
1198 self.sub_assign(*rhs)
1199 }
1200}
1201
1202impl Sub<I16Vec3> for i16 {
1203 type Output = I16Vec3;
1204 #[inline]
1205 fn sub(self, rhs: I16Vec3) -> I16Vec3 {
1206 I16Vec3 {
1207 x: self.sub(rhs.x),
1208 y: self.sub(rhs.y),
1209 z: self.sub(rhs.z),
1210 }
1211 }
1212}
1213
1214impl Sub<&I16Vec3> for i16 {
1215 type Output = I16Vec3;
1216 #[inline]
1217 fn sub(self, rhs: &I16Vec3) -> I16Vec3 {
1218 self.sub(*rhs)
1219 }
1220}
1221
1222impl Sub<&I16Vec3> for &i16 {
1223 type Output = I16Vec3;
1224 #[inline]
1225 fn sub(self, rhs: &I16Vec3) -> I16Vec3 {
1226 (*self).sub(*rhs)
1227 }
1228}
1229
1230impl Sub<I16Vec3> for &i16 {
1231 type Output = I16Vec3;
1232 #[inline]
1233 fn sub(self, rhs: I16Vec3) -> I16Vec3 {
1234 (*self).sub(rhs)
1235 }
1236}
1237
1238impl Rem<I16Vec3> for I16Vec3 {
1239 type Output = Self;
1240 #[inline]
1241 fn rem(self, rhs: Self) -> Self {
1242 Self {
1243 x: self.x.rem(rhs.x),
1244 y: self.y.rem(rhs.y),
1245 z: self.z.rem(rhs.z),
1246 }
1247 }
1248}
1249
1250impl Rem<&I16Vec3> for I16Vec3 {
1251 type Output = I16Vec3;
1252 #[inline]
1253 fn rem(self, rhs: &I16Vec3) -> I16Vec3 {
1254 self.rem(*rhs)
1255 }
1256}
1257
1258impl Rem<&I16Vec3> for &I16Vec3 {
1259 type Output = I16Vec3;
1260 #[inline]
1261 fn rem(self, rhs: &I16Vec3) -> I16Vec3 {
1262 (*self).rem(*rhs)
1263 }
1264}
1265
1266impl Rem<I16Vec3> for &I16Vec3 {
1267 type Output = I16Vec3;
1268 #[inline]
1269 fn rem(self, rhs: I16Vec3) -> I16Vec3 {
1270 (*self).rem(rhs)
1271 }
1272}
1273
1274impl RemAssign<I16Vec3> for I16Vec3 {
1275 #[inline]
1276 fn rem_assign(&mut self, rhs: Self) {
1277 self.x.rem_assign(rhs.x);
1278 self.y.rem_assign(rhs.y);
1279 self.z.rem_assign(rhs.z);
1280 }
1281}
1282
1283impl RemAssign<&Self> for I16Vec3 {
1284 #[inline]
1285 fn rem_assign(&mut self, rhs: &Self) {
1286 self.rem_assign(*rhs)
1287 }
1288}
1289
1290impl Rem<i16> for I16Vec3 {
1291 type Output = Self;
1292 #[inline]
1293 fn rem(self, rhs: i16) -> Self {
1294 Self {
1295 x: self.x.rem(rhs),
1296 y: self.y.rem(rhs),
1297 z: self.z.rem(rhs),
1298 }
1299 }
1300}
1301
1302impl Rem<&i16> for I16Vec3 {
1303 type Output = I16Vec3;
1304 #[inline]
1305 fn rem(self, rhs: &i16) -> I16Vec3 {
1306 self.rem(*rhs)
1307 }
1308}
1309
1310impl Rem<&i16> for &I16Vec3 {
1311 type Output = I16Vec3;
1312 #[inline]
1313 fn rem(self, rhs: &i16) -> I16Vec3 {
1314 (*self).rem(*rhs)
1315 }
1316}
1317
1318impl Rem<i16> for &I16Vec3 {
1319 type Output = I16Vec3;
1320 #[inline]
1321 fn rem(self, rhs: i16) -> I16Vec3 {
1322 (*self).rem(rhs)
1323 }
1324}
1325
1326impl RemAssign<i16> for I16Vec3 {
1327 #[inline]
1328 fn rem_assign(&mut self, rhs: i16) {
1329 self.x.rem_assign(rhs);
1330 self.y.rem_assign(rhs);
1331 self.z.rem_assign(rhs);
1332 }
1333}
1334
1335impl RemAssign<&i16> for I16Vec3 {
1336 #[inline]
1337 fn rem_assign(&mut self, rhs: &i16) {
1338 self.rem_assign(*rhs)
1339 }
1340}
1341
1342impl Rem<I16Vec3> for i16 {
1343 type Output = I16Vec3;
1344 #[inline]
1345 fn rem(self, rhs: I16Vec3) -> I16Vec3 {
1346 I16Vec3 {
1347 x: self.rem(rhs.x),
1348 y: self.rem(rhs.y),
1349 z: self.rem(rhs.z),
1350 }
1351 }
1352}
1353
1354impl Rem<&I16Vec3> for i16 {
1355 type Output = I16Vec3;
1356 #[inline]
1357 fn rem(self, rhs: &I16Vec3) -> I16Vec3 {
1358 self.rem(*rhs)
1359 }
1360}
1361
1362impl Rem<&I16Vec3> for &i16 {
1363 type Output = I16Vec3;
1364 #[inline]
1365 fn rem(self, rhs: &I16Vec3) -> I16Vec3 {
1366 (*self).rem(*rhs)
1367 }
1368}
1369
1370impl Rem<I16Vec3> for &i16 {
1371 type Output = I16Vec3;
1372 #[inline]
1373 fn rem(self, rhs: I16Vec3) -> I16Vec3 {
1374 (*self).rem(rhs)
1375 }
1376}
1377
1378#[cfg(not(target_arch = "spirv"))]
1379impl AsRef<[i16; 3]> for I16Vec3 {
1380 #[inline]
1381 fn as_ref(&self) -> &[i16; 3] {
1382 unsafe { &*(self as *const I16Vec3 as *const [i16; 3]) }
1383 }
1384}
1385
1386#[cfg(not(target_arch = "spirv"))]
1387impl AsMut<[i16; 3]> for I16Vec3 {
1388 #[inline]
1389 fn as_mut(&mut self) -> &mut [i16; 3] {
1390 unsafe { &mut *(self as *mut I16Vec3 as *mut [i16; 3]) }
1391 }
1392}
1393
1394impl Sum for I16Vec3 {
1395 #[inline]
1396 fn sum<I>(iter: I) -> Self
1397 where
1398 I: Iterator<Item = Self>,
1399 {
1400 iter.fold(Self::ZERO, Self::add)
1401 }
1402}
1403
1404impl<'a> Sum<&'a Self> for I16Vec3 {
1405 #[inline]
1406 fn sum<I>(iter: I) -> Self
1407 where
1408 I: Iterator<Item = &'a Self>,
1409 {
1410 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1411 }
1412}
1413
1414impl Product for I16Vec3 {
1415 #[inline]
1416 fn product<I>(iter: I) -> Self
1417 where
1418 I: Iterator<Item = Self>,
1419 {
1420 iter.fold(Self::ONE, Self::mul)
1421 }
1422}
1423
1424impl<'a> Product<&'a Self> for I16Vec3 {
1425 #[inline]
1426 fn product<I>(iter: I) -> Self
1427 where
1428 I: Iterator<Item = &'a Self>,
1429 {
1430 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1431 }
1432}
1433
1434impl Neg for I16Vec3 {
1435 type Output = Self;
1436 #[inline]
1437 fn neg(self) -> Self {
1438 Self {
1439 x: self.x.neg(),
1440 y: self.y.neg(),
1441 z: self.z.neg(),
1442 }
1443 }
1444}
1445
1446impl Neg for &I16Vec3 {
1447 type Output = I16Vec3;
1448 #[inline]
1449 fn neg(self) -> I16Vec3 {
1450 (*self).neg()
1451 }
1452}
1453
1454impl Not for I16Vec3 {
1455 type Output = Self;
1456 #[inline]
1457 fn not(self) -> Self::Output {
1458 Self {
1459 x: self.x.not(),
1460 y: self.y.not(),
1461 z: self.z.not(),
1462 }
1463 }
1464}
1465
1466impl BitAnd for I16Vec3 {
1467 type Output = Self;
1468 #[inline]
1469 fn bitand(self, rhs: Self) -> Self::Output {
1470 Self {
1471 x: self.x.bitand(rhs.x),
1472 y: self.y.bitand(rhs.y),
1473 z: self.z.bitand(rhs.z),
1474 }
1475 }
1476}
1477
1478impl BitOr for I16Vec3 {
1479 type Output = Self;
1480 #[inline]
1481 fn bitor(self, rhs: Self) -> Self::Output {
1482 Self {
1483 x: self.x.bitor(rhs.x),
1484 y: self.y.bitor(rhs.y),
1485 z: self.z.bitor(rhs.z),
1486 }
1487 }
1488}
1489
1490impl BitXor for I16Vec3 {
1491 type Output = Self;
1492 #[inline]
1493 fn bitxor(self, rhs: Self) -> Self::Output {
1494 Self {
1495 x: self.x.bitxor(rhs.x),
1496 y: self.y.bitxor(rhs.y),
1497 z: self.z.bitxor(rhs.z),
1498 }
1499 }
1500}
1501
1502impl BitAnd<i16> for I16Vec3 {
1503 type Output = Self;
1504 #[inline]
1505 fn bitand(self, rhs: i16) -> Self::Output {
1506 Self {
1507 x: self.x.bitand(rhs),
1508 y: self.y.bitand(rhs),
1509 z: self.z.bitand(rhs),
1510 }
1511 }
1512}
1513
1514impl BitOr<i16> for I16Vec3 {
1515 type Output = Self;
1516 #[inline]
1517 fn bitor(self, rhs: i16) -> Self::Output {
1518 Self {
1519 x: self.x.bitor(rhs),
1520 y: self.y.bitor(rhs),
1521 z: self.z.bitor(rhs),
1522 }
1523 }
1524}
1525
1526impl BitXor<i16> for I16Vec3 {
1527 type Output = Self;
1528 #[inline]
1529 fn bitxor(self, rhs: i16) -> Self::Output {
1530 Self {
1531 x: self.x.bitxor(rhs),
1532 y: self.y.bitxor(rhs),
1533 z: self.z.bitxor(rhs),
1534 }
1535 }
1536}
1537
1538impl Shl<i8> for I16Vec3 {
1539 type Output = Self;
1540 #[inline]
1541 fn shl(self, rhs: i8) -> Self::Output {
1542 Self {
1543 x: self.x.shl(rhs),
1544 y: self.y.shl(rhs),
1545 z: self.z.shl(rhs),
1546 }
1547 }
1548}
1549
1550impl Shr<i8> for I16Vec3 {
1551 type Output = Self;
1552 #[inline]
1553 fn shr(self, rhs: i8) -> Self::Output {
1554 Self {
1555 x: self.x.shr(rhs),
1556 y: self.y.shr(rhs),
1557 z: self.z.shr(rhs),
1558 }
1559 }
1560}
1561
1562impl Shl<i16> for I16Vec3 {
1563 type Output = Self;
1564 #[inline]
1565 fn shl(self, rhs: i16) -> Self::Output {
1566 Self {
1567 x: self.x.shl(rhs),
1568 y: self.y.shl(rhs),
1569 z: self.z.shl(rhs),
1570 }
1571 }
1572}
1573
1574impl Shr<i16> for I16Vec3 {
1575 type Output = Self;
1576 #[inline]
1577 fn shr(self, rhs: i16) -> Self::Output {
1578 Self {
1579 x: self.x.shr(rhs),
1580 y: self.y.shr(rhs),
1581 z: self.z.shr(rhs),
1582 }
1583 }
1584}
1585
1586impl Shl<i32> for I16Vec3 {
1587 type Output = Self;
1588 #[inline]
1589 fn shl(self, rhs: i32) -> Self::Output {
1590 Self {
1591 x: self.x.shl(rhs),
1592 y: self.y.shl(rhs),
1593 z: self.z.shl(rhs),
1594 }
1595 }
1596}
1597
1598impl Shr<i32> for I16Vec3 {
1599 type Output = Self;
1600 #[inline]
1601 fn shr(self, rhs: i32) -> Self::Output {
1602 Self {
1603 x: self.x.shr(rhs),
1604 y: self.y.shr(rhs),
1605 z: self.z.shr(rhs),
1606 }
1607 }
1608}
1609
1610impl Shl<i64> for I16Vec3 {
1611 type Output = Self;
1612 #[inline]
1613 fn shl(self, rhs: i64) -> Self::Output {
1614 Self {
1615 x: self.x.shl(rhs),
1616 y: self.y.shl(rhs),
1617 z: self.z.shl(rhs),
1618 }
1619 }
1620}
1621
1622impl Shr<i64> for I16Vec3 {
1623 type Output = Self;
1624 #[inline]
1625 fn shr(self, rhs: i64) -> Self::Output {
1626 Self {
1627 x: self.x.shr(rhs),
1628 y: self.y.shr(rhs),
1629 z: self.z.shr(rhs),
1630 }
1631 }
1632}
1633
1634impl Shl<u8> for I16Vec3 {
1635 type Output = Self;
1636 #[inline]
1637 fn shl(self, rhs: u8) -> Self::Output {
1638 Self {
1639 x: self.x.shl(rhs),
1640 y: self.y.shl(rhs),
1641 z: self.z.shl(rhs),
1642 }
1643 }
1644}
1645
1646impl Shr<u8> for I16Vec3 {
1647 type Output = Self;
1648 #[inline]
1649 fn shr(self, rhs: u8) -> Self::Output {
1650 Self {
1651 x: self.x.shr(rhs),
1652 y: self.y.shr(rhs),
1653 z: self.z.shr(rhs),
1654 }
1655 }
1656}
1657
1658impl Shl<u16> for I16Vec3 {
1659 type Output = Self;
1660 #[inline]
1661 fn shl(self, rhs: u16) -> Self::Output {
1662 Self {
1663 x: self.x.shl(rhs),
1664 y: self.y.shl(rhs),
1665 z: self.z.shl(rhs),
1666 }
1667 }
1668}
1669
1670impl Shr<u16> for I16Vec3 {
1671 type Output = Self;
1672 #[inline]
1673 fn shr(self, rhs: u16) -> Self::Output {
1674 Self {
1675 x: self.x.shr(rhs),
1676 y: self.y.shr(rhs),
1677 z: self.z.shr(rhs),
1678 }
1679 }
1680}
1681
1682impl Shl<u32> for I16Vec3 {
1683 type Output = Self;
1684 #[inline]
1685 fn shl(self, rhs: u32) -> Self::Output {
1686 Self {
1687 x: self.x.shl(rhs),
1688 y: self.y.shl(rhs),
1689 z: self.z.shl(rhs),
1690 }
1691 }
1692}
1693
1694impl Shr<u32> for I16Vec3 {
1695 type Output = Self;
1696 #[inline]
1697 fn shr(self, rhs: u32) -> Self::Output {
1698 Self {
1699 x: self.x.shr(rhs),
1700 y: self.y.shr(rhs),
1701 z: self.z.shr(rhs),
1702 }
1703 }
1704}
1705
1706impl Shl<u64> for I16Vec3 {
1707 type Output = Self;
1708 #[inline]
1709 fn shl(self, rhs: u64) -> Self::Output {
1710 Self {
1711 x: self.x.shl(rhs),
1712 y: self.y.shl(rhs),
1713 z: self.z.shl(rhs),
1714 }
1715 }
1716}
1717
1718impl Shr<u64> for I16Vec3 {
1719 type Output = Self;
1720 #[inline]
1721 fn shr(self, rhs: u64) -> Self::Output {
1722 Self {
1723 x: self.x.shr(rhs),
1724 y: self.y.shr(rhs),
1725 z: self.z.shr(rhs),
1726 }
1727 }
1728}
1729
1730impl Shl<crate::IVec3> for I16Vec3 {
1731 type Output = Self;
1732 #[inline]
1733 fn shl(self, rhs: crate::IVec3) -> Self::Output {
1734 Self {
1735 x: self.x.shl(rhs.x),
1736 y: self.y.shl(rhs.y),
1737 z: self.z.shl(rhs.z),
1738 }
1739 }
1740}
1741
1742impl Shr<crate::IVec3> for I16Vec3 {
1743 type Output = Self;
1744 #[inline]
1745 fn shr(self, rhs: crate::IVec3) -> Self::Output {
1746 Self {
1747 x: self.x.shr(rhs.x),
1748 y: self.y.shr(rhs.y),
1749 z: self.z.shr(rhs.z),
1750 }
1751 }
1752}
1753
1754impl Shl<crate::UVec3> for I16Vec3 {
1755 type Output = Self;
1756 #[inline]
1757 fn shl(self, rhs: crate::UVec3) -> Self::Output {
1758 Self {
1759 x: self.x.shl(rhs.x),
1760 y: self.y.shl(rhs.y),
1761 z: self.z.shl(rhs.z),
1762 }
1763 }
1764}
1765
1766impl Shr<crate::UVec3> for I16Vec3 {
1767 type Output = Self;
1768 #[inline]
1769 fn shr(self, rhs: crate::UVec3) -> Self::Output {
1770 Self {
1771 x: self.x.shr(rhs.x),
1772 y: self.y.shr(rhs.y),
1773 z: self.z.shr(rhs.z),
1774 }
1775 }
1776}
1777
1778impl Index<usize> for I16Vec3 {
1779 type Output = i16;
1780 #[inline]
1781 fn index(&self, index: usize) -> &Self::Output {
1782 match index {
1783 0 => &self.x,
1784 1 => &self.y,
1785 2 => &self.z,
1786 _ => panic!("index out of bounds"),
1787 }
1788 }
1789}
1790
1791impl IndexMut<usize> for I16Vec3 {
1792 #[inline]
1793 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1794 match index {
1795 0 => &mut self.x,
1796 1 => &mut self.y,
1797 2 => &mut self.z,
1798 _ => panic!("index out of bounds"),
1799 }
1800 }
1801}
1802
1803impl fmt::Display for I16Vec3 {
1804 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1805 write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
1806 }
1807}
1808
1809impl fmt::Debug for I16Vec3 {
1810 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1811 fmt.debug_tuple(stringify!(I16Vec3))
1812 .field(&self.x)
1813 .field(&self.y)
1814 .field(&self.z)
1815 .finish()
1816 }
1817}
1818
1819impl From<[i16; 3]> for I16Vec3 {
1820 #[inline]
1821 fn from(a: [i16; 3]) -> Self {
1822 Self::new(a[0], a[1], a[2])
1823 }
1824}
1825
1826impl From<I16Vec3> for [i16; 3] {
1827 #[inline]
1828 fn from(v: I16Vec3) -> Self {
1829 [v.x, v.y, v.z]
1830 }
1831}
1832
1833impl From<(i16, i16, i16)> for I16Vec3 {
1834 #[inline]
1835 fn from(t: (i16, i16, i16)) -> Self {
1836 Self::new(t.0, t.1, t.2)
1837 }
1838}
1839
1840impl From<I16Vec3> for (i16, i16, i16) {
1841 #[inline]
1842 fn from(v: I16Vec3) -> Self {
1843 (v.x, v.y, v.z)
1844 }
1845}
1846
1847impl From<(I16Vec2, i16)> for I16Vec3 {
1848 #[inline]
1849 fn from((v, z): (I16Vec2, i16)) -> Self {
1850 Self::new(v.x, v.y, z)
1851 }
1852}
1853
1854impl From<I8Vec3> for I16Vec3 {
1855 #[inline]
1856 fn from(v: I8Vec3) -> Self {
1857 Self::new(i16::from(v.x), i16::from(v.y), i16::from(v.z))
1858 }
1859}
1860
1861impl From<U8Vec3> for I16Vec3 {
1862 #[inline]
1863 fn from(v: U8Vec3) -> Self {
1864 Self::new(i16::from(v.x), i16::from(v.y), i16::from(v.z))
1865 }
1866}
1867
1868impl TryFrom<U16Vec3> for I16Vec3 {
1869 type Error = core::num::TryFromIntError;
1870
1871 #[inline]
1872 fn try_from(v: U16Vec3) -> Result<Self, Self::Error> {
1873 Ok(Self::new(
1874 i16::try_from(v.x)?,
1875 i16::try_from(v.y)?,
1876 i16::try_from(v.z)?,
1877 ))
1878 }
1879}
1880
1881impl TryFrom<IVec3> for I16Vec3 {
1882 type Error = core::num::TryFromIntError;
1883
1884 #[inline]
1885 fn try_from(v: IVec3) -> Result<Self, Self::Error> {
1886 Ok(Self::new(
1887 i16::try_from(v.x)?,
1888 i16::try_from(v.y)?,
1889 i16::try_from(v.z)?,
1890 ))
1891 }
1892}
1893
1894impl TryFrom<UVec3> for I16Vec3 {
1895 type Error = core::num::TryFromIntError;
1896
1897 #[inline]
1898 fn try_from(v: UVec3) -> Result<Self, Self::Error> {
1899 Ok(Self::new(
1900 i16::try_from(v.x)?,
1901 i16::try_from(v.y)?,
1902 i16::try_from(v.z)?,
1903 ))
1904 }
1905}
1906
1907impl TryFrom<I64Vec3> for I16Vec3 {
1908 type Error = core::num::TryFromIntError;
1909
1910 #[inline]
1911 fn try_from(v: I64Vec3) -> Result<Self, Self::Error> {
1912 Ok(Self::new(
1913 i16::try_from(v.x)?,
1914 i16::try_from(v.y)?,
1915 i16::try_from(v.z)?,
1916 ))
1917 }
1918}
1919
1920impl TryFrom<U64Vec3> for I16Vec3 {
1921 type Error = core::num::TryFromIntError;
1922
1923 #[inline]
1924 fn try_from(v: U64Vec3) -> Result<Self, Self::Error> {
1925 Ok(Self::new(
1926 i16::try_from(v.x)?,
1927 i16::try_from(v.y)?,
1928 i16::try_from(v.z)?,
1929 ))
1930 }
1931}
1932
1933impl From<BVec3> for I16Vec3 {
1934 #[inline]
1935 fn from(v: BVec3) -> Self {
1936 Self::new(i16::from(v.x), i16::from(v.y), i16::from(v.z))
1937 }
1938}
1939
1940impl From<BVec3A> for I16Vec3 {
1941 #[inline]
1942 fn from(v: BVec3A) -> Self {
1943 let bool_array: [bool; 3] = v.into();
1944 Self::new(
1945 i16::from(bool_array[0]),
1946 i16::from(bool_array[1]),
1947 i16::from(bool_array[2]),
1948 )
1949 }
1950}