1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
use std; use ::*; impl Vector for double3 { type Scalar = f64; type Boolean = long3; type CharVector = char3; type ShortVector = short3; type IntVector = int3; type LongVector = long3; type UCharVector = uchar3; type UShortVector = ushort3; type UIntVector = uint3; type ULongVector = ulong3; type FloatVector = float3; type DoubleVector = double3; #[inline(always)] fn map_unary(self, f: &Fn(Self::Scalar) -> Self::Scalar) -> Self { return double3(f(self.0), f(self.1), f(self.2)); } #[inline(always)] fn map_binary(self, other: Self, f: &Fn(Self::Scalar, Self::Scalar) -> Self::Scalar) -> Self { return double3(f(self.0, other.0), f(self.1, other.1), f(self.2, other.2)); } #[inline(always)] fn reduce(self, f: &Fn(Self::Scalar, Self::Scalar) -> Self::Scalar) -> Self::Scalar { return f(self.2, f(self.1, self.0)); } #[inline(always)] fn abs(self) -> Self { let x = Self::Boolean::broadcast(std::i64::MAX); return x.bitselect(Self::from(0), self); } #[inline(always)] fn to_char_sat(self) -> char3 { return double3::to_char(self.clamp(Self::broadcast(std::i8::MIN as f64), Self::broadcast(std::i8::MAX as f64))); } #[inline(always)] fn to_uchar_sat(self) -> uchar3 { return double3::to_uchar(self.clamp(Self::broadcast(std::u8::MIN as f64), Self::broadcast(std::u8::MAX as f64))); } #[inline(always)] fn to_short_sat(self) -> short3 { return double3::to_short(self.clamp(Self::broadcast(std::i16::MIN as f64), Self::broadcast(std::i16::MAX as f64))); } #[inline(always)] fn to_ushort_sat(self) -> ushort3 { return double3::to_ushort(self.clamp(Self::broadcast(std::u16::MIN as f64), Self::broadcast(std::u16::MAX as f64))); } #[inline(always)] fn to_int_sat(self) -> int3 { return double3::to_int(self.clamp(Self::broadcast(std::i32::MIN as f64), Self::broadcast(std::i32::MAX as f64))); } #[inline(always)] fn to_uint_sat(self) -> uint3 { return double3::to_uint(self.clamp(Self::broadcast(std::u32::MIN as f64), Self::broadcast(std::u32::MAX as f64))); } #[inline(always)] fn to_long_sat(self) -> long3 { return double3::to_long(self.clamp(Self::broadcast(std::i64::MIN as f64), Self::broadcast(std::i64::MAX as f64))); } #[inline(always)] fn to_ulong_sat(self) -> ulong3 { return double3::to_ulong(self.clamp(Self::broadcast(std::u64::MIN as f64), Self::broadcast(std::u64::MAX as f64))); } } impl Cross for double3 { type CrossProduct = double3; #[inline(always)] fn cross(self, other: Self) -> Self::CrossProduct { let a = self * double3(other.2, other.1, other.0) - double3(self.2, self.1, self.0) * other; return double3(a.2, a.1, a.0); } } impl Dot<double3> for double3 { type DotProduct = f64; #[inline(always)] fn dot(self, other: Self) -> Self::DotProduct { return reduce_add(self * other); } } impl Float for double3 { type FloatScalar = f64; const SIGN_MASK: i64 = std::i64::MAX; } impl Geometry for double3 { } impl double3 { #[inline(always)] pub fn lo(self) -> double2 { return double2(self.0, self.1); } #[inline(always)] pub fn hi(self) -> double2 { return double2(self.2, 0.0); } #[inline(always)] pub fn odd(self) -> double2 { return double2(self.1, 0.0); } #[inline(always)] pub fn even(self) -> double2 { return double2(self.0, self.2); } }