Debian Codegraph @

debian/missing-sources/glam-0.15.2/src/core/scalar/quaternion.rs

raw symbols SCIP
1 use craterust-analyzer cargo glam 0.15.2 crate/::corerust-analyzer cargo glam 0.15.2 core/::{
2 storagerust-analyzer cargo glam 0.15.2 core/storage/::{XYZrust-analyzer cargo glam 0.15.2 core/storage/XYZ#, XYZWrust-analyzer cargo glam 0.15.2 core/storage/XYZW#},
3 traitsrust-analyzer cargo glam 0.15.2 core/traits/::{quaternionrust-analyzer cargo glam 0.15.2 core/traits/quaternion/::Quaternionrust-analyzer cargo glam 0.15.2 core/traits/quaternion/Quaternion#, scalarrust-analyzer cargo glam 0.15.2 core/traits/scalar/::*, vectorrust-analyzer cargo glam 0.15.2 core/traits/vector/::*},
4 };
5
6 impl<T: FloatExrust-analyzer cargo glam 0.15.2 core/traits/scalar/FloatEx#> Quaternionrust-analyzer cargo glam 0.15.2 core/traits/quaternion/Quaternion#<T> for XYZWrust-analyzer cargo glam 0.15.2 core/storage/XYZW#<T> {
7 // fallback
8 type SIMDVector3rust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]SIMDVector3# = XYZrust-analyzer cargo glam 0.15.2 core/storage/XYZ#<T>;
9
10 #[inline(always)]
11 fn conjugaterust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]conjugate().(self) -> Selfrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`] {
12 Selfrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]::newrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector4<T>`]new().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().self.xrust-analyzer cargo glam 0.15.2 core/storage/XYZW#x., -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().self.yrust-analyzer cargo glam 0.15.2 core/storage/XYZW#y., -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().self.zrust-analyzer cargo glam 0.15.2 core/storage/XYZW#z., self.wrust-analyzer cargo glam 0.15.2 core/storage/XYZW#w.)
13 }
14
15 #[inline]
16 fn lerprust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]lerp().(self, end: Selfrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`], s: T) -> Selfrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`] {
17 glam_assertrust-analyzer cargo glam 0.15.2 macros/glam_assert!!(FloatVector4::is_normalized(self));
18 glam_assertrust-analyzer cargo glam 0.15.2 macros/glam_assert!!(FloatVector4::is_normalized(end));
19
20 let start = self;
21 let end = end;
22 let dot = start.dotrust-analyzer cargo glam 0.15.2 core/traits/vector/Vector4#dot().(end);
23 let bias = if dot rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().T::ZEROrust-analyzer cargo glam 0.15.2 core/traits/scalar/NumConstEx#ZERO. { T::ONErust-analyzer cargo glam 0.15.2 core/traits/scalar/NumConstEx#ONE. } else { T::NEG_ONErust-analyzer cargo glam 0.15.2 core/traits/scalar/FloatConstEx#NEG_ONE. };
24 let interpolated = start.addrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector<T>`]add().(end.mul_scalarrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector<T>`]mul_scalar().(bias).subrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector<T>`]sub().(start).mul_scalarrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector<T>`]mul_scalar().(s));
25 interpolated.normalizerust-analyzer cargo glam 0.15.2 core/traits/vector/FloatVector4#normalize().()
26 }
27
28 #[inline]
29 fn slerprust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]slerp().(self, end: Selfrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`], s: T) -> Selfrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`] {
30 // http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/
31
32 glam_assertrust-analyzer cargo glam 0.15.2 macros/glam_assert!!(FloatVector4::is_normalized(self));
33 glam_assertrust-analyzer cargo glam 0.15.2 macros/glam_assert!!(FloatVector4::is_normalized(end));
34
35 let dot = self.dotrust-analyzer cargo glam 0.15.2 core/traits/vector/Vector4#dot().(end);
36
37 if dot rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().T::from_f32rust-analyzer cargo glam 0.15.2 core/traits/scalar/FloatEx#from_f32().(0.9995) {
38 // assumes lerp returns a normalized quaternion
39 self.lerprust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]lerp().(end, s)
40 } else {
41 // assumes scalar_acos clamps the input to [-1.0, 1.0]
42 let theta = dot.acos_approxrust-analyzer cargo glam 0.15.2 core/traits/scalar/FloatEx#acos_approx().();
43 let scale1 = (theta rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::ONErust-analyzer cargo glam 0.15.2 core/traits/scalar/NumConstEx#ONE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().s)).sinrust-analyzer cargo glam 0.15.2 core/traits/scalar/Float#sin().();
44 let scale2 = (theta rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s).sinrust-analyzer cargo glam 0.15.2 core/traits/scalar/Float#sin().();
45 let theta_sin = theta.sinrust-analyzer cargo glam 0.15.2 core/traits/scalar/Float#sin().();
46
47 self.mul_scalarrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector<T>`]mul_scalar().(scale1)
48 .addrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector<T>`]add().(end.mul_scalarrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector<T>`]mul_scalar().(scale2))
49 .mul_scalarrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector<T>`]mul_scalar().(theta_sin.reciprust-analyzer cargo glam 0.15.2 core/traits/scalar/Float#recip().())
50 }
51 }
52
53 #[inline]
54 fn mul_vector3rust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]mul_vector3().(self, other: XYZrust-analyzer cargo glam 0.15.2 core/storage/XYZ#<T>) -> XYZrust-analyzer cargo glam 0.15.2 core/storage/XYZ#<T> {
55 glam_assertrust-analyzer cargo glam 0.15.2 macros/glam_assert!!(FloatVector4::is_normalized(self));
56 let w = self.wrust-analyzer cargo glam 0.15.2 core/storage/XYZW#w.;
57 let b = XYZrust-analyzer cargo glam 0.15.2 core/storage/XYZ# {
58 xrust-analyzer cargo glam 0.15.2 core/storage/XYZ#x.: self.xrust-analyzer cargo glam 0.15.2 core/storage/XYZW#x.,
59 yrust-analyzer cargo glam 0.15.2 core/storage/XYZ#y.: self.yrust-analyzer cargo glam 0.15.2 core/storage/XYZW#y.,
60 zrust-analyzer cargo glam 0.15.2 core/storage/XYZ#z.: self.zrust-analyzer cargo glam 0.15.2 core/storage/XYZW#z.,
61 };
62 let b2 = b.dotrust-analyzer cargo glam 0.15.2 core/traits/vector/Vector3#dot().(b);
63 other
64 .mul_scalarrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZ<T>`][`Vector<T>`]mul_scalar().(w rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().w rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().b2)
65 .addrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZ<T>`][`Vector<T>`]add().(b.mul_scalarrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZ<T>`][`Vector<T>`]mul_scalar().(other.dotrust-analyzer cargo glam 0.15.2 core/traits/vector/Vector3#dot().(b) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::TWOrust-analyzer cargo glam 0.15.2 core/traits/scalar/FloatConstEx#TWO.))
66 .addrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZ<T>`][`Vector<T>`]add().(b.crossrust-analyzer cargo glam 0.15.2 core/traits/vector/Vector3#cross().(other).mul_scalarrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZ<T>`][`Vector<T>`]mul_scalar().(w rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::TWOrust-analyzer cargo glam 0.15.2 core/traits/scalar/FloatConstEx#TWO.))
67 }
68
69 #[inline]
70 fn mul_quaternionrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]mul_quaternion().(self, other: Selfrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]) -> Selfrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`] {
71 glam_assertrust-analyzer cargo glam 0.15.2 macros/glam_assert!!(FloatVector4::is_normalized(self));
72 glam_assertrust-analyzer cargo glam 0.15.2 macros/glam_assert!!(FloatVector4::is_normalized(other));
73 let (x0, y0, z0, w0) = self.into_tuplerust-analyzer cargo glam 0.15.2 core/traits/vector/Vector4#into_tuple().();
74 let (x1, y1, z1, w1) = other.into_tuplerust-analyzer cargo glam 0.15.2 core/traits/vector/Vector4#into_tuple().();
75 Selfrust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]::newrust-analyzer cargo glam 0.15.2 core/scalar/vector/impl#[`XYZW<T>`][`Vector4<T>`]new().(
76 w0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().x1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().x0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().w1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().z1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().z0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().y1,
77 w0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().y1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().x0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().z1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().w1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().z0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().x1,
78 w0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().z1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().x0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().y1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().x1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().z0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().w1,
79 w0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().w1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().x0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().x1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().y1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().z0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().z1,
80 )
81 }
82
83 #[inline(always)]
84 fn mul_float4_as_vector3rust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]mul_float4_as_vector3().(self, other: XYZrust-analyzer cargo glam 0.15.2 core/storage/XYZ#<T>) -> XYZrust-analyzer cargo glam 0.15.2 core/storage/XYZ#<T> {
85 self.mul_vector3rust-analyzer cargo glam 0.15.2 core/scalar/quaternion/impl#[`XYZW<T>`][`Quaternion<T>`]mul_vector3().(other)
86 }
87 }