ruby_math/algebra/vec/
vec3d.rs

1#![allow(dead_code)]
2
3use std::{
4    fmt::Display,
5    ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign},
6};
7
8use super::{vec3f, Vec2d, Vec3f, Vec4d};
9
10#[derive(Clone, Copy, PartialEq, Debug)]
11pub struct Vec3d {
12    x: f64,
13    y: f64,
14    z: f64,
15}
16
17pub fn vec3d(x: f64, y: f64, z: f64) -> Vec3d {
18    Vec3d::new(x, y, z)
19}
20
21impl Display for Vec3d {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        write!(f, "Vec3d(x: {}, y: {}, z: {})", self.x, self.y, self.z)
24    }
25}
26
27impl Default for Vec3d {
28    fn default() -> Self {
29        Self::new(0.0, 0.0, 0.0)
30    }
31}
32
33impl Add<Vec3d> for Vec3d {
34    type Output = Vec3d;
35
36    fn add(self, rhs: Vec3d) -> Self::Output {
37        Vec3d::new(self.x + rhs.x, self.y + rhs.y, self.z + rhs.z)
38    }
39}
40
41impl Add<f64> for Vec3d {
42    type Output = Vec3d;
43
44    fn add(self, rhs: f64) -> Self::Output {
45        Vec3d::new(self.x + rhs, self.y + rhs, self.z + rhs)
46    }
47}
48
49impl Add<Vec3d> for f64 {
50    type Output = Vec3d;
51
52    fn add(self, rhs: Vec3d) -> Self::Output {
53        Vec3d::new(self + rhs.x, self + rhs.y, self + rhs.z)
54    }
55}
56
57impl AddAssign<Vec3d> for Vec3d {
58    fn add_assign(&mut self, rhs: Vec3d) {
59        self.x += rhs.x;
60        self.y += rhs.y;
61        self.z += rhs.z;
62    }
63}
64
65impl AddAssign<f64> for Vec3d {
66    fn add_assign(&mut self, rhs: f64) {
67        self.x += rhs;
68        self.y += rhs;
69        self.z += rhs;
70    }
71}
72
73impl Sub<Vec3d> for Vec3d {
74    type Output = Vec3d;
75
76    fn sub(self, rhs: Vec3d) -> Self::Output {
77        Vec3d::new(self.x - rhs.x, self.y - rhs.y, self.z - rhs.z)
78    }
79}
80
81impl Sub<f64> for Vec3d {
82    type Output = Vec3d;
83
84    fn sub(self, rhs: f64) -> Self::Output {
85        Vec3d::new(self.x - rhs, self.y - rhs, self.z - rhs)
86    }
87}
88
89impl Sub<Vec3d> for f64 {
90    type Output = Vec3d;
91
92    fn sub(self, rhs: Vec3d) -> Self::Output {
93        Vec3d::new(self - rhs.x, self - rhs.y, self - rhs.z)
94    }
95}
96
97impl SubAssign<Vec3d> for Vec3d {
98    fn sub_assign(&mut self, rhs: Vec3d) {
99        self.x -= rhs.x;
100        self.y -= rhs.y;
101        self.z -= rhs.z;
102    }
103}
104
105impl SubAssign<f64> for Vec3d {
106    fn sub_assign(&mut self, rhs: f64) {
107        self.x -= rhs;
108        self.y -= rhs;
109        self.z -= rhs;
110    }
111}
112
113impl Mul<Vec3d> for Vec3d {
114    type Output = Vec3d;
115
116    fn mul(self, rhs: Vec3d) -> Self::Output {
117        Vec3d::new(self.x * rhs.x, self.y * rhs.y, self.z * rhs.z)
118    }
119}
120
121impl Mul<f64> for Vec3d {
122    type Output = Vec3d;
123
124    fn mul(self, rhs: f64) -> Self::Output {
125        Vec3d::new(self.x * rhs, self.y * rhs, self.z * rhs)
126    }
127}
128
129impl Mul<Vec3d> for f64 {
130    type Output = Vec3d;
131
132    fn mul(self, rhs: Vec3d) -> Self::Output {
133        Vec3d::new(self * rhs.x, self * rhs.y, self * rhs.z)
134    }
135}
136
137impl MulAssign<Vec3d> for Vec3d {
138    fn mul_assign(&mut self, rhs: Vec3d) {
139        self.x *= rhs.x;
140        self.y *= rhs.y;
141        self.z *= rhs.z;
142    }
143}
144
145impl MulAssign<f64> for Vec3d {
146    fn mul_assign(&mut self, rhs: f64) {
147        self.x *= rhs;
148        self.y *= rhs;
149        self.z *= rhs;
150    }
151}
152
153impl Div<Vec3d> for Vec3d {
154    type Output = Vec3d;
155
156    fn div(self, rhs: Vec3d) -> Self::Output {
157        Vec3d::new(self.x / rhs.x, self.y / rhs.y, self.z / rhs.z)
158    }
159}
160
161impl Div<f64> for Vec3d {
162    type Output = Vec3d;
163
164    fn div(self, rhs: f64) -> Self::Output {
165        Vec3d::new(self.x / rhs, self.y / rhs, self.z / rhs)
166    }
167}
168
169impl Div<Vec3d> for f64 {
170    type Output = Vec3d;
171
172    fn div(self, rhs: Vec3d) -> Self::Output {
173        Vec3d::new(self / rhs.x, self / rhs.y, self / rhs.z)
174    }
175}
176
177impl DivAssign<Vec3d> for Vec3d {
178    fn div_assign(&mut self, rhs: Vec3d) {
179        self.x /= rhs.x;
180        self.y /= rhs.y;
181        self.z /= rhs.z;
182    }
183}
184
185impl DivAssign<f64> for Vec3d {
186    fn div_assign(&mut self, rhs: f64) {
187        self.x /= rhs;
188        self.y /= rhs;
189        self.z /= rhs;
190    }
191}
192
193impl Neg for Vec3d {
194    type Output = Vec3d;
195
196    fn neg(self) -> Self::Output {
197        Self::new(-self.x, -self.y, -self.z)
198    }
199}
200
201impl Index<usize> for Vec3d {
202    type Output = f64;
203
204    fn index(&self, index: usize) -> &Self::Output {
205        match index {
206            0 => &self.x,
207            1 => &self.y,
208            2 => &self.z,
209            _ => panic!("`rmath::algebra::Vec3d::index`: index out of bounds."),
210        }
211    }
212}
213
214impl IndexMut<usize> for Vec3d {
215    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
216        match index {
217            0 => &mut self.x,
218            1 => &mut self.y,
219            2 => &mut self.z,
220            _ => panic!("`rmath::algebra::Vec3d::index_mut`: index out of bounds."),
221        }
222    }
223}
224
225impl From<f64> for Vec3d {
226    fn from(v: f64) -> Self {
227        Self::new(v, v, v)
228    }
229}
230
231impl From<(f64, f64, f64)> for Vec3d {
232    fn from(v: (f64, f64, f64)) -> Self {
233        let (x, y, z) = v;
234        Self::new(x, y, z)
235    }
236}
237
238impl From<(Vec2d, f64)> for Vec3d {
239    fn from(v: (Vec2d, f64)) -> Self {
240        let (xy, z) = v;
241        let (x, y) = xy.to_tuple();
242        Self::new(x, y, z)
243    }
244}
245
246impl From<Vec4d> for Vec3d {
247    fn from(v: Vec4d) -> Self {
248        v.xyz()
249    }
250}
251
252impl Vec3d {
253    pub fn new(x: f64, y: f64, z: f64) -> Self {
254        Self { x, y, z }
255    }
256
257    pub fn one() -> Self {
258        Self::new(1.0, 1.0, 1.0)
259    }
260
261    pub fn zero() -> Self {
262        Self::new(0.0, 0.0, 0.0)
263    }
264}
265
266impl Vec3d {
267    pub fn floor(self) -> Self {
268        Self::new(self.x.floor(), self.y.floor(), self.z.floor())
269    }
270
271    pub fn ceil(self) -> Self {
272        Self::new(self.x.ceil(), self.y.ceil(), self.z.ceil())
273    }
274
275    pub fn round(self) -> Self {
276        Self::new(self.x.round(), self.y.round(), self.z.round())
277    }
278
279    pub fn trunc(self) -> Self {
280        Self::new(self.x.trunc(), self.y.trunc(), self.z.trunc())
281    }
282
283    pub fn fract(self) -> Self {
284        Self::new(self.x.fract(), self.y.fract(), self.z.fract())
285    }
286
287    pub fn abs(self) -> Self {
288        Self::new(self.x.abs(), self.y.abs(), self.z.abs())
289    }
290
291    pub fn signum(self) -> Self {
292        Self::new(self.x.signum(), self.y.signum(), self.z.signum())
293    }
294
295    pub fn powf(self, n: f64) -> Self {
296        Self::new(self.x.powf(n), self.y.powf(n), self.z.powf(n))
297    }
298
299    pub fn sqrt(self) -> Self {
300        Self::new(self.x.sqrt(), self.y.sqrt(), self.z.sqrt())
301    }
302
303    pub fn exp(self) -> Self {
304        Self::new(self.x.exp(), self.y.exp(), self.z.exp())
305    }
306
307    pub fn exp2(self) -> Self {
308        Self::new(self.x.exp2(), self.y.exp2(), self.z.exp2())
309    }
310
311    pub fn ln(self) -> Self {
312        Self::new(self.x.ln(), self.y.ln(), self.z.ln())
313    }
314
315    pub fn log(self, base: f64) -> Self {
316        Self::new(self.x.log(base), self.y.log(base), self.z.log(base))
317    }
318
319    pub fn log2(self) -> Self {
320        Self::new(self.x.log2(), self.y.log2(), self.z.log2())
321    }
322
323    pub fn log10(self) -> Self {
324        Self::new(self.x.log10(), self.y.log10(), self.z.log10())
325    }
326
327    pub fn cbrt(self) -> Self {
328        Self::new(self.x.cbrt(), self.y.cbrt(), self.z.cbrt())
329    }
330
331    pub fn sin(self) -> Self {
332        Self::new(self.x.sin(), self.y.sin(), self.z.sin())
333    }
334
335    pub fn cos(self) -> Self {
336        Self::new(self.x.cos(), self.y.cos(), self.z.cos())
337    }
338
339    pub fn tan(self) -> Self {
340        Self::new(self.x.tan(), self.y.tan(), self.z.tan())
341    }
342
343    pub fn sin_cos(self) -> (Self, Self) {
344        (self.sin(), self.cos())
345    }
346
347    pub fn lerp(self, rhs: Self, s: f64) -> Self {
348        self + (rhs - self) * s
349    }
350
351    pub fn lerp_vec(self, rhs: Self, s: Self) -> Self {
352        self + (rhs - self) * s
353    }
354
355    pub fn is_nan(self) -> bool {
356        self.x.is_nan() || self.y.is_nan() || self.z.is_nan()
357    }
358
359    pub fn is_infinite(self) -> bool {
360        self.x.is_infinite() || self.y.is_infinite() || self.z.is_infinite()
361    }
362
363    pub fn is_finite(self) -> bool {
364        self.x.is_finite() && self.y.is_finite() && self.z.is_finite()
365    }
366
367    pub fn recip(self) -> Self {
368        Self::new(self.x.recip(), self.y.recip(), self.z.recip())
369    }
370
371    pub fn max(self, rhs: Self) -> Self {
372        Self::new(self.x.max(rhs.x), self.y.max(rhs.y), self.z.max(rhs.z))
373    }
374
375    pub fn min(self, rhs: Self) -> Self {
376        Self::new(self.x.min(rhs.x), self.y.min(rhs.y), self.z.min(rhs.z))
377    }
378
379    pub fn clamp(self, min: Self, max: Self) -> Self {
380        ruby_assert!(min.x <= max.x);
381        ruby_assert!(min.y <= max.y);
382        ruby_assert!(min.z <= max.z);
383
384        self.min(max).max(min)
385    }
386
387    pub fn saturate(self) -> Self {
388        self.clamp(Self::zero(), Self::one())
389    }
390
391    pub fn min_element(self) -> f64 {
392        self.x.min(self.y).min(self.z)
393    }
394
395    pub fn max_element(self) -> f64 {
396        self.x.max(self.y).max(self.z)
397    }
398}
399
400impl Vec3d {
401    pub fn dot(self, rhs: Self) -> f64 {
402        self.x * rhs.x + self.y * rhs.y + self.z * rhs.z
403    }
404
405    pub fn cross(self, rhs: Self) -> Self {
406        Self::new(
407            self.y * rhs.z - self.z * rhs.y,
408            self.z * rhs.x - self.x * rhs.z,
409            self.x * rhs.y - self.y * rhs.x,
410        )
411    }
412
413    pub fn length(self) -> f64 {
414        self.dot(self).sqrt()
415    }
416
417    pub fn length_squared(self) -> f64 {
418        self.dot(self)
419    }
420
421    pub fn length_recip(self) -> f64 {
422        self.length().recip()
423    }
424
425    pub fn distance(self, rhs: Self) -> f64 {
426        (rhs - self).length()
427    }
428
429    pub fn distance_squared(self, rhs: Self) -> f64 {
430        (rhs - self).length_squared()
431    }
432
433    pub fn normalize(self) -> Self {
434        let normalized = self * self.length_recip();
435        ruby_assert!(normalized.is_finite());
436        normalized
437    }
438
439    pub fn try_normalize(self) -> Option<Self> {
440        let recip = self.length_recip();
441        if recip.is_finite() && recip > 0.0 {
442            Some(self * recip)
443        } else {
444            None
445        }
446    }
447
448    pub fn normalize_or_zero(self) -> Self {
449        let recip = self.length_recip();
450        if recip.is_finite() && recip > 0.0 {
451            self * recip
452        } else {
453            Self::zero()
454        }
455    }
456
457    pub fn is_normalized(self) -> bool {
458        (self.length_squared() - 1.0f64).abs() < f64::EPSILON
459    }
460
461    pub fn angle_between(self, rhs: Self) -> f64 {
462        self.dot(rhs)
463            .div(self.length_squared().mul(rhs.length_squared()).sqrt())
464            .acos()
465    }
466}
467
468impl Vec3d {
469    pub fn to_array(self) -> [f64; 3] {
470        [self.x, self.y, self.z]
471    }
472
473    pub fn to_tuple(self) -> (f64, f64, f64) {
474        (self.x, self.y, self.z)
475    }
476
477    pub fn to_vec3f(self) -> Vec3f {
478        vec3f(self.x as f32, self.y as f32, self.z as f32)
479    }
480
481    pub fn to_homogeneous_coord_point(self) -> Vec4d {
482        Vec4d::from((self, 1.0))
483    }
484
485    pub fn to_homogeneous_coord_vector(self) -> Vec4d {
486        Vec4d::from((self, 0.0))
487    }
488}
489
490impl Vec3d {
491    pub fn x(self) -> f64 {
492        self.x
493    }
494
495    pub fn y(self) -> f64 {
496        self.y
497    }
498
499    pub fn z(self) -> f64 {
500        self.z
501    }
502
503    pub fn xx(self) -> Vec2d {
504        Vec2d::new(self.x, self.x)
505    }
506
507    pub fn xy(self) -> Vec2d {
508        Vec2d::new(self.x, self.y)
509    }
510
511    pub fn xz(self) -> Vec2d {
512        Vec2d::new(self.x, self.z)
513    }
514
515    pub fn yx(self) -> Vec2d {
516        Vec2d::new(self.y, self.x)
517    }
518
519    pub fn yy(self) -> Vec2d {
520        Vec2d::new(self.y, self.y)
521    }
522
523    pub fn yz(self) -> Vec2d {
524        Vec2d::new(self.y, self.z)
525    }
526
527    pub fn zx(self) -> Vec2d {
528        Vec2d::new(self.z, self.x)
529    }
530
531    pub fn zy(self) -> Vec2d {
532        Vec2d::new(self.z, self.y)
533    }
534
535    pub fn zz(self) -> Vec2d {
536        Vec2d::new(self.z, self.z)
537    }
538
539    pub fn xxx(self) -> Self {
540        Self::new(self.x, self.x, self.x)
541    }
542
543    pub fn xxy(self) -> Self {
544        Self::new(self.x, self.x, self.y)
545    }
546
547    pub fn xxz(self) -> Self {
548        Self::new(self.x, self.x, self.z)
549    }
550
551    pub fn xyx(self) -> Self {
552        Self::new(self.x, self.y, self.x)
553    }
554
555    pub fn xyy(self) -> Self {
556        Self::new(self.x, self.y, self.y)
557    }
558
559    pub fn xyz(self) -> Self {
560        Self::new(self.x, self.y, self.z)
561    }
562
563    pub fn xzx(self) -> Self {
564        Self::new(self.x, self.z, self.x)
565    }
566
567    pub fn xzy(self) -> Self {
568        Self::new(self.x, self.z, self.y)
569    }
570
571    pub fn xzz(self) -> Self {
572        Self::new(self.x, self.z, self.z)
573    }
574
575    pub fn yxx(self) -> Self {
576        Self::new(self.y, self.x, self.x)
577    }
578
579    pub fn yxy(self) -> Self {
580        Self::new(self.y, self.x, self.y)
581    }
582
583    pub fn yxz(self) -> Self {
584        Self::new(self.y, self.x, self.z)
585    }
586
587    pub fn yyx(self) -> Self {
588        Self::new(self.y, self.y, self.x)
589    }
590
591    pub fn yyy(self) -> Self {
592        Self::new(self.y, self.y, self.y)
593    }
594
595    pub fn yyz(self) -> Self {
596        Self::new(self.y, self.y, self.z)
597    }
598
599    pub fn yzx(self) -> Self {
600        Self::new(self.y, self.z, self.x)
601    }
602
603    pub fn yzy(self) -> Self {
604        Self::new(self.y, self.z, self.y)
605    }
606
607    pub fn yzz(self) -> Self {
608        Self::new(self.y, self.z, self.z)
609    }
610
611    pub fn zxx(self) -> Self {
612        Self::new(self.z, self.x, self.x)
613    }
614
615    pub fn zxy(self) -> Self {
616        Self::new(self.z, self.x, self.y)
617    }
618
619    pub fn zxz(self) -> Self {
620        Self::new(self.z, self.x, self.z)
621    }
622
623    pub fn zyx(self) -> Self {
624        Self::new(self.z, self.y, self.x)
625    }
626
627    pub fn zyy(self) -> Self {
628        Self::new(self.z, self.y, self.y)
629    }
630
631    pub fn zyz(self) -> Self {
632        Self::new(self.z, self.y, self.z)
633    }
634
635    pub fn zzx(self) -> Self {
636        Self::new(self.z, self.z, self.x)
637    }
638
639    pub fn zzy(self) -> Self {
640        Self::new(self.z, self.z, self.y)
641    }
642
643    pub fn zzz(self) -> Self {
644        Self::new(self.z, self.z, self.z)
645    }
646
647    pub fn xxxx(self) -> Vec4d {
648        Vec4d::new(self.x, self.x, self.x, self.x)
649    }
650
651    pub fn xxxy(self) -> Vec4d {
652        Vec4d::new(self.x, self.x, self.x, self.y)
653    }
654
655    pub fn xxxz(self) -> Vec4d {
656        Vec4d::new(self.x, self.x, self.x, self.z)
657    }
658
659    pub fn xxyx(self) -> Vec4d {
660        Vec4d::new(self.x, self.x, self.y, self.x)
661    }
662
663    pub fn xxyy(self) -> Vec4d {
664        Vec4d::new(self.x, self.x, self.y, self.y)
665    }
666
667    pub fn xxyz(self) -> Vec4d {
668        Vec4d::new(self.x, self.x, self.y, self.z)
669    }
670
671    pub fn xxzx(self) -> Vec4d {
672        Vec4d::new(self.x, self.x, self.z, self.x)
673    }
674
675    pub fn xxzy(self) -> Vec4d {
676        Vec4d::new(self.x, self.x, self.z, self.y)
677    }
678
679    pub fn xxzz(self) -> Vec4d {
680        Vec4d::new(self.x, self.x, self.z, self.z)
681    }
682
683    pub fn xyxx(self) -> Vec4d {
684        Vec4d::new(self.x, self.y, self.x, self.x)
685    }
686
687    pub fn xyxy(self) -> Vec4d {
688        Vec4d::new(self.x, self.y, self.x, self.y)
689    }
690
691    pub fn xyxz(self) -> Vec4d {
692        Vec4d::new(self.x, self.y, self.x, self.z)
693    }
694
695    pub fn xyyx(self) -> Vec4d {
696        Vec4d::new(self.x, self.y, self.y, self.x)
697    }
698
699    pub fn xyyy(self) -> Vec4d {
700        Vec4d::new(self.x, self.y, self.y, self.y)
701    }
702
703    pub fn xyyz(self) -> Vec4d {
704        Vec4d::new(self.x, self.y, self.y, self.z)
705    }
706
707    pub fn xyzx(self) -> Vec4d {
708        Vec4d::new(self.x, self.y, self.z, self.x)
709    }
710
711    pub fn xyzy(self) -> Vec4d {
712        Vec4d::new(self.x, self.y, self.z, self.y)
713    }
714
715    pub fn xyzz(self) -> Vec4d {
716        Vec4d::new(self.x, self.y, self.z, self.z)
717    }
718
719    pub fn xzxx(self) -> Vec4d {
720        Vec4d::new(self.x, self.z, self.x, self.x)
721    }
722
723    pub fn xzxy(self) -> Vec4d {
724        Vec4d::new(self.x, self.z, self.x, self.y)
725    }
726
727    pub fn xzxz(self) -> Vec4d {
728        Vec4d::new(self.x, self.z, self.x, self.z)
729    }
730
731    pub fn xzyx(self) -> Vec4d {
732        Vec4d::new(self.x, self.z, self.y, self.x)
733    }
734
735    pub fn xzyy(self) -> Vec4d {
736        Vec4d::new(self.x, self.z, self.y, self.y)
737    }
738
739    pub fn xzyz(self) -> Vec4d {
740        Vec4d::new(self.x, self.z, self.y, self.z)
741    }
742
743    pub fn xzzx(self) -> Vec4d {
744        Vec4d::new(self.x, self.z, self.z, self.x)
745    }
746
747    pub fn xzzy(self) -> Vec4d {
748        Vec4d::new(self.x, self.z, self.z, self.y)
749    }
750
751    pub fn xzzz(self) -> Vec4d {
752        Vec4d::new(self.x, self.z, self.z, self.z)
753    }
754
755    pub fn yxxx(self) -> Vec4d {
756        Vec4d::new(self.y, self.x, self.x, self.x)
757    }
758
759    pub fn yxxy(self) -> Vec4d {
760        Vec4d::new(self.y, self.x, self.x, self.y)
761    }
762
763    pub fn yxxz(self) -> Vec4d {
764        Vec4d::new(self.y, self.x, self.x, self.z)
765    }
766
767    pub fn yxyx(self) -> Vec4d {
768        Vec4d::new(self.y, self.x, self.y, self.x)
769    }
770
771    pub fn yxyy(self) -> Vec4d {
772        Vec4d::new(self.y, self.x, self.y, self.y)
773    }
774
775    pub fn yxyz(self) -> Vec4d {
776        Vec4d::new(self.y, self.x, self.y, self.z)
777    }
778
779    pub fn yxzx(self) -> Vec4d {
780        Vec4d::new(self.y, self.x, self.z, self.x)
781    }
782
783    pub fn yxzy(self) -> Vec4d {
784        Vec4d::new(self.y, self.x, self.z, self.y)
785    }
786
787    pub fn yxzz(self) -> Vec4d {
788        Vec4d::new(self.y, self.x, self.z, self.z)
789    }
790
791    pub fn yyxx(self) -> Vec4d {
792        Vec4d::new(self.y, self.y, self.x, self.x)
793    }
794
795    pub fn yyxy(self) -> Vec4d {
796        Vec4d::new(self.y, self.y, self.x, self.y)
797    }
798
799    pub fn yyxz(self) -> Vec4d {
800        Vec4d::new(self.y, self.y, self.x, self.z)
801    }
802
803    pub fn yyyx(self) -> Vec4d {
804        Vec4d::new(self.y, self.y, self.y, self.x)
805    }
806
807    pub fn yyyy(self) -> Vec4d {
808        Vec4d::new(self.y, self.y, self.y, self.y)
809    }
810
811    pub fn yyyz(self) -> Vec4d {
812        Vec4d::new(self.y, self.y, self.y, self.z)
813    }
814
815    pub fn yyzx(self) -> Vec4d {
816        Vec4d::new(self.y, self.y, self.z, self.x)
817    }
818
819    pub fn yyzy(self) -> Vec4d {
820        Vec4d::new(self.y, self.y, self.z, self.y)
821    }
822
823    pub fn yyzz(self) -> Vec4d {
824        Vec4d::new(self.y, self.y, self.z, self.z)
825    }
826
827    pub fn yzxx(self) -> Vec4d {
828        Vec4d::new(self.y, self.z, self.x, self.x)
829    }
830
831    pub fn yzxy(self) -> Vec4d {
832        Vec4d::new(self.y, self.z, self.x, self.y)
833    }
834
835    pub fn yzxz(self) -> Vec4d {
836        Vec4d::new(self.y, self.z, self.x, self.z)
837    }
838
839    pub fn yzyx(self) -> Vec4d {
840        Vec4d::new(self.y, self.z, self.y, self.x)
841    }
842
843    pub fn yzyy(self) -> Vec4d {
844        Vec4d::new(self.y, self.z, self.y, self.y)
845    }
846
847    pub fn yzyz(self) -> Vec4d {
848        Vec4d::new(self.y, self.z, self.y, self.z)
849    }
850
851    pub fn yzzx(self) -> Vec4d {
852        Vec4d::new(self.y, self.z, self.z, self.x)
853    }
854
855    pub fn yzzy(self) -> Vec4d {
856        Vec4d::new(self.y, self.z, self.z, self.y)
857    }
858
859    pub fn yzzz(self) -> Vec4d {
860        Vec4d::new(self.y, self.z, self.z, self.z)
861    }
862
863    pub fn zxxx(self) -> Vec4d {
864        Vec4d::new(self.z, self.x, self.x, self.x)
865    }
866
867    pub fn zxxy(self) -> Vec4d {
868        Vec4d::new(self.z, self.x, self.x, self.y)
869    }
870
871    pub fn zxxz(self) -> Vec4d {
872        Vec4d::new(self.z, self.x, self.x, self.z)
873    }
874
875    pub fn zxyx(self) -> Vec4d {
876        Vec4d::new(self.z, self.x, self.y, self.x)
877    }
878
879    pub fn zxyy(self) -> Vec4d {
880        Vec4d::new(self.z, self.x, self.y, self.y)
881    }
882
883    pub fn zxyz(self) -> Vec4d {
884        Vec4d::new(self.z, self.x, self.y, self.z)
885    }
886
887    pub fn zxzx(self) -> Vec4d {
888        Vec4d::new(self.z, self.x, self.z, self.x)
889    }
890
891    pub fn zxzy(self) -> Vec4d {
892        Vec4d::new(self.z, self.x, self.z, self.y)
893    }
894
895    pub fn zxzz(self) -> Vec4d {
896        Vec4d::new(self.z, self.x, self.z, self.z)
897    }
898
899    pub fn zyxx(self) -> Vec4d {
900        Vec4d::new(self.z, self.y, self.x, self.x)
901    }
902
903    pub fn zyxy(self) -> Vec4d {
904        Vec4d::new(self.z, self.y, self.x, self.y)
905    }
906
907    pub fn zyxz(self) -> Vec4d {
908        Vec4d::new(self.z, self.y, self.x, self.z)
909    }
910
911    pub fn zyyx(self) -> Vec4d {
912        Vec4d::new(self.z, self.y, self.y, self.x)
913    }
914
915    pub fn zyyy(self) -> Vec4d {
916        Vec4d::new(self.z, self.y, self.y, self.y)
917    }
918
919    pub fn zyyz(self) -> Vec4d {
920        Vec4d::new(self.z, self.y, self.y, self.z)
921    }
922
923    pub fn zyzx(self) -> Vec4d {
924        Vec4d::new(self.z, self.y, self.z, self.x)
925    }
926
927    pub fn zyzy(self) -> Vec4d {
928        Vec4d::new(self.z, self.y, self.z, self.y)
929    }
930
931    pub fn zyzz(self) -> Vec4d {
932        Vec4d::new(self.z, self.y, self.z, self.z)
933    }
934
935    pub fn zzxx(self) -> Vec4d {
936        Vec4d::new(self.z, self.z, self.x, self.x)
937    }
938
939    pub fn zzxy(self) -> Vec4d {
940        Vec4d::new(self.z, self.z, self.x, self.y)
941    }
942
943    pub fn zzxz(self) -> Vec4d {
944        Vec4d::new(self.z, self.z, self.x, self.z)
945    }
946
947    pub fn zzyx(self) -> Vec4d {
948        Vec4d::new(self.z, self.z, self.y, self.x)
949    }
950
951    pub fn zzyy(self) -> Vec4d {
952        Vec4d::new(self.z, self.z, self.y, self.y)
953    }
954
955    pub fn zzyz(self) -> Vec4d {
956        Vec4d::new(self.z, self.z, self.y, self.z)
957    }
958
959    pub fn zzzx(self) -> Vec4d {
960        Vec4d::new(self.z, self.z, self.z, self.x)
961    }
962
963    pub fn zzzy(self) -> Vec4d {
964        Vec4d::new(self.z, self.z, self.z, self.y)
965    }
966
967    pub fn zzzz(self) -> Vec4d {
968        Vec4d::new(self.z, self.z, self.z, self.z)
969    }
970}