1#[cfg(not(feature = "scalar-math"))]
4use crate::BVec4A;
5use crate::{f64::math, BVec4, DVec2, DVec3, IVec4, UVec4, Vec4};
6
7use core::fmt;
8use core::iter::{Product, Sum};
9use core::{f32, ops::*};
10
11#[inline(always)]
13#[must_use]
14pub const fn dvec4(x: f64, y: f64, z: f64, w: f64) -> DVec4 {
15 DVec4::new(x, y, z, w)
16}
17
18#[derive(Clone, Copy, PartialEq)]
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 DVec4 {
24 pub x: f64,
25 pub y: f64,
26 pub z: f64,
27 pub w: f64,
28}
29
30impl DVec4 {
31 pub const ZERO: Self = Self::splat(0.0);
33
34 pub const ONE: Self = Self::splat(1.0);
36
37 pub const NEG_ONE: Self = Self::splat(-1.0);
39
40 pub const MIN: Self = Self::splat(f64::MIN);
42
43 pub const MAX: Self = Self::splat(f64::MAX);
45
46 pub const NAN: Self = Self::splat(f64::NAN);
48
49 pub const INFINITY: Self = Self::splat(f64::INFINITY);
51
52 pub const NEG_INFINITY: Self = Self::splat(f64::NEG_INFINITY);
54
55 pub const X: Self = Self::new(1.0, 0.0, 0.0, 0.0);
57
58 pub const Y: Self = Self::new(0.0, 1.0, 0.0, 0.0);
60
61 pub const Z: Self = Self::new(0.0, 0.0, 1.0, 0.0);
63
64 pub const W: Self = Self::new(0.0, 0.0, 0.0, 1.0);
66
67 pub const NEG_X: Self = Self::new(-1.0, 0.0, 0.0, 0.0);
69
70 pub const NEG_Y: Self = Self::new(0.0, -1.0, 0.0, 0.0);
72
73 pub const NEG_Z: Self = Self::new(0.0, 0.0, -1.0, 0.0);
75
76 pub const NEG_W: Self = Self::new(0.0, 0.0, 0.0, -1.0);
78
79 pub const AXES: [Self; 4] = [Self::X, Self::Y, Self::Z, Self::W];
81
82 pub const USES_CORE_SIMD: bool = false;
84 pub const USES_NEON: bool = false;
86 pub const USES_SCALAR_MATH: bool = true;
88 pub const USES_SSE2: bool = false;
90 pub const USES_WASM32_SIMD: bool = false;
92
93 #[inline(always)]
95 #[must_use]
96 pub const fn new(x: f64, y: f64, z: f64, w: f64) -> Self {
97 Self { x, y, z, w }
98 }
99
100 #[inline]
102 #[must_use]
103 pub const fn splat(v: f64) -> Self {
104 Self {
105 x: v,
106
107 y: v,
108
109 z: v,
110
111 w: v,
112 }
113 }
114
115 #[inline]
117 #[must_use]
118 pub fn map<F>(self, f: F) -> Self
119 where
120 F: Fn(f64) -> f64,
121 {
122 Self::new(f(self.x), f(self.y), f(self.z), f(self.w))
123 }
124
125 #[inline]
131 #[must_use]
132 pub fn select(mask: BVec4, if_true: Self, if_false: Self) -> Self {
133 Self {
134 x: if mask.test(0) { if_true.x } else { if_false.x },
135 y: if mask.test(1) { if_true.y } else { if_false.y },
136 z: if mask.test(2) { if_true.z } else { if_false.z },
137 w: if mask.test(3) { if_true.w } else { if_false.w },
138 }
139 }
140
141 #[inline]
143 #[must_use]
144 pub const fn from_array(a: [f64; 4]) -> Self {
145 Self::new(a[0], a[1], a[2], a[3])
146 }
147
148 #[inline]
150 #[must_use]
151 pub const fn to_array(&self) -> [f64; 4] {
152 [self.x, self.y, self.z, self.w]
153 }
154
155 #[inline]
161 #[must_use]
162 pub const fn from_slice(slice: &[f64]) -> Self {
163 assert!(slice.len() >= 4);
164 Self::new(slice[0], slice[1], slice[2], slice[3])
165 }
166
167 #[inline]
173 pub fn write_to_slice(self, slice: &mut [f64]) {
174 slice[..4].copy_from_slice(&self.to_array());
175 }
176
177 #[inline]
181 #[must_use]
182 pub fn truncate(self) -> DVec3 {
183 use crate::swizzles::Vec4Swizzles;
184 self.xyz()
185 }
186
187 #[inline]
189 #[must_use]
190 pub fn with_x(mut self, x: f64) -> Self {
191 self.x = x;
192 self
193 }
194
195 #[inline]
197 #[must_use]
198 pub fn with_y(mut self, y: f64) -> Self {
199 self.y = y;
200 self
201 }
202
203 #[inline]
205 #[must_use]
206 pub fn with_z(mut self, z: f64) -> Self {
207 self.z = z;
208 self
209 }
210
211 #[inline]
213 #[must_use]
214 pub fn with_w(mut self, w: f64) -> Self {
215 self.w = w;
216 self
217 }
218
219 #[inline]
221 #[must_use]
222 pub fn dot(self, rhs: Self) -> f64 {
223 (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z) + (self.w * rhs.w)
224 }
225
226 #[inline]
228 #[must_use]
229 pub fn dot_into_vec(self, rhs: Self) -> Self {
230 Self::splat(self.dot(rhs))
231 }
232
233 #[inline]
240 #[must_use]
241 pub fn min(self, rhs: Self) -> Self {
242 Self {
243 x: if self.x < rhs.x { self.x } else { rhs.x },
244 y: if self.y < rhs.y { self.y } else { rhs.y },
245 z: if self.z < rhs.z { self.z } else { rhs.z },
246 w: if self.w < rhs.w { self.w } else { rhs.w },
247 }
248 }
249
250 #[inline]
257 #[must_use]
258 pub fn max(self, rhs: Self) -> Self {
259 Self {
260 x: if self.x > rhs.x { self.x } else { rhs.x },
261 y: if self.y > rhs.y { self.y } else { rhs.y },
262 z: if self.z > rhs.z { self.z } else { rhs.z },
263 w: if self.w > rhs.w { self.w } else { rhs.w },
264 }
265 }
266
267 #[inline]
278 #[must_use]
279 pub fn clamp(self, min: Self, max: Self) -> Self {
280 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
281 self.max(min).min(max)
282 }
283
284 #[inline]
291 #[must_use]
292 pub fn min_element(self) -> f64 {
293 let min = |a, b| if a < b { a } else { b };
294 min(self.x, min(self.y, min(self.z, self.w)))
295 }
296
297 #[inline]
304 #[must_use]
305 pub fn max_element(self) -> f64 {
306 let max = |a, b| if a > b { a } else { b };
307 max(self.x, max(self.y, max(self.z, self.w)))
308 }
309
310 #[doc(alias = "argmin")]
312 #[inline]
313 #[must_use]
314 pub fn min_position(self) -> usize {
315 let mut min = self.x;
316 let mut index = 0;
317 if self.y < min {
318 min = self.y;
319 index = 1;
320 }
321 if self.z < min {
322 min = self.z;
323 index = 2;
324 }
325 if self.w < min {
326 index = 3;
327 }
328 index
329 }
330
331 #[doc(alias = "argmax")]
333 #[inline]
334 #[must_use]
335 pub fn max_position(self) -> usize {
336 let mut max = self.x;
337 let mut index = 0;
338 if self.y > max {
339 max = self.y;
340 index = 1;
341 }
342 if self.z > max {
343 max = self.z;
344 index = 2;
345 }
346 if self.w > max {
347 index = 3;
348 }
349 index
350 }
351
352 #[inline]
356 #[must_use]
357 pub fn element_sum(self) -> f64 {
358 self.x + self.y + self.z + self.w
359 }
360
361 #[inline]
365 #[must_use]
366 pub fn element_product(self) -> f64 {
367 self.x * self.y * self.z * self.w
368 }
369
370 #[inline]
376 #[must_use]
377 pub fn cmpeq(self, rhs: Self) -> BVec4 {
378 BVec4::new(
379 self.x.eq(&rhs.x),
380 self.y.eq(&rhs.y),
381 self.z.eq(&rhs.z),
382 self.w.eq(&rhs.w),
383 )
384 }
385
386 #[inline]
392 #[must_use]
393 pub fn cmpne(self, rhs: Self) -> BVec4 {
394 BVec4::new(
395 self.x.ne(&rhs.x),
396 self.y.ne(&rhs.y),
397 self.z.ne(&rhs.z),
398 self.w.ne(&rhs.w),
399 )
400 }
401
402 #[inline]
408 #[must_use]
409 pub fn cmpge(self, rhs: Self) -> BVec4 {
410 BVec4::new(
411 self.x.ge(&rhs.x),
412 self.y.ge(&rhs.y),
413 self.z.ge(&rhs.z),
414 self.w.ge(&rhs.w),
415 )
416 }
417
418 #[inline]
424 #[must_use]
425 pub fn cmpgt(self, rhs: Self) -> BVec4 {
426 BVec4::new(
427 self.x.gt(&rhs.x),
428 self.y.gt(&rhs.y),
429 self.z.gt(&rhs.z),
430 self.w.gt(&rhs.w),
431 )
432 }
433
434 #[inline]
440 #[must_use]
441 pub fn cmple(self, rhs: Self) -> BVec4 {
442 BVec4::new(
443 self.x.le(&rhs.x),
444 self.y.le(&rhs.y),
445 self.z.le(&rhs.z),
446 self.w.le(&rhs.w),
447 )
448 }
449
450 #[inline]
456 #[must_use]
457 pub fn cmplt(self, rhs: Self) -> BVec4 {
458 BVec4::new(
459 self.x.lt(&rhs.x),
460 self.y.lt(&rhs.y),
461 self.z.lt(&rhs.z),
462 self.w.lt(&rhs.w),
463 )
464 }
465
466 #[inline]
468 #[must_use]
469 pub fn abs(self) -> Self {
470 Self {
471 x: math::abs(self.x),
472 y: math::abs(self.y),
473 z: math::abs(self.z),
474 w: math::abs(self.w),
475 }
476 }
477
478 #[inline]
484 #[must_use]
485 pub fn signum(self) -> Self {
486 Self {
487 x: math::signum(self.x),
488 y: math::signum(self.y),
489 z: math::signum(self.z),
490 w: math::signum(self.w),
491 }
492 }
493
494 #[inline]
496 #[must_use]
497 pub fn copysign(self, rhs: Self) -> Self {
498 Self {
499 x: math::copysign(self.x, rhs.x),
500 y: math::copysign(self.y, rhs.y),
501 z: math::copysign(self.z, rhs.z),
502 w: math::copysign(self.w, rhs.w),
503 }
504 }
505
506 #[inline]
514 #[must_use]
515 pub fn is_negative_bitmask(self) -> u32 {
516 (self.x.is_sign_negative() as u32)
517 | ((self.y.is_sign_negative() as u32) << 1)
518 | ((self.z.is_sign_negative() as u32) << 2)
519 | ((self.w.is_sign_negative() as u32) << 3)
520 }
521
522 #[inline]
525 #[must_use]
526 pub fn is_finite(self) -> bool {
527 self.x.is_finite() && self.y.is_finite() && self.z.is_finite() && self.w.is_finite()
528 }
529
530 pub fn is_finite_mask(self) -> BVec4 {
534 BVec4::new(
535 self.x.is_finite(),
536 self.y.is_finite(),
537 self.z.is_finite(),
538 self.w.is_finite(),
539 )
540 }
541
542 #[inline]
544 #[must_use]
545 pub fn is_nan(self) -> bool {
546 self.x.is_nan() || self.y.is_nan() || self.z.is_nan() || self.w.is_nan()
547 }
548
549 #[inline]
553 #[must_use]
554 pub fn is_nan_mask(self) -> BVec4 {
555 BVec4::new(
556 self.x.is_nan(),
557 self.y.is_nan(),
558 self.z.is_nan(),
559 self.w.is_nan(),
560 )
561 }
562
563 #[doc(alias = "magnitude")]
565 #[inline]
566 #[must_use]
567 pub fn length(self) -> f64 {
568 math::sqrt(self.dot(self))
569 }
570
571 #[doc(alias = "magnitude2")]
575 #[inline]
576 #[must_use]
577 pub fn length_squared(self) -> f64 {
578 self.dot(self)
579 }
580
581 #[inline]
585 #[must_use]
586 pub fn length_recip(self) -> f64 {
587 self.length().recip()
588 }
589
590 #[inline]
592 #[must_use]
593 pub fn distance(self, rhs: Self) -> f64 {
594 (self - rhs).length()
595 }
596
597 #[inline]
599 #[must_use]
600 pub fn distance_squared(self, rhs: Self) -> f64 {
601 (self - rhs).length_squared()
602 }
603
604 #[inline]
606 #[must_use]
607 pub fn div_euclid(self, rhs: Self) -> Self {
608 Self::new(
609 math::div_euclid(self.x, rhs.x),
610 math::div_euclid(self.y, rhs.y),
611 math::div_euclid(self.z, rhs.z),
612 math::div_euclid(self.w, rhs.w),
613 )
614 }
615
616 #[inline]
620 #[must_use]
621 pub fn rem_euclid(self, rhs: Self) -> Self {
622 Self::new(
623 math::rem_euclid(self.x, rhs.x),
624 math::rem_euclid(self.y, rhs.y),
625 math::rem_euclid(self.z, rhs.z),
626 math::rem_euclid(self.w, rhs.w),
627 )
628 }
629
630 #[inline]
640 #[must_use]
641 pub fn normalize(self) -> Self {
642 #[allow(clippy::let_and_return)]
643 let normalized = self.mul(self.length_recip());
644 glam_assert!(normalized.is_finite());
645 normalized
646 }
647
648 #[inline]
655 #[must_use]
656 pub fn try_normalize(self) -> Option<Self> {
657 let rcp = self.length_recip();
658 if rcp.is_finite() && rcp > 0.0 {
659 Some(self * rcp)
660 } else {
661 None
662 }
663 }
664
665 #[inline]
673 #[must_use]
674 pub fn normalize_or(self, fallback: Self) -> Self {
675 let rcp = self.length_recip();
676 if rcp.is_finite() && rcp > 0.0 {
677 self * rcp
678 } else {
679 fallback
680 }
681 }
682
683 #[inline]
690 #[must_use]
691 pub fn normalize_or_zero(self) -> Self {
692 self.normalize_or(Self::ZERO)
693 }
694
695 #[inline]
699 #[must_use]
700 pub fn normalize_and_length(self) -> (Self, f64) {
701 let length = self.length();
702 let rcp = 1.0 / length;
703 if rcp.is_finite() && rcp > 0.0 {
704 (self * rcp, length)
705 } else {
706 (Self::X, 0.0)
707 }
708 }
709
710 #[inline]
714 #[must_use]
715 pub fn is_normalized(self) -> bool {
716 math::abs(self.length_squared() - 1.0) <= 2e-4
717 }
718
719 #[inline]
727 #[must_use]
728 pub fn project_onto(self, rhs: Self) -> Self {
729 let other_len_sq_rcp = rhs.dot(rhs).recip();
730 glam_assert!(other_len_sq_rcp.is_finite());
731 rhs * self.dot(rhs) * other_len_sq_rcp
732 }
733
734 #[doc(alias("plane"))]
745 #[inline]
746 #[must_use]
747 pub fn reject_from(self, rhs: Self) -> Self {
748 self - self.project_onto(rhs)
749 }
750
751 #[inline]
759 #[must_use]
760 pub fn project_onto_normalized(self, rhs: Self) -> Self {
761 glam_assert!(rhs.is_normalized());
762 rhs * self.dot(rhs)
763 }
764
765 #[doc(alias("plane"))]
776 #[inline]
777 #[must_use]
778 pub fn reject_from_normalized(self, rhs: Self) -> Self {
779 self - self.project_onto_normalized(rhs)
780 }
781
782 #[inline]
785 #[must_use]
786 pub fn round(self) -> Self {
787 Self {
788 x: math::round(self.x),
789 y: math::round(self.y),
790 z: math::round(self.z),
791 w: math::round(self.w),
792 }
793 }
794
795 #[inline]
798 #[must_use]
799 pub fn floor(self) -> Self {
800 Self {
801 x: math::floor(self.x),
802 y: math::floor(self.y),
803 z: math::floor(self.z),
804 w: math::floor(self.w),
805 }
806 }
807
808 #[inline]
811 #[must_use]
812 pub fn ceil(self) -> Self {
813 Self {
814 x: math::ceil(self.x),
815 y: math::ceil(self.y),
816 z: math::ceil(self.z),
817 w: math::ceil(self.w),
818 }
819 }
820
821 #[inline]
824 #[must_use]
825 pub fn trunc(self) -> Self {
826 Self {
827 x: math::trunc(self.x),
828 y: math::trunc(self.y),
829 z: math::trunc(self.z),
830 w: math::trunc(self.w),
831 }
832 }
833
834 #[inline]
841 #[must_use]
842 pub fn fract(self) -> Self {
843 self - self.trunc()
844 }
845
846 #[inline]
853 #[must_use]
854 pub fn fract_gl(self) -> Self {
855 self - self.floor()
856 }
857
858 #[inline]
861 #[must_use]
862 pub fn exp(self) -> Self {
863 Self::new(
864 math::exp(self.x),
865 math::exp(self.y),
866 math::exp(self.z),
867 math::exp(self.w),
868 )
869 }
870
871 #[inline]
873 #[must_use]
874 pub fn powf(self, n: f64) -> Self {
875 Self::new(
876 math::powf(self.x, n),
877 math::powf(self.y, n),
878 math::powf(self.z, n),
879 math::powf(self.w, n),
880 )
881 }
882
883 #[inline]
885 #[must_use]
886 pub fn recip(self) -> Self {
887 Self {
888 x: 1.0 / self.x,
889 y: 1.0 / self.y,
890 z: 1.0 / self.z,
891 w: 1.0 / self.w,
892 }
893 }
894
895 #[doc(alias = "mix")]
901 #[inline]
902 #[must_use]
903 pub fn lerp(self, rhs: Self, s: f64) -> Self {
904 self * (1.0 - s) + rhs * s
905 }
906
907 #[inline]
912 #[must_use]
913 pub fn move_towards(&self, rhs: Self, d: f64) -> Self {
914 let a = rhs - *self;
915 let len = a.length();
916 if len <= d || len <= 1e-4 {
917 return rhs;
918 }
919 *self + a / len * d
920 }
921
922 #[inline]
928 pub fn midpoint(self, rhs: Self) -> Self {
929 (self + rhs) * 0.5
930 }
931
932 #[inline]
942 #[must_use]
943 pub fn abs_diff_eq(self, rhs: Self, max_abs_diff: f64) -> bool {
944 self.sub(rhs).abs().cmple(Self::splat(max_abs_diff)).all()
945 }
946
947 #[inline]
953 #[must_use]
954 pub fn clamp_length(self, min: f64, max: f64) -> Self {
955 glam_assert!(0.0 <= min);
956 glam_assert!(min <= max);
957 let length_sq = self.length_squared();
958 if length_sq < min * min {
959 min * (self / math::sqrt(length_sq))
960 } else if length_sq > max * max {
961 max * (self / math::sqrt(length_sq))
962 } else {
963 self
964 }
965 }
966
967 #[inline]
973 #[must_use]
974 pub fn clamp_length_max(self, max: f64) -> Self {
975 glam_assert!(0.0 <= max);
976 let length_sq = self.length_squared();
977 if length_sq > max * max {
978 max * (self / math::sqrt(length_sq))
979 } else {
980 self
981 }
982 }
983
984 #[inline]
990 #[must_use]
991 pub fn clamp_length_min(self, min: f64) -> Self {
992 glam_assert!(0.0 <= min);
993 let length_sq = self.length_squared();
994 if length_sq < min * min {
995 min * (self / math::sqrt(length_sq))
996 } else {
997 self
998 }
999 }
1000
1001 #[inline]
1009 #[must_use]
1010 pub fn mul_add(self, a: Self, b: Self) -> Self {
1011 Self::new(
1012 math::mul_add(self.x, a.x, b.x),
1013 math::mul_add(self.y, a.y, b.y),
1014 math::mul_add(self.z, a.z, b.z),
1015 math::mul_add(self.w, a.w, b.w),
1016 )
1017 }
1018
1019 #[inline]
1028 #[must_use]
1029 pub fn reflect(self, normal: Self) -> Self {
1030 glam_assert!(normal.is_normalized());
1031 self - 2.0 * self.dot(normal) * normal
1032 }
1033
1034 #[inline]
1044 #[must_use]
1045 pub fn refract(self, normal: Self, eta: f64) -> Self {
1046 glam_assert!(self.is_normalized());
1047 glam_assert!(normal.is_normalized());
1048 let n_dot_i = normal.dot(self);
1049 let k = 1.0 - eta * eta * (1.0 - n_dot_i * n_dot_i);
1050 if k >= 0.0 {
1051 eta * self - (eta * n_dot_i + math::sqrt(k)) * normal
1052 } else {
1053 Self::ZERO
1054 }
1055 }
1056
1057 #[inline]
1059 #[must_use]
1060 pub fn as_vec4(&self) -> crate::Vec4 {
1061 crate::Vec4::new(self.x as f32, self.y as f32, self.z as f32, self.w as f32)
1062 }
1063
1064 #[inline]
1066 #[must_use]
1067 pub fn as_i8vec4(&self) -> crate::I8Vec4 {
1068 crate::I8Vec4::new(self.x as i8, self.y as i8, self.z as i8, self.w as i8)
1069 }
1070
1071 #[inline]
1073 #[must_use]
1074 pub fn as_u8vec4(&self) -> crate::U8Vec4 {
1075 crate::U8Vec4::new(self.x as u8, self.y as u8, self.z as u8, self.w as u8)
1076 }
1077
1078 #[inline]
1080 #[must_use]
1081 pub fn as_i16vec4(&self) -> crate::I16Vec4 {
1082 crate::I16Vec4::new(self.x as i16, self.y as i16, self.z as i16, self.w as i16)
1083 }
1084
1085 #[inline]
1087 #[must_use]
1088 pub fn as_u16vec4(&self) -> crate::U16Vec4 {
1089 crate::U16Vec4::new(self.x as u16, self.y as u16, self.z as u16, self.w as u16)
1090 }
1091
1092 #[inline]
1094 #[must_use]
1095 pub fn as_ivec4(&self) -> crate::IVec4 {
1096 crate::IVec4::new(self.x as i32, self.y as i32, self.z as i32, self.w as i32)
1097 }
1098
1099 #[inline]
1101 #[must_use]
1102 pub fn as_uvec4(&self) -> crate::UVec4 {
1103 crate::UVec4::new(self.x as u32, self.y as u32, self.z as u32, self.w as u32)
1104 }
1105
1106 #[inline]
1108 #[must_use]
1109 pub fn as_i64vec4(&self) -> crate::I64Vec4 {
1110 crate::I64Vec4::new(self.x as i64, self.y as i64, self.z as i64, self.w as i64)
1111 }
1112
1113 #[inline]
1115 #[must_use]
1116 pub fn as_u64vec4(&self) -> crate::U64Vec4 {
1117 crate::U64Vec4::new(self.x as u64, self.y as u64, self.z as u64, self.w as u64)
1118 }
1119
1120 #[inline]
1122 #[must_use]
1123 pub fn as_usizevec4(&self) -> crate::USizeVec4 {
1124 crate::USizeVec4::new(
1125 self.x as usize,
1126 self.y as usize,
1127 self.z as usize,
1128 self.w as usize,
1129 )
1130 }
1131}
1132
1133impl Default for DVec4 {
1134 #[inline(always)]
1135 fn default() -> Self {
1136 Self::ZERO
1137 }
1138}
1139
1140impl Div<DVec4> for DVec4 {
1141 type Output = Self;
1142 #[inline]
1143 fn div(self, rhs: Self) -> Self {
1144 Self {
1145 x: self.x.div(rhs.x),
1146 y: self.y.div(rhs.y),
1147 z: self.z.div(rhs.z),
1148 w: self.w.div(rhs.w),
1149 }
1150 }
1151}
1152
1153impl Div<&DVec4> for DVec4 {
1154 type Output = DVec4;
1155 #[inline]
1156 fn div(self, rhs: &DVec4) -> DVec4 {
1157 self.div(*rhs)
1158 }
1159}
1160
1161impl Div<&DVec4> for &DVec4 {
1162 type Output = DVec4;
1163 #[inline]
1164 fn div(self, rhs: &DVec4) -> DVec4 {
1165 (*self).div(*rhs)
1166 }
1167}
1168
1169impl Div<DVec4> for &DVec4 {
1170 type Output = DVec4;
1171 #[inline]
1172 fn div(self, rhs: DVec4) -> DVec4 {
1173 (*self).div(rhs)
1174 }
1175}
1176
1177impl DivAssign<DVec4> for DVec4 {
1178 #[inline]
1179 fn div_assign(&mut self, rhs: Self) {
1180 self.x.div_assign(rhs.x);
1181 self.y.div_assign(rhs.y);
1182 self.z.div_assign(rhs.z);
1183 self.w.div_assign(rhs.w);
1184 }
1185}
1186
1187impl DivAssign<&DVec4> for DVec4 {
1188 #[inline]
1189 fn div_assign(&mut self, rhs: &DVec4) {
1190 self.div_assign(*rhs)
1191 }
1192}
1193
1194impl Div<f64> for DVec4 {
1195 type Output = Self;
1196 #[inline]
1197 fn div(self, rhs: f64) -> Self {
1198 Self {
1199 x: self.x.div(rhs),
1200 y: self.y.div(rhs),
1201 z: self.z.div(rhs),
1202 w: self.w.div(rhs),
1203 }
1204 }
1205}
1206
1207impl Div<&f64> for DVec4 {
1208 type Output = DVec4;
1209 #[inline]
1210 fn div(self, rhs: &f64) -> DVec4 {
1211 self.div(*rhs)
1212 }
1213}
1214
1215impl Div<&f64> for &DVec4 {
1216 type Output = DVec4;
1217 #[inline]
1218 fn div(self, rhs: &f64) -> DVec4 {
1219 (*self).div(*rhs)
1220 }
1221}
1222
1223impl Div<f64> for &DVec4 {
1224 type Output = DVec4;
1225 #[inline]
1226 fn div(self, rhs: f64) -> DVec4 {
1227 (*self).div(rhs)
1228 }
1229}
1230
1231impl DivAssign<f64> for DVec4 {
1232 #[inline]
1233 fn div_assign(&mut self, rhs: f64) {
1234 self.x.div_assign(rhs);
1235 self.y.div_assign(rhs);
1236 self.z.div_assign(rhs);
1237 self.w.div_assign(rhs);
1238 }
1239}
1240
1241impl DivAssign<&f64> for DVec4 {
1242 #[inline]
1243 fn div_assign(&mut self, rhs: &f64) {
1244 self.div_assign(*rhs)
1245 }
1246}
1247
1248impl Div<DVec4> for f64 {
1249 type Output = DVec4;
1250 #[inline]
1251 fn div(self, rhs: DVec4) -> DVec4 {
1252 DVec4 {
1253 x: self.div(rhs.x),
1254 y: self.div(rhs.y),
1255 z: self.div(rhs.z),
1256 w: self.div(rhs.w),
1257 }
1258 }
1259}
1260
1261impl Div<&DVec4> for f64 {
1262 type Output = DVec4;
1263 #[inline]
1264 fn div(self, rhs: &DVec4) -> DVec4 {
1265 self.div(*rhs)
1266 }
1267}
1268
1269impl Div<&DVec4> for &f64 {
1270 type Output = DVec4;
1271 #[inline]
1272 fn div(self, rhs: &DVec4) -> DVec4 {
1273 (*self).div(*rhs)
1274 }
1275}
1276
1277impl Div<DVec4> for &f64 {
1278 type Output = DVec4;
1279 #[inline]
1280 fn div(self, rhs: DVec4) -> DVec4 {
1281 (*self).div(rhs)
1282 }
1283}
1284
1285impl Mul<DVec4> for DVec4 {
1286 type Output = Self;
1287 #[inline]
1288 fn mul(self, rhs: Self) -> Self {
1289 Self {
1290 x: self.x.mul(rhs.x),
1291 y: self.y.mul(rhs.y),
1292 z: self.z.mul(rhs.z),
1293 w: self.w.mul(rhs.w),
1294 }
1295 }
1296}
1297
1298impl Mul<&DVec4> for DVec4 {
1299 type Output = DVec4;
1300 #[inline]
1301 fn mul(self, rhs: &DVec4) -> DVec4 {
1302 self.mul(*rhs)
1303 }
1304}
1305
1306impl Mul<&DVec4> for &DVec4 {
1307 type Output = DVec4;
1308 #[inline]
1309 fn mul(self, rhs: &DVec4) -> DVec4 {
1310 (*self).mul(*rhs)
1311 }
1312}
1313
1314impl Mul<DVec4> for &DVec4 {
1315 type Output = DVec4;
1316 #[inline]
1317 fn mul(self, rhs: DVec4) -> DVec4 {
1318 (*self).mul(rhs)
1319 }
1320}
1321
1322impl MulAssign<DVec4> for DVec4 {
1323 #[inline]
1324 fn mul_assign(&mut self, rhs: Self) {
1325 self.x.mul_assign(rhs.x);
1326 self.y.mul_assign(rhs.y);
1327 self.z.mul_assign(rhs.z);
1328 self.w.mul_assign(rhs.w);
1329 }
1330}
1331
1332impl MulAssign<&DVec4> for DVec4 {
1333 #[inline]
1334 fn mul_assign(&mut self, rhs: &DVec4) {
1335 self.mul_assign(*rhs)
1336 }
1337}
1338
1339impl Mul<f64> for DVec4 {
1340 type Output = Self;
1341 #[inline]
1342 fn mul(self, rhs: f64) -> Self {
1343 Self {
1344 x: self.x.mul(rhs),
1345 y: self.y.mul(rhs),
1346 z: self.z.mul(rhs),
1347 w: self.w.mul(rhs),
1348 }
1349 }
1350}
1351
1352impl Mul<&f64> for DVec4 {
1353 type Output = DVec4;
1354 #[inline]
1355 fn mul(self, rhs: &f64) -> DVec4 {
1356 self.mul(*rhs)
1357 }
1358}
1359
1360impl Mul<&f64> for &DVec4 {
1361 type Output = DVec4;
1362 #[inline]
1363 fn mul(self, rhs: &f64) -> DVec4 {
1364 (*self).mul(*rhs)
1365 }
1366}
1367
1368impl Mul<f64> for &DVec4 {
1369 type Output = DVec4;
1370 #[inline]
1371 fn mul(self, rhs: f64) -> DVec4 {
1372 (*self).mul(rhs)
1373 }
1374}
1375
1376impl MulAssign<f64> for DVec4 {
1377 #[inline]
1378 fn mul_assign(&mut self, rhs: f64) {
1379 self.x.mul_assign(rhs);
1380 self.y.mul_assign(rhs);
1381 self.z.mul_assign(rhs);
1382 self.w.mul_assign(rhs);
1383 }
1384}
1385
1386impl MulAssign<&f64> for DVec4 {
1387 #[inline]
1388 fn mul_assign(&mut self, rhs: &f64) {
1389 self.mul_assign(*rhs)
1390 }
1391}
1392
1393impl Mul<DVec4> for f64 {
1394 type Output = DVec4;
1395 #[inline]
1396 fn mul(self, rhs: DVec4) -> DVec4 {
1397 DVec4 {
1398 x: self.mul(rhs.x),
1399 y: self.mul(rhs.y),
1400 z: self.mul(rhs.z),
1401 w: self.mul(rhs.w),
1402 }
1403 }
1404}
1405
1406impl Mul<&DVec4> for f64 {
1407 type Output = DVec4;
1408 #[inline]
1409 fn mul(self, rhs: &DVec4) -> DVec4 {
1410 self.mul(*rhs)
1411 }
1412}
1413
1414impl Mul<&DVec4> for &f64 {
1415 type Output = DVec4;
1416 #[inline]
1417 fn mul(self, rhs: &DVec4) -> DVec4 {
1418 (*self).mul(*rhs)
1419 }
1420}
1421
1422impl Mul<DVec4> for &f64 {
1423 type Output = DVec4;
1424 #[inline]
1425 fn mul(self, rhs: DVec4) -> DVec4 {
1426 (*self).mul(rhs)
1427 }
1428}
1429
1430impl Add<DVec4> for DVec4 {
1431 type Output = Self;
1432 #[inline]
1433 fn add(self, rhs: Self) -> Self {
1434 Self {
1435 x: self.x.add(rhs.x),
1436 y: self.y.add(rhs.y),
1437 z: self.z.add(rhs.z),
1438 w: self.w.add(rhs.w),
1439 }
1440 }
1441}
1442
1443impl Add<&DVec4> for DVec4 {
1444 type Output = DVec4;
1445 #[inline]
1446 fn add(self, rhs: &DVec4) -> DVec4 {
1447 self.add(*rhs)
1448 }
1449}
1450
1451impl Add<&DVec4> for &DVec4 {
1452 type Output = DVec4;
1453 #[inline]
1454 fn add(self, rhs: &DVec4) -> DVec4 {
1455 (*self).add(*rhs)
1456 }
1457}
1458
1459impl Add<DVec4> for &DVec4 {
1460 type Output = DVec4;
1461 #[inline]
1462 fn add(self, rhs: DVec4) -> DVec4 {
1463 (*self).add(rhs)
1464 }
1465}
1466
1467impl AddAssign<DVec4> for DVec4 {
1468 #[inline]
1469 fn add_assign(&mut self, rhs: Self) {
1470 self.x.add_assign(rhs.x);
1471 self.y.add_assign(rhs.y);
1472 self.z.add_assign(rhs.z);
1473 self.w.add_assign(rhs.w);
1474 }
1475}
1476
1477impl AddAssign<&DVec4> for DVec4 {
1478 #[inline]
1479 fn add_assign(&mut self, rhs: &DVec4) {
1480 self.add_assign(*rhs)
1481 }
1482}
1483
1484impl Add<f64> for DVec4 {
1485 type Output = Self;
1486 #[inline]
1487 fn add(self, rhs: f64) -> Self {
1488 Self {
1489 x: self.x.add(rhs),
1490 y: self.y.add(rhs),
1491 z: self.z.add(rhs),
1492 w: self.w.add(rhs),
1493 }
1494 }
1495}
1496
1497impl Add<&f64> for DVec4 {
1498 type Output = DVec4;
1499 #[inline]
1500 fn add(self, rhs: &f64) -> DVec4 {
1501 self.add(*rhs)
1502 }
1503}
1504
1505impl Add<&f64> for &DVec4 {
1506 type Output = DVec4;
1507 #[inline]
1508 fn add(self, rhs: &f64) -> DVec4 {
1509 (*self).add(*rhs)
1510 }
1511}
1512
1513impl Add<f64> for &DVec4 {
1514 type Output = DVec4;
1515 #[inline]
1516 fn add(self, rhs: f64) -> DVec4 {
1517 (*self).add(rhs)
1518 }
1519}
1520
1521impl AddAssign<f64> for DVec4 {
1522 #[inline]
1523 fn add_assign(&mut self, rhs: f64) {
1524 self.x.add_assign(rhs);
1525 self.y.add_assign(rhs);
1526 self.z.add_assign(rhs);
1527 self.w.add_assign(rhs);
1528 }
1529}
1530
1531impl AddAssign<&f64> for DVec4 {
1532 #[inline]
1533 fn add_assign(&mut self, rhs: &f64) {
1534 self.add_assign(*rhs)
1535 }
1536}
1537
1538impl Add<DVec4> for f64 {
1539 type Output = DVec4;
1540 #[inline]
1541 fn add(self, rhs: DVec4) -> DVec4 {
1542 DVec4 {
1543 x: self.add(rhs.x),
1544 y: self.add(rhs.y),
1545 z: self.add(rhs.z),
1546 w: self.add(rhs.w),
1547 }
1548 }
1549}
1550
1551impl Add<&DVec4> for f64 {
1552 type Output = DVec4;
1553 #[inline]
1554 fn add(self, rhs: &DVec4) -> DVec4 {
1555 self.add(*rhs)
1556 }
1557}
1558
1559impl Add<&DVec4> for &f64 {
1560 type Output = DVec4;
1561 #[inline]
1562 fn add(self, rhs: &DVec4) -> DVec4 {
1563 (*self).add(*rhs)
1564 }
1565}
1566
1567impl Add<DVec4> for &f64 {
1568 type Output = DVec4;
1569 #[inline]
1570 fn add(self, rhs: DVec4) -> DVec4 {
1571 (*self).add(rhs)
1572 }
1573}
1574
1575impl Sub<DVec4> for DVec4 {
1576 type Output = Self;
1577 #[inline]
1578 fn sub(self, rhs: Self) -> Self {
1579 Self {
1580 x: self.x.sub(rhs.x),
1581 y: self.y.sub(rhs.y),
1582 z: self.z.sub(rhs.z),
1583 w: self.w.sub(rhs.w),
1584 }
1585 }
1586}
1587
1588impl Sub<&DVec4> for DVec4 {
1589 type Output = DVec4;
1590 #[inline]
1591 fn sub(self, rhs: &DVec4) -> DVec4 {
1592 self.sub(*rhs)
1593 }
1594}
1595
1596impl Sub<&DVec4> for &DVec4 {
1597 type Output = DVec4;
1598 #[inline]
1599 fn sub(self, rhs: &DVec4) -> DVec4 {
1600 (*self).sub(*rhs)
1601 }
1602}
1603
1604impl Sub<DVec4> for &DVec4 {
1605 type Output = DVec4;
1606 #[inline]
1607 fn sub(self, rhs: DVec4) -> DVec4 {
1608 (*self).sub(rhs)
1609 }
1610}
1611
1612impl SubAssign<DVec4> for DVec4 {
1613 #[inline]
1614 fn sub_assign(&mut self, rhs: DVec4) {
1615 self.x.sub_assign(rhs.x);
1616 self.y.sub_assign(rhs.y);
1617 self.z.sub_assign(rhs.z);
1618 self.w.sub_assign(rhs.w);
1619 }
1620}
1621
1622impl SubAssign<&DVec4> for DVec4 {
1623 #[inline]
1624 fn sub_assign(&mut self, rhs: &DVec4) {
1625 self.sub_assign(*rhs)
1626 }
1627}
1628
1629impl Sub<f64> for DVec4 {
1630 type Output = Self;
1631 #[inline]
1632 fn sub(self, rhs: f64) -> Self {
1633 Self {
1634 x: self.x.sub(rhs),
1635 y: self.y.sub(rhs),
1636 z: self.z.sub(rhs),
1637 w: self.w.sub(rhs),
1638 }
1639 }
1640}
1641
1642impl Sub<&f64> for DVec4 {
1643 type Output = DVec4;
1644 #[inline]
1645 fn sub(self, rhs: &f64) -> DVec4 {
1646 self.sub(*rhs)
1647 }
1648}
1649
1650impl Sub<&f64> for &DVec4 {
1651 type Output = DVec4;
1652 #[inline]
1653 fn sub(self, rhs: &f64) -> DVec4 {
1654 (*self).sub(*rhs)
1655 }
1656}
1657
1658impl Sub<f64> for &DVec4 {
1659 type Output = DVec4;
1660 #[inline]
1661 fn sub(self, rhs: f64) -> DVec4 {
1662 (*self).sub(rhs)
1663 }
1664}
1665
1666impl SubAssign<f64> for DVec4 {
1667 #[inline]
1668 fn sub_assign(&mut self, rhs: f64) {
1669 self.x.sub_assign(rhs);
1670 self.y.sub_assign(rhs);
1671 self.z.sub_assign(rhs);
1672 self.w.sub_assign(rhs);
1673 }
1674}
1675
1676impl SubAssign<&f64> for DVec4 {
1677 #[inline]
1678 fn sub_assign(&mut self, rhs: &f64) {
1679 self.sub_assign(*rhs)
1680 }
1681}
1682
1683impl Sub<DVec4> for f64 {
1684 type Output = DVec4;
1685 #[inline]
1686 fn sub(self, rhs: DVec4) -> DVec4 {
1687 DVec4 {
1688 x: self.sub(rhs.x),
1689 y: self.sub(rhs.y),
1690 z: self.sub(rhs.z),
1691 w: self.sub(rhs.w),
1692 }
1693 }
1694}
1695
1696impl Sub<&DVec4> for f64 {
1697 type Output = DVec4;
1698 #[inline]
1699 fn sub(self, rhs: &DVec4) -> DVec4 {
1700 self.sub(*rhs)
1701 }
1702}
1703
1704impl Sub<&DVec4> for &f64 {
1705 type Output = DVec4;
1706 #[inline]
1707 fn sub(self, rhs: &DVec4) -> DVec4 {
1708 (*self).sub(*rhs)
1709 }
1710}
1711
1712impl Sub<DVec4> for &f64 {
1713 type Output = DVec4;
1714 #[inline]
1715 fn sub(self, rhs: DVec4) -> DVec4 {
1716 (*self).sub(rhs)
1717 }
1718}
1719
1720impl Rem<DVec4> for DVec4 {
1721 type Output = Self;
1722 #[inline]
1723 fn rem(self, rhs: Self) -> Self {
1724 Self {
1725 x: self.x.rem(rhs.x),
1726 y: self.y.rem(rhs.y),
1727 z: self.z.rem(rhs.z),
1728 w: self.w.rem(rhs.w),
1729 }
1730 }
1731}
1732
1733impl Rem<&DVec4> for DVec4 {
1734 type Output = DVec4;
1735 #[inline]
1736 fn rem(self, rhs: &DVec4) -> DVec4 {
1737 self.rem(*rhs)
1738 }
1739}
1740
1741impl Rem<&DVec4> for &DVec4 {
1742 type Output = DVec4;
1743 #[inline]
1744 fn rem(self, rhs: &DVec4) -> DVec4 {
1745 (*self).rem(*rhs)
1746 }
1747}
1748
1749impl Rem<DVec4> for &DVec4 {
1750 type Output = DVec4;
1751 #[inline]
1752 fn rem(self, rhs: DVec4) -> DVec4 {
1753 (*self).rem(rhs)
1754 }
1755}
1756
1757impl RemAssign<DVec4> for DVec4 {
1758 #[inline]
1759 fn rem_assign(&mut self, rhs: Self) {
1760 self.x.rem_assign(rhs.x);
1761 self.y.rem_assign(rhs.y);
1762 self.z.rem_assign(rhs.z);
1763 self.w.rem_assign(rhs.w);
1764 }
1765}
1766
1767impl RemAssign<&DVec4> for DVec4 {
1768 #[inline]
1769 fn rem_assign(&mut self, rhs: &DVec4) {
1770 self.rem_assign(*rhs)
1771 }
1772}
1773
1774impl Rem<f64> for DVec4 {
1775 type Output = Self;
1776 #[inline]
1777 fn rem(self, rhs: f64) -> Self {
1778 Self {
1779 x: self.x.rem(rhs),
1780 y: self.y.rem(rhs),
1781 z: self.z.rem(rhs),
1782 w: self.w.rem(rhs),
1783 }
1784 }
1785}
1786
1787impl Rem<&f64> for DVec4 {
1788 type Output = DVec4;
1789 #[inline]
1790 fn rem(self, rhs: &f64) -> DVec4 {
1791 self.rem(*rhs)
1792 }
1793}
1794
1795impl Rem<&f64> for &DVec4 {
1796 type Output = DVec4;
1797 #[inline]
1798 fn rem(self, rhs: &f64) -> DVec4 {
1799 (*self).rem(*rhs)
1800 }
1801}
1802
1803impl Rem<f64> for &DVec4 {
1804 type Output = DVec4;
1805 #[inline]
1806 fn rem(self, rhs: f64) -> DVec4 {
1807 (*self).rem(rhs)
1808 }
1809}
1810
1811impl RemAssign<f64> for DVec4 {
1812 #[inline]
1813 fn rem_assign(&mut self, rhs: f64) {
1814 self.x.rem_assign(rhs);
1815 self.y.rem_assign(rhs);
1816 self.z.rem_assign(rhs);
1817 self.w.rem_assign(rhs);
1818 }
1819}
1820
1821impl RemAssign<&f64> for DVec4 {
1822 #[inline]
1823 fn rem_assign(&mut self, rhs: &f64) {
1824 self.rem_assign(*rhs)
1825 }
1826}
1827
1828impl Rem<DVec4> for f64 {
1829 type Output = DVec4;
1830 #[inline]
1831 fn rem(self, rhs: DVec4) -> DVec4 {
1832 DVec4 {
1833 x: self.rem(rhs.x),
1834 y: self.rem(rhs.y),
1835 z: self.rem(rhs.z),
1836 w: self.rem(rhs.w),
1837 }
1838 }
1839}
1840
1841impl Rem<&DVec4> for f64 {
1842 type Output = DVec4;
1843 #[inline]
1844 fn rem(self, rhs: &DVec4) -> DVec4 {
1845 self.rem(*rhs)
1846 }
1847}
1848
1849impl Rem<&DVec4> for &f64 {
1850 type Output = DVec4;
1851 #[inline]
1852 fn rem(self, rhs: &DVec4) -> DVec4 {
1853 (*self).rem(*rhs)
1854 }
1855}
1856
1857impl Rem<DVec4> for &f64 {
1858 type Output = DVec4;
1859 #[inline]
1860 fn rem(self, rhs: DVec4) -> DVec4 {
1861 (*self).rem(rhs)
1862 }
1863}
1864
1865#[cfg(not(target_arch = "spirv"))]
1866impl AsRef<[f64; 4]> for DVec4 {
1867 #[inline]
1868 fn as_ref(&self) -> &[f64; 4] {
1869 unsafe { &*(self as *const DVec4 as *const [f64; 4]) }
1870 }
1871}
1872
1873#[cfg(not(target_arch = "spirv"))]
1874impl AsMut<[f64; 4]> for DVec4 {
1875 #[inline]
1876 fn as_mut(&mut self) -> &mut [f64; 4] {
1877 unsafe { &mut *(self as *mut DVec4 as *mut [f64; 4]) }
1878 }
1879}
1880
1881impl Sum for DVec4 {
1882 #[inline]
1883 fn sum<I>(iter: I) -> Self
1884 where
1885 I: Iterator<Item = Self>,
1886 {
1887 iter.fold(Self::ZERO, Self::add)
1888 }
1889}
1890
1891impl<'a> Sum<&'a Self> for DVec4 {
1892 #[inline]
1893 fn sum<I>(iter: I) -> Self
1894 where
1895 I: Iterator<Item = &'a Self>,
1896 {
1897 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1898 }
1899}
1900
1901impl Product for DVec4 {
1902 #[inline]
1903 fn product<I>(iter: I) -> Self
1904 where
1905 I: Iterator<Item = Self>,
1906 {
1907 iter.fold(Self::ONE, Self::mul)
1908 }
1909}
1910
1911impl<'a> Product<&'a Self> for DVec4 {
1912 #[inline]
1913 fn product<I>(iter: I) -> Self
1914 where
1915 I: Iterator<Item = &'a Self>,
1916 {
1917 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1918 }
1919}
1920
1921impl Neg for DVec4 {
1922 type Output = Self;
1923 #[inline]
1924 fn neg(self) -> Self {
1925 Self {
1926 x: self.x.neg(),
1927 y: self.y.neg(),
1928 z: self.z.neg(),
1929 w: self.w.neg(),
1930 }
1931 }
1932}
1933
1934impl Neg for &DVec4 {
1935 type Output = DVec4;
1936 #[inline]
1937 fn neg(self) -> DVec4 {
1938 (*self).neg()
1939 }
1940}
1941
1942impl Index<usize> for DVec4 {
1943 type Output = f64;
1944 #[inline]
1945 fn index(&self, index: usize) -> &Self::Output {
1946 match index {
1947 0 => &self.x,
1948 1 => &self.y,
1949 2 => &self.z,
1950 3 => &self.w,
1951 _ => panic!("index out of bounds"),
1952 }
1953 }
1954}
1955
1956impl IndexMut<usize> for DVec4 {
1957 #[inline]
1958 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1959 match index {
1960 0 => &mut self.x,
1961 1 => &mut self.y,
1962 2 => &mut self.z,
1963 3 => &mut self.w,
1964 _ => panic!("index out of bounds"),
1965 }
1966 }
1967}
1968
1969impl fmt::Display for DVec4 {
1970 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1971 if let Some(p) = f.precision() {
1972 write!(
1973 f,
1974 "[{:.*}, {:.*}, {:.*}, {:.*}]",
1975 p, self.x, p, self.y, p, self.z, p, self.w
1976 )
1977 } else {
1978 write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
1979 }
1980 }
1981}
1982
1983impl fmt::Debug for DVec4 {
1984 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1985 fmt.debug_tuple(stringify!(DVec4))
1986 .field(&self.x)
1987 .field(&self.y)
1988 .field(&self.z)
1989 .field(&self.w)
1990 .finish()
1991 }
1992}
1993
1994impl From<[f64; 4]> for DVec4 {
1995 #[inline]
1996 fn from(a: [f64; 4]) -> Self {
1997 Self::new(a[0], a[1], a[2], a[3])
1998 }
1999}
2000
2001impl From<DVec4> for [f64; 4] {
2002 #[inline]
2003 fn from(v: DVec4) -> Self {
2004 [v.x, v.y, v.z, v.w]
2005 }
2006}
2007
2008impl From<(f64, f64, f64, f64)> for DVec4 {
2009 #[inline]
2010 fn from(t: (f64, f64, f64, f64)) -> Self {
2011 Self::new(t.0, t.1, t.2, t.3)
2012 }
2013}
2014
2015impl From<DVec4> for (f64, f64, f64, f64) {
2016 #[inline]
2017 fn from(v: DVec4) -> Self {
2018 (v.x, v.y, v.z, v.w)
2019 }
2020}
2021
2022impl From<(DVec3, f64)> for DVec4 {
2023 #[inline]
2024 fn from((v, w): (DVec3, f64)) -> Self {
2025 Self::new(v.x, v.y, v.z, w)
2026 }
2027}
2028
2029impl From<(f64, DVec3)> for DVec4 {
2030 #[inline]
2031 fn from((x, v): (f64, DVec3)) -> Self {
2032 Self::new(x, v.x, v.y, v.z)
2033 }
2034}
2035
2036impl From<(DVec2, f64, f64)> for DVec4 {
2037 #[inline]
2038 fn from((v, z, w): (DVec2, f64, f64)) -> Self {
2039 Self::new(v.x, v.y, z, w)
2040 }
2041}
2042
2043impl From<(DVec2, DVec2)> for DVec4 {
2044 #[inline]
2045 fn from((v, u): (DVec2, DVec2)) -> Self {
2046 Self::new(v.x, v.y, u.x, u.y)
2047 }
2048}
2049
2050impl From<Vec4> for DVec4 {
2051 #[inline]
2052 fn from(v: Vec4) -> Self {
2053 Self::new(
2054 f64::from(v.x),
2055 f64::from(v.y),
2056 f64::from(v.z),
2057 f64::from(v.w),
2058 )
2059 }
2060}
2061
2062impl From<IVec4> for DVec4 {
2063 #[inline]
2064 fn from(v: IVec4) -> Self {
2065 Self::new(
2066 f64::from(v.x),
2067 f64::from(v.y),
2068 f64::from(v.z),
2069 f64::from(v.w),
2070 )
2071 }
2072}
2073
2074impl From<UVec4> for DVec4 {
2075 #[inline]
2076 fn from(v: UVec4) -> Self {
2077 Self::new(
2078 f64::from(v.x),
2079 f64::from(v.y),
2080 f64::from(v.z),
2081 f64::from(v.w),
2082 )
2083 }
2084}
2085
2086impl From<BVec4> for DVec4 {
2087 #[inline]
2088 fn from(v: BVec4) -> Self {
2089 Self::new(
2090 f64::from(v.x),
2091 f64::from(v.y),
2092 f64::from(v.z),
2093 f64::from(v.w),
2094 )
2095 }
2096}
2097
2098#[cfg(not(feature = "scalar-math"))]
2099impl From<BVec4A> for DVec4 {
2100 #[inline]
2101 fn from(v: BVec4A) -> Self {
2102 let bool_array: [bool; 4] = v.into();
2103 Self::new(
2104 f64::from(bool_array[0]),
2105 f64::from(bool_array[1]),
2106 f64::from(bool_array[2]),
2107 f64::from(bool_array[3]),
2108 )
2109 }
2110}