nalgebra/geometry/
similarity_simba.rs

1use simba::simd::{SimdRealField, SimdValue};
2
3use crate::geometry::{AbstractRotation, Isometry, Similarity};
4
5impl<T: SimdRealField, R, const D: usize> SimdValue for Similarity<T, R, D>
6where
7    T::Element: SimdRealField,
8    R: SimdValue<SimdBool = T::SimdBool> + AbstractRotation<T, D>,
9    R::Element: AbstractRotation<T::Element, D>,
10{
11    const LANES: usize = T::LANES;
12    type Element = Similarity<T::Element, R::Element, D>;
13    type SimdBool = T::SimdBool;
14
15    #[inline]
16    fn splat(val: Self::Element) -> Self {
17        let scaling = T::splat(val.scaling());
18        Similarity::from_isometry(Isometry::splat(val.isometry), scaling)
19    }
20
21    #[inline]
22    fn extract(&self, i: usize) -> Self::Element {
23        Similarity::from_isometry(self.isometry.extract(i), self.scaling().extract(i))
24    }
25
26    #[inline]
27    unsafe fn extract_unchecked(&self, i: usize) -> Self::Element {
28        unsafe {
29            Similarity::from_isometry(
30                self.isometry.extract_unchecked(i),
31                self.scaling().extract_unchecked(i),
32            )
33        }
34    }
35
36    #[inline]
37    fn replace(&mut self, i: usize, val: Self::Element) {
38        let mut s = self.scaling();
39        s.replace(i, val.scaling());
40        self.set_scaling(s);
41        self.isometry.replace(i, val.isometry);
42    }
43
44    #[inline]
45    unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element) {
46        unsafe {
47            let mut s = self.scaling();
48            s.replace_unchecked(i, val.scaling());
49            self.set_scaling(s);
50            self.isometry.replace_unchecked(i, val.isometry);
51        }
52    }
53
54    #[inline]
55    fn select(self, cond: Self::SimdBool, other: Self) -> Self {
56        let scaling = self.scaling().select(cond, other.scaling());
57        Similarity::from_isometry(self.isometry.select(cond, other.isometry), scaling)
58    }
59}