Debian Codegraph @

debian/missing-sources/glam-0.16.0/src/core/scalar/vector.rs

raw symbols SCIP
1 use crate::core::{
2 storage::{XY, XYZ, XYZF32A16, XYZW},
3 traits::{scalar::*, vector::*},
4 };
5
6 impl<T: NumEx> VectorConst for XY<T> {
7 const ZERO: Self = Self {
8 x: <T as NumConstEx>::ZERO,
9 y: <T as NumConstEx>::ZERO,
10 };
11 const ONE: Self = Self {
12 x: <T as NumConstEx>::ONE,
13 y: <T as NumConstEx>::ONE,
14 };
15 }
16
17 impl<T: NumEx> Vector2Const for XY<T> {
18 const X: Self = Self {
19 x: <T as NumConstEx>::ONE,
20 y: <T as NumConstEx>::ZERO,
21 };
22 const Y: Self = Self {
23 x: <T as NumConstEx>::ZERO,
24 y: <T as NumConstEx>::ONE,
25 };
26 }
27
28 impl<T: NumEx> VectorConst for XYZ<T> {
29 const ZERO: Self = Self {
30 x: <T as NumConstEx>::ZERO,
31 y: <T as NumConstEx>::ZERO,
32 z: <T as NumConstEx>::ZERO,
33 };
34 const ONE: Self = Self {
35 x: <T as NumConstEx>::ONE,
36 y: <T as NumConstEx>::ONE,
37 z: <T as NumConstEx>::ONE,
38 };
39 }
40
41 impl<T: NumEx> Vector3Const for XYZ<T> {
42 const X: Self = Self {
43 x: <T as NumConstEx>::ONE,
44 y: <T as NumConstEx>::ZERO,
45 z: <T as NumConstEx>::ZERO,
46 };
47 const Y: Self = Self {
48 x: <T as NumConstEx>::ZERO,
49 y: <T as NumConstEx>::ONE,
50 z: <T as NumConstEx>::ZERO,
51 };
52 const Z: Self = Self {
53 x: <T as NumConstEx>::ZERO,
54 y: <T as NumConstEx>::ZERO,
55 z: <T as NumConstEx>::ONE,
56 };
57 }
58
59 impl<T: NumEx> VectorConst for XYZW<T> {
60 const ZERO: Self = Self {
61 x: <T as NumConstEx>::ZERO,
62 y: <T as NumConstEx>::ZERO,
63 z: <T as NumConstEx>::ZERO,
64 w: <T as NumConstEx>::ZERO,
65 };
66 const ONE: Self = Self {
67 x: <T as NumConstEx>::ONE,
68 y: <T as NumConstEx>::ONE,
69 z: <T as NumConstEx>::ONE,
70 w: <T as NumConstEx>::ONE,
71 };
72 }
73 impl<T: NumEx> Vector4Const for XYZW<T> {
74 const X: Self = Self {
75 x: <T as NumConstEx>::ONE,
76 y: <T as NumConstEx>::ZERO,
77 z: <T as NumConstEx>::ZERO,
78 w: <T as NumConstEx>::ZERO,
79 };
80 const Y: Self = Self {
81 x: <T as NumConstEx>::ZERO,
82 y: <T as NumConstEx>::ONE,
83 z: <T as NumConstEx>::ZERO,
84 w: <T as NumConstEx>::ZERO,
85 };
86 const Z: Self = Self {
87 x: <T as NumConstEx>::ZERO,
88 y: <T as NumConstEx>::ZERO,
89 z: <T as NumConstEx>::ONE,
90 w: <T as NumConstEx>::ZERO,
91 };
92 const W: Self = Self {
93 x: <T as NumConstEx>::ZERO,
94 y: <T as NumConstEx>::ZERO,
95 z: <T as NumConstEx>::ZERO,
96 w: <T as NumConstEx>::ONE,
97 };
98 }
99
100 impl<T: NumEx> Vector<T> for XY<T> {
101 type Mask = XY<bool>;
102
103 #[inline]
104 fn splat(s: T) -> Self {
105 Self { x: s, y: s }
106 }
107
108 #[inline]
109 fn select(mask: Self::Mask, if_true: Self, if_false: Self) -> Self {
110 Self {
111 x: if mask.x { if_true.x } else { if_false.x },
112 y: if mask.y { if_true.y } else { if_false.y },
113 }
114 }
115
116 #[inline]
117 fn cmpeq(self, other: Self) -> Self::Mask {
118 Self::Mask {
119 x: self.x.eq(&other.x),
120 y: self.y.eq(&other.y),
121 }
122 }
123
124 #[inline]
125 fn cmpne(self, other: Self) -> Self::Mask {
126 Self::Mask {
127 x: self.x.ne(&other.x),
128 y: self.y.ne(&other.y),
129 }
130 }
131
132 #[inline]
133 fn cmpge(self, other: Self) -> Self::Mask {
134 Self::Mask {
135 x: self.x.ge(&other.x),
136 y: self.y.ge(&other.y),
137 }
138 }
139
140 #[inline]
141 fn cmpgt(self, other: Self) -> Self::Mask {
142 Self::Mask {
143 x: self.x.gt(&other.x),
144 y: self.y.gt(&other.y),
145 }
146 }
147
148 #[inline]
149 fn cmple(self, other: Self) -> Self::Mask {
150 Self::Mask {
151 x: self.x.le(&other.x),
152 y: self.y.le(&other.y),
153 }
154 }
155
156 #[inline]
157 fn cmplt(self, other: Self) -> Self::Mask {
158 Self::Mask {
159 x: self.x.lt(&other.x),
160 y: self.y.lt(&other.y),
161 }
162 }
163
164 #[inline]
165 fn add(self, other: Self) -> Self {
166 Self {
167 x: self.x + other.x,
168 y: self.y + other.y,
169 }
170 }
171
172 #[inline]
173 fn div(self, other: Self) -> Self {
174 Self {
175 x: self.x / other.x,
176 y: self.y / other.y,
177 }
178 }
179
180 #[inline]
181 fn mul(self, other: Self) -> Self {
182 Self {
183 x: self.x * other.x,
184 y: self.y * other.y,
185 }
186 }
187
188 #[inline]
189 fn mul_add(self, b: Self, c: Self) -> Self {
190 Self {
191 x: self.x * b.x + c.x,
192 y: self.y * b.y + c.y,
193 }
194 }
195
196 #[inline]
197 fn sub(self, other: Self) -> Self {
198 Self {
199 x: self.x - other.x,
200 y: self.y - other.y,
201 }
202 }
203
204 #[inline]
205 fn mul_scalar(self, other: T) -> Self {
206 Self {
207 x: self.x * other,
208 y: self.y * other,
209 }
210 }
211
212 #[inline]
213 fn div_scalar(self, other: T) -> Self {
214 Self {
215 x: self.x / other,
216 y: self.y / other,
217 }
218 }
219
220 #[inline]
221 fn min(self, other: Self) -> Self {
222 Self {
223 x: self.x.min(other.x),
224 y: self.y.min(other.y),
225 }
226 }
227
228 #[inline]
229 fn max(self, other: Self) -> Self {
230 Self {
231 x: self.x.max(other.x),
232 y: self.y.max(other.y),
233 }
234 }
235 }
236
237 impl<T: NumEx> Vector<T> for XYZ<T> {
238 type Mask = XYZ<bool>;
239
240 #[inline]
241 fn splat(s: T) -> Self {
242 Self { x: s, y: s, z: s }
243 }
244
245 #[inline]
246 fn select(mask: Self::Mask, if_true: Self, if_false: Self) -> Self {
247 Self {
248 x: if mask.x { if_true.x } else { if_false.x },
249 y: if mask.y { if_true.y } else { if_false.y },
250 z: if mask.z { if_true.z } else { if_false.z },
251 }
252 }
253
254 #[inline]
255 fn cmpeq(self, other: Self) -> Self::Mask {
256 Self::Mask {
257 x: self.x.eq(&other.x),
258 y: self.y.eq(&other.y),
259 z: self.z.eq(&other.z),
260 }
261 }
262
263 #[inline]
264 fn cmpne(self, other: Self) -> Self::Mask {
265 Self::Mask {
266 x: self.x.ne(&other.x),
267 y: self.y.ne(&other.y),
268 z: self.z.ne(&other.z),
269 }
270 }
271
272 #[inline]
273 fn cmpge(self, other: Self) -> Self::Mask {
274 Self::Mask {
275 x: self.x.ge(&other.x),
276 y: self.y.ge(&other.y),
277 z: self.z.ge(&other.z),
278 }
279 }
280
281 #[inline]
282 fn cmpgt(self, other: Self) -> Self::Mask {
283 Self::Mask {
284 x: self.x.gt(&other.x),
285 y: self.y.gt(&other.y),
286 z: self.z.gt(&other.z),
287 }
288 }
289
290 #[inline]
291 fn cmple(self, other: Self) -> Self::Mask {
292 Self::Mask {
293 x: self.x.le(&other.x),
294 y: self.y.le(&other.y),
295 z: self.z.le(&other.z),
296 }
297 }
298
299 #[inline]
300 fn cmplt(self, other: Self) -> Self::Mask {
301 Self::Mask {
302 x: self.x.lt(&other.x),
303 y: self.y.lt(&other.y),
304 z: self.z.lt(&other.z),
305 }
306 }
307
308 #[inline]
309 fn add(self, other: Self) -> Self {
310 Self {
311 x: self.x + other.x,
312 y: self.y + other.y,
313 z: self.z + other.z,
314 }
315 }
316
317 #[inline]
318 fn div(self, other: Self) -> Self {
319 Self {
320 x: self.x / other.x,
321 y: self.y / other.y,
322 z: self.z / other.z,
323 }
324 }
325
326 #[inline]
327 fn mul(self, other: Self) -> Self {
328 Self {
329 x: self.x * other.x,
330 y: self.y * other.y,
331 z: self.z * other.z,
332 }
333 }
334
335 #[inline]
336 fn mul_add(self, b: Self, c: Self) -> Self {
337 Self {
338 x: self.x * b.x + c.x,
339 y: self.y * b.y + c.y,
340 z: self.z * b.z + c.z,
341 }
342 }
343
344 #[inline]
345 fn sub(self, other: Self) -> Self {
346 Self {
347 x: self.x - other.x,
348 y: self.y - other.y,
349 z: self.z - other.z,
350 }
351 }
352
353 #[inline]
354 fn mul_scalar(self, other: T) -> Self {
355 Self {
356 x: self.x * other,
357 y: self.y * other,
358 z: self.z * other,
359 }
360 }
361
362 #[inline]
363 fn div_scalar(self, other: T) -> Self {
364 Self {
365 x: self.x / other,
366 y: self.y / other,
367 z: self.z / other,
368 }
369 }
370
371 #[inline]
372 fn min(self, other: Self) -> Self {
373 Self {
374 x: self.x.min(other.x),
375 y: self.y.min(other.y),
376 z: self.z.min(other.z),
377 }
378 }
379
380 #[inline]
381 fn max(self, other: Self) -> Self {
382 Self {
383 x: self.x.max(other.x),
384 y: self.y.max(other.y),
385 z: self.z.max(other.z),
386 }
387 }
388 }
389
390 impl<T: NumEx> Vector<T> for XYZW<T> {
391 type Mask = XYZW<bool>;
392
393 #[inline]
394 fn splat(s: T) -> Self {
395 Self {
396 x: s,
397 y: s,
398 z: s,
399 w: s,
400 }
401 }
402
403 #[inline]
404 fn select(mask: Self::Mask, if_true: Self, if_false: Self) -> Self {
405 Self {
406 x: if mask.x { if_true.x } else { if_false.x },
407 y: if mask.y { if_true.y } else { if_false.y },
408 z: if mask.z { if_true.z } else { if_false.z },
409 w: if mask.w { if_true.w } else { if_false.w },
410 }
411 }
412
413 #[inline]
414 fn cmpeq(self, other: Self) -> Self::Mask {
415 Self::Mask {
416 x: self.x.eq(&other.x),
417 y: self.y.eq(&other.y),
418 z: self.z.eq(&other.z),
419 w: self.w.eq(&other.w),
420 }
421 }
422
423 #[inline]
424 fn cmpne(self, other: Self) -> Self::Mask {
425 Self::Mask {
426 x: self.x.ne(&other.x),
427 y: self.y.ne(&other.y),
428 z: self.z.ne(&other.z),
429 w: self.w.ne(&other.w),
430 }
431 }
432
433 #[inline]
434 fn cmpge(self, other: Self) -> Self::Mask {
435 Self::Mask {
436 x: self.x.ge(&other.x),
437 y: self.y.ge(&other.y),
438 z: self.z.ge(&other.z),
439 w: self.w.ge(&other.w),
440 }
441 }
442
443 #[inline]
444 fn cmpgt(self, other: Self) -> Self::Mask {
445 Self::Mask {
446 x: self.x.gt(&other.x),
447 y: self.y.gt(&other.y),
448 z: self.z.gt(&other.z),
449 w: self.w.gt(&other.w),
450 }
451 }
452
453 #[inline]
454 fn cmple(self, other: Self) -> Self::Mask {
455 Self::Mask {
456 x: self.x.le(&other.x),
457 y: self.y.le(&other.y),
458 z: self.z.le(&other.z),
459 w: self.w.le(&other.w),
460 }
461 }
462
463 #[inline]
464 fn cmplt(self, other: Self) -> Self::Mask {
465 Self::Mask {
466 x: self.x.lt(&other.x),
467 y: self.y.lt(&other.y),
468 z: self.z.lt(&other.z),
469 w: self.w.lt(&other.w),
470 }
471 }
472
473 #[inline]
474 fn add(self, other: Self) -> Self {
475 Self {
476 x: self.x + other.x,
477 y: self.y + other.y,
478 z: self.z + other.z,
479 w: self.w + other.w,
480 }
481 }
482
483 #[inline]
484 fn div(self, other: Self) -> Self {
485 Self {
486 x: self.x / other.x,
487 y: self.y / other.y,
488 z: self.z / other.z,
489 w: self.w / other.w,
490 }
491 }
492
493 #[inline]
494 fn mul(self, other: Self) -> Self {
495 Self {
496 x: self.x * other.x,
497 y: self.y * other.y,
498 z: self.z * other.z,
499 w: self.w * other.w,
500 }
501 }
502
503 #[inline]
504 fn mul_add(self, b: Self, c: Self) -> Self {
505 Self {
506 x: self.x * b.x + c.x,
507 y: self.y * b.y + c.y,
508 z: self.z * b.z + c.z,
509 w: self.w * b.w + c.w,
510 }
511 }
512
513 #[inline]
514 fn sub(self, other: Self) -> Self {
515 Self {
516 x: self.x - other.x,
517 y: self.y - other.y,
518 z: self.z - other.z,
519 w: self.w - other.w,
520 }
521 }
522
523 #[inline]
524 fn mul_scalar(self, other: T) -> Self {
525 Self {
526 x: self.x * other,
527 y: self.y * other,
528 z: self.z * other,
529 w: self.w * other,
530 }
531 }
532
533 #[inline]
534 fn div_scalar(self, other: T) -> Self {
535 Self {
536 x: self.x / other,
537 y: self.y / other,
538 z: self.z / other,
539 w: self.w / other,
540 }
541 }
542
543 #[inline]
544 fn min(self, other: Self) -> Self {
545 Self {
546 x: self.x.min(other.x),
547 y: self.y.min(other.y),
548 z: self.z.min(other.z),
549 w: self.w.min(other.w),
550 }
551 }
552
553 #[inline]
554 fn max(self, other: Self) -> Self {
555 Self {
556 x: self.x.max(other.x),
557 y: self.y.max(other.y),
558 z: self.z.max(other.z),
559 w: self.w.max(other.w),
560 }
561 }
562 }
563
564 impl<T: NumEx> Vector2<T> for XY<T> {
565 #[inline(always)]
566 fn new(x: T, y: T) -> Self {
567 Self { x, y }
568 }
569
570 #[inline(always)]
571 fn x(self) -> T {
572 self.x
573 }
574
575 #[inline(always)]
576 fn y(self) -> T {
577 self.y
578 }
579
580 #[inline(always)]
581 fn as_ref_xy(&self) -> &XY<T> {
582 self
583 }
584
585 #[inline(always)]
586 fn as_mut_xy(&mut self) -> &mut XY<T> {
587 self
588 }
589
590 #[inline]
591 fn min_element(self) -> T {
592 self.x.min(self.y)
593 }
594
595 #[inline]
596 fn max_element(self) -> T {
597 self.x.max(self.y)
598 }
599
600 #[inline]
601 fn clamp(self, min: Self, max: Self) -> Self {
602 glam_assert!(min.x <= max.x);
603 glam_assert!(min.y <= max.y);
604 // we intentionally do not use `f32::clamp` because we don't
605 // want panics unless `glam-assert` feature is on.
606 Self {
607 x: self.x.max(min.x).min(max.x),
608 y: self.y.max(min.y).min(max.y),
609 }
610 }
611 }
612
613 impl<T: NumEx> Vector3<T> for XYZ<T> {
614 #[inline(always)]
615 fn new(x: T, y: T, z: T) -> Self {
616 Self { x, y, z }
617 }
618
619 #[inline(always)]
620 fn x(self) -> T {
621 self.x
622 }
623
624 #[inline(always)]
625 fn y(self) -> T {
626 self.y
627 }
628
629 #[inline(always)]
630 fn z(self) -> T {
631 self.z
632 }
633
634 #[inline(always)]
635 fn as_ref_xyz(&self) -> &XYZ<T> {
636 self
637 }
638
639 #[inline(always)]
640 fn as_mut_xyz(&mut self) -> &mut XYZ<T> {
641 self
642 }
643
644 #[inline]
645 fn min_element(self) -> T {
646 self.x.min(self.y.min(self.z))
647 }
648
649 #[inline]
650 fn max_element(self) -> T {
651 self.x.max(self.y.max(self.z))
652 }
653
654 #[inline]
655 fn clamp(self, min: Self, max: Self) -> Self {
656 glam_assert!(min.x <= max.x);
657 glam_assert!(min.y <= max.y);
658 glam_assert!(min.z <= max.z);
659 // we intentionally do not use `f32::clamp` because we don't
660 // want panics unless `glam-assert` feature is on.
661 Self::new(
662 self.x.max(min.x).min(max.x),
663 self.y.max(min.y).min(max.y),
664 self.z.max(min.z).min(max.z),
665 )
666 }
667 }
668
669 impl<T: NumEx> Vector4<T> for XYZW<T> {
670 #[inline(always)]
671 fn new(x: T, y: T, z: T, w: T) -> Self {
672 Self { x, y, z, w }
673 }
674
675 #[inline(always)]
676 fn x(self) -> T {
677 self.x
678 }
679
680 #[inline(always)]
681 fn y(self) -> T {
682 self.y
683 }
684
685 #[inline(always)]
686 fn z(self) -> T {
687 self.z
688 }
689
690 #[inline(always)]
691 fn w(self) -> T {
692 self.w
693 }
694
695 #[inline(always)]
696 fn as_ref_xyzw(&self) -> &XYZW<T> {
697 self
698 }
699
700 #[inline(always)]
701 fn as_mut_xyzw(&mut self) -> &mut XYZW<T> {
702 self
703 }
704
705 #[inline]
706 fn min_element(self) -> T {
707 self.x.min(self.y.min(self.z.min(self.w)))
708 }
709
710 #[inline]
711 fn max_element(self) -> T {
712 self.x.max(self.y.max(self.z.min(self.w)))
713 }
714
715 #[inline]
716 fn clamp(self, min: Self, max: Self) -> Self {
717 glam_assert!(min.x <= max.x);
718 glam_assert!(min.y <= max.y);
719 glam_assert!(min.z <= max.z);
720 glam_assert!(min.w <= max.w);
721 // we intentionally do not use `f32::clamp` because we don't
722 // want panics unless `glam-assert` feature is on.
723 Self {
724 x: self.x.max(min.x).min(max.x),
725 y: self.y.max(min.y).min(max.y),
726 z: self.z.max(min.z).min(max.z),
727 w: self.w.max(min.w).min(max.w),
728 }
729 }
730 }
731
732 impl<T: SignedEx> SignedVector<T> for XY<T> {
733 #[inline]
734 fn neg(self) -> Self {
735 Self {
736 x: self.x.neg(),
737 y: self.y.neg(),
738 }
739 }
740 }
741
742 impl<T: SignedEx> SignedVector2<T> for XY<T> {}
743
744 impl<T: SignedEx> SignedVector<T> for XYZ<T> {
745 #[inline]
746 fn neg(self) -> Self {
747 Self {
748 x: self.x.neg(),
749 y: self.y.neg(),
750 z: self.z.neg(),
751 }
752 }
753 }
754
755 impl<T: SignedEx> SignedVector<T> for XYZW<T> {
756 #[inline]
757 fn neg(self) -> Self {
758 Self {
759 x: self.x.neg(),
760 y: self.y.neg(),
761 z: self.z.neg(),
762 w: self.w.neg(),
763 }
764 }
765 }
766
767 impl<T: SignedEx> SignedVector3<T> for XYZ<T> {}
768 impl<T: SignedEx> SignedVector4<T> for XYZW<T> {}
769
770 impl<T: FloatEx> FloatVector2<T> for XY<T> {}
771 impl<T: FloatEx> FloatVector3<T> for XYZ<T> {}
772 impl<T: FloatEx> FloatVector4<T> for XYZW<T> {}
773
774 impl<T> From<XYZ<T>> for XY<T> {
775 #[inline(always)]
776 fn from(v: XYZ<T>) -> Self {
777 Self { x: v.x, y: v.y }
778 }
779 }
780
781 impl<T> From<XYZW<T>> for XY<T> {
782 #[inline(always)]
783 fn from(v: XYZW<T>) -> Self {
784 Self { x: v.x, y: v.y }
785 }
786 }
787
788 impl<T> From<XYZW<T>> for XYZ<T> {
789 #[inline(always)]
790 fn from(v: XYZW<T>) -> Self {
791 Self {
792 x: v.x,
793 y: v.y,
794 z: v.z,
795 }
796 }
797 }
798
799 impl VectorConst for XYZF32A16 {
800 const ZERO: Self = Self {
801 x: 0.0,
802 y: 0.0,
803 z: 0.0,
804 };
805 const ONE: Self = Self {
806 x: 1.0,
807 y: 1.0,
808 z: 1.0,
809 };
810 }
811
812 impl Vector3Const for XYZF32A16 {
813 const X: Self = Self {
814 x: 1.0,
815 y: 0.0,
816 z: 0.0,
817 };
818 const Y: Self = Self {
819 x: 0.0,
820 y: 1.0,
821 z: 0.0,
822 };
823 const Z: Self = Self {
824 x: 0.0,
825 y: 0.0,
826 z: 1.0,
827 };
828 }
829
830 impl Vector<f32> for XYZF32A16 {
831 type Mask = XYZ<bool>;
832
833 #[inline]
834 fn splat(s: f32) -> Self {
835 Self { x: s, y: s, z: s }
836 }
837
838 #[inline]
839 fn select(mask: Self::Mask, if_true: Self, if_false: Self) -> Self {
840 XYZ::select(mask, if_true.into(), if_false.into()).into()
841 }
842
843 #[inline]
844 fn cmpeq(self, other: Self) -> Self::Mask {
845 XYZ::cmpeq(self.into(), other.into())
846 }
847
848 #[inline]
849 fn cmpne(self, other: Self) -> Self::Mask {
850 XYZ::cmpne(self.into(), other.into())
851 }
852
853 #[inline]
854 fn cmpge(self, other: Self) -> Self::Mask {
855 XYZ::cmpge(self.into(), other.into())
856 }
857
858 #[inline]
859 fn cmpgt(self, other: Self) -> Self::Mask {
860 XYZ::cmpgt(self.into(), other.into())
861 }
862
863 #[inline]
864 fn cmple(self, other: Self) -> Self::Mask {
865 XYZ::cmple(self.into(), other.into())
866 }
867
868 #[inline]
869 fn cmplt(self, other: Self) -> Self::Mask {
870 XYZ::cmplt(self.into(), other.into())
871 }
872
873 #[inline]
874 fn add(self, other: Self) -> Self {
875 XYZ::add(self.into(), other.into()).into()
876 }
877
878 #[inline]
879 fn div(self, other: Self) -> Self {
880 XYZ::div(self.into(), other.into()).into()
881 }
882
883 #[inline]
884 fn mul(self, other: Self) -> Self {
885 XYZ::mul(self.into(), other.into()).into()
886 }
887
888 #[inline]
889 fn mul_add(self, b: Self, c: Self) -> Self {
890 XYZ::mul_add(self.into(), b.into(), c.into()).into()
891 }
892
893 #[inline]
894 fn sub(self, other: Self) -> Self {
895 XYZ::sub(self.into(), other.into()).into()
896 }
897
898 #[inline]
899 fn mul_scalar(self, other: f32) -> Self {
900 XYZ::mul_scalar(self.into(), other).into()
901 }
902
903 #[inline]
904 fn div_scalar(self, other: f32) -> Self {
905 XYZ::div_scalar(self.into(), other).into()
906 }
907
908 #[inline]
909 fn min(self, other: Self) -> Self {
910 XYZ::min(self.into(), other.into()).into()
911 }
912
913 #[inline]
914 fn max(self, other: Self) -> Self {
915 XYZ::max(self.into(), other.into()).into()
916 }
917 }
918
919 impl Vector3<f32> for XYZF32A16 {
920 #[inline(always)]
921 fn new(x: f32, y: f32, z: f32) -> Self {
922 XYZF32A16 { x, y, z }
923 }
924
925 #[inline(always)]
926 fn x(self) -> f32 {
927 self.x
928 }
929
930 #[inline(always)]
931 fn y(self) -> f32 {
932 self.y
933 }
934
935 #[inline(always)]
936 fn z(self) -> f32 {
937 self.z
938 }
939
940 #[inline(always)]
941 fn as_ref_xyz(&self) -> &XYZ<f32> {
942 unsafe { &*(self as *const Self as *const XYZ<f32>) }
943 }
944
945 #[inline(always)]
946 fn as_mut_xyz(&mut self) -> &mut XYZ<f32> {
947 unsafe { &mut *(self as *mut Self as *mut XYZ<f32>) }
948 }
949
950 #[inline(always)]
951 fn min_element(self) -> f32 {
952 XYZ::min_element(self.into())
953 }
954
955 #[inline(always)]
956 fn max_element(self) -> f32 {
957 XYZ::max_element(self.into())
958 }
959
960 #[inline(always)]
961 fn clamp(self, min: Self, max: Self) -> Self {
962 XYZ::clamp(self.into(), min.into(), max.into()).into()
963 }
964 }
965
966 impl SignedVector<f32> for XYZF32A16 {
967 #[inline(always)]
968 fn neg(self) -> Self {
969 XYZ::neg(self.into()).into()
970 }
971 }
972
973 impl SignedVector3<f32> for XYZF32A16 {}
974 impl FloatVector3<f32> for XYZF32A16 {}