Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Quat.inl
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
6
8{
9#if defined(JPH_USE_SSE4_1)
10 // Taken from: http://momchil-velikov.blogspot.nl/2013/10/fast-sse-quternion-multiplication.html
11 __m128 abcd = mValue.mValue;
12 __m128 xyzw = inRHS.mValue.mValue;
13
14 __m128 t0 = _mm_shuffle_ps(abcd, abcd, _MM_SHUFFLE(3, 3, 3, 3));
15 __m128 t1 = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(2, 3, 0, 1));
16
17 __m128 t3 = _mm_shuffle_ps(abcd, abcd, _MM_SHUFFLE(0, 0, 0, 0));
18 __m128 t4 = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(1, 0, 3, 2));
19
20 __m128 t5 = _mm_shuffle_ps(abcd, abcd, _MM_SHUFFLE(1, 1, 1, 1));
21 __m128 t6 = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(2, 0, 3, 1));
22
23 // [d,d,d,d] * [z,w,x,y] = [dz,dw,dx,dy]
24 __m128 m0 = _mm_mul_ps(t0, t1);
25
26 // [a,a,a,a] * [y,x,w,z] = [ay,ax,aw,az]
27 __m128 m1 = _mm_mul_ps(t3, t4);
28
29 // [b,b,b,b] * [z,x,w,y] = [bz,bx,bw,by]
30 __m128 m2 = _mm_mul_ps(t5, t6);
31
32 // [c,c,c,c] * [w,z,x,y] = [cw,cz,cx,cy]
33 __m128 t7 = _mm_shuffle_ps(abcd, abcd, _MM_SHUFFLE(2, 2, 2, 2));
34 __m128 t8 = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(3, 2, 0, 1));
35 __m128 m3 = _mm_mul_ps(t7, t8);
36
37 // [dz,dw,dx,dy] + -[ay,ax,aw,az] = [dz+ay,dw-ax,dx+aw,dy-az]
38 __m128 e = _mm_addsub_ps(m0, m1);
39
40 // [dx+aw,dz+ay,dy-az,dw-ax]
41 e = _mm_shuffle_ps(e, e, _MM_SHUFFLE(1, 3, 0, 2));
42
43 // [dx+aw,dz+ay,dy-az,dw-ax] + -[bz,bx,bw,by] = [dx+aw+bz,dz+ay-bx,dy-az+bw,dw-ax-by]
44 e = _mm_addsub_ps(e, m2);
45
46 // [dz+ay-bx,dw-ax-by,dy-az+bw,dx+aw+bz]
47 e = _mm_shuffle_ps(e, e, _MM_SHUFFLE(2, 0, 1, 3));
48
49 // [dz+ay-bx,dw-ax-by,dy-az+bw,dx+aw+bz] + -[cw,cz,cx,cy] = [dz+ay-bx+cw,dw-ax-by-cz,dy-az+bw+cx,dx+aw+bz-cy]
50 e = _mm_addsub_ps(e, m3);
51
52 // [dw-ax-by-cz,dz+ay-bx+cw,dy-az+bw+cx,dx+aw+bz-cy]
53 return Quat(Vec4(_mm_shuffle_ps(e, e, _MM_SHUFFLE(2, 3, 1, 0))));
54#else
55 float lx = mValue.GetX();
56 float ly = mValue.GetY();
57 float lz = mValue.GetZ();
58 float lw = mValue.GetW();
59
60 float rx = inRHS.mValue.GetX();
61 float ry = inRHS.mValue.GetY();
62 float rz = inRHS.mValue.GetZ();
63 float rw = inRHS.mValue.GetW();
64
65 float x = lw * rx + lx * rw + ly * rz - lz * ry;
66 float y = lw * ry - lx * rz + ly * rw + lz * rx;
67 float z = lw * rz + lx * ry - ly * rx + lz * rw;
68 float w = lw * rw - lx * rx - ly * ry - lz * rz;
69
70 return Quat(x, y, z, w);
71#endif
72}
73
75{
76#if defined(JPH_USE_SSE4_1)
77 __m128 abc0 = inLHS.mValue;
78 __m128 xyzw = inRHS.mValue.mValue;
79
80 // [a,a,a,a] * [w,y,z,x] = [aw,ay,az,ax]
81 __m128 aaaa = _mm_shuffle_ps(abc0, abc0, _MM_SHUFFLE(0, 0, 0, 0));
82 __m128 xzyw = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(3, 1, 2, 0));
83 __m128 axazayaw = _mm_mul_ps(aaaa, xzyw);
84
85 // [b,b,b,b] * [z,x,w,y] = [bz,bx,bw,by]
86 __m128 bbbb = _mm_shuffle_ps(abc0, abc0, _MM_SHUFFLE(1, 1, 1, 1));
87 __m128 ywxz = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(2, 0, 3, 1));
88 __m128 bybwbxbz = _mm_mul_ps(bbbb, ywxz);
89
90 // [c,c,c,c] * [w,z,x,y] = [cw,cz,cx,cy]
91 __m128 cccc = _mm_shuffle_ps(abc0, abc0, _MM_SHUFFLE(2, 2, 2, 2));
92 __m128 yxzw = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(3, 2, 0, 1));
93 __m128 cycxczcw = _mm_mul_ps(cccc, yxzw);
94
95 // [+aw,+ay,-az,-ax]
96 __m128 e = _mm_xor_ps(axazayaw, _mm_set_ps(0.0f, 0.0f, -0.0f, -0.0f));
97
98 // [+aw,+ay,-az,-ax] + -[bz,bx,bw,by] = [+aw+bz,+ay-bx,-az+bw,-ax-by]
99 e = _mm_addsub_ps(e, bybwbxbz);
100
101 // [+ay-bx,-ax-by,-az+bw,+aw+bz]
102 e = _mm_shuffle_ps(e, e, _MM_SHUFFLE(2, 0, 1, 3));
103
104 // [+ay-bx,-ax-by,-az+bw,+aw+bz] + -[cw,cz,cx,cy] = [+ay-bx+cw,-ax-by-cz,-az+bw+cx,+aw+bz-cy]
105 e = _mm_addsub_ps(e, cycxczcw);
106
107 // [-ax-by-cz,+ay-bx+cw,-az+bw+cx,+aw+bz-cy]
108 return Quat(Vec4(_mm_shuffle_ps(e, e, _MM_SHUFFLE(2, 3, 1, 0))));
109#else
110 float lx = inLHS.GetX();
111 float ly = inLHS.GetY();
112 float lz = inLHS.GetZ();
113
114 float rx = inRHS.mValue.GetX();
115 float ry = inRHS.mValue.GetY();
116 float rz = inRHS.mValue.GetZ();
117 float rw = inRHS.mValue.GetW();
118
119 float x = (lx * rw) + ly * rz - lz * ry;
120 float y = -(lx * rz) + ly * rw + lz * rx;
121 float z = (lx * ry) - ly * rx + lz * rw;
122 float w = -(lx * rx) - ly * ry - lz * rz;
123
124 return Quat(x, y, z, w);
125#endif
126}
127
128Quat Quat::sRotation(Vec3Arg inAxis, float inAngle)
129{
130 // returns [inAxis * sin(0.5f * inAngle), cos(0.5f * inAngle)]
131 JPH_ASSERT(inAxis.IsNormalized());
132 Vec4 s, c;
133 Vec4::sReplicate(0.5f * inAngle).SinCos(s, c);
134 return Quat(Vec4::sSelect(Vec4(inAxis) * s, c, UVec4(0, 0, 0, 0xffffffffU)));
135}
136
137void Quat::GetAxisAngle(Vec3 &outAxis, float &outAngle) const
138{
140 Quat w_pos = EnsureWPositive();
141 float abs_w = w_pos.GetW();
142 if (abs_w >= 1.0f)
143 {
144 outAxis = Vec3::sZero();
145 outAngle = 0.0f;
146 }
147 else
148 {
149 outAngle = 2.0f * ACos(abs_w);
150 outAxis = w_pos.GetXYZ().NormalizedOr(Vec3::sZero());
151 }
152}
153
155{
156 /*
157 Uses (inFrom = v1, inTo = v2):
158
159 angle = arcos(v1 . v2 / |v1||v2|)
160 axis = normalize(v1 x v2)
161
162 Quaternion is then:
163
164 s = sin(angle / 2)
165 x = axis.x * s
166 y = axis.y * s
167 z = axis.z * s
168 w = cos(angle / 2)
169
170 Using identities:
171
172 sin(2 * a) = 2 * sin(a) * cos(a)
173 cos(2 * a) = cos(a)^2 - sin(a)^2
174 sin(a)^2 + cos(a)^2 = 1
175
176 This reduces to:
177
178 x = (v1 x v2).x
179 y = (v1 x v2).y
180 z = (v1 x v2).z
181 w = |v1||v2| + v1 . v2
182
183 which then needs to be normalized because the whole equation was multiplied by 2 cos(angle / 2)
184 */
185
186 float len_v1_v2 = sqrt(inFrom.LengthSq() * inTo.LengthSq());
187 float w = len_v1_v2 + inFrom.Dot(inTo);
188
189 if (w == 0.0f)
190 {
191 if (len_v1_v2 == 0.0f)
192 {
193 // If either of the vectors has zero length, there is no rotation and we return identity
194 return Quat::sIdentity();
195 }
196 else
197 {
198 // If vectors are perpendicular, take one of the many 180 degree rotations that exist
199 return Quat(Vec4(inFrom.GetNormalizedPerpendicular(), 0));
200 }
201 }
202
203 Vec3 v = inFrom.Cross(inTo);
204 return Quat(Vec4(v, w)).Normalized();
205}
206
207template <class Random>
208Quat Quat::sRandom(Random &inRandom)
209{
210 std::uniform_real_distribution<float> zero_to_one(0.0f, 1.0f);
211 float x0 = zero_to_one(inRandom);
212 float r1 = sqrt(1.0f - x0), r2 = sqrt(x0);
213 std::uniform_real_distribution<float> zero_to_two_pi(0.0f, 2.0f * JPH_PI);
214 Vec4 s, c;
215 Vec4(zero_to_two_pi(inRandom), zero_to_two_pi(inRandom), 0, 0).SinCos(s, c);
216 return Quat(s.GetX() * r1, c.GetX() * r1, s.GetY() * r2, c.GetY() * r2);
217}
218
220{
221 Vec4 half(0.5f * inAngles);
222 Vec4 s, c;
223 half.SinCos(s, c);
224
225 float cx = c.GetX();
226 float sx = s.GetX();
227 float cy = c.GetY();
228 float sy = s.GetY();
229 float cz = c.GetZ();
230 float sz = s.GetZ();
231
232 return Quat(
233 cz * sx * cy - sz * cx * sy,
234 cz * cx * sy + sz * sx * cy,
235 sz * cx * cy - cz * sx * sy,
236 cz * cx * cy + sz * sx * sy);
237}
238
240{
241 float y_sq = GetY() * GetY();
242
243 // X
244 float t0 = 2.0f * (GetW() * GetX() + GetY() * GetZ());
245 float t1 = 1.0f - 2.0f * (GetX() * GetX() + y_sq);
246
247 // Y
248 float t2 = 2.0f * (GetW() * GetY() - GetZ() * GetX());
249 t2 = t2 > 1.0f? 1.0f : t2;
250 t2 = t2 < -1.0f? -1.0f : t2;
251
252 // Z
253 float t3 = 2.0f * (GetW() * GetZ() + GetX() * GetY());
254 float t4 = 1.0f - 2.0f * (y_sq + GetZ() * GetZ());
255
256 return Vec3(ATan2(t0, t1), ASin(t2), ATan2(t3, t4));
257}
258
260{
261 Quat twist(Vec4(GetXYZ().Dot(inAxis) * inAxis, GetW()));
262 float twist_len = twist.LengthSq();
263 if (twist_len != 0.0f)
264 return twist / sqrt(twist_len);
265 else
266 return Quat::sIdentity();
267}
268
269void Quat::GetSwingTwist(Quat &outSwing, Quat &outTwist) const
270{
271 float x = GetX(), y = GetY(), z = GetZ(), w = GetW();
272 float s = sqrt(Square(w) + Square(x));
273 if (s != 0.0f)
274 {
275 outTwist = Quat(x / s, 0, 0, w / s);
276 outSwing = Quat(0, (w * y - x * z) / s, (w * z + x * y) / s, s);
277 }
278 else
279 {
280 // If both x and w are zero, this must be a 180 degree rotation around either y or z
281 outTwist = Quat::sIdentity();
282 outSwing = *this;
283 }
284}
285
286Quat Quat::LERP(QuatArg inDestination, float inFraction) const
287{
288 float scale0 = 1.0f - inFraction;
289 return Quat(Vec4::sReplicate(scale0) * mValue + Vec4::sReplicate(inFraction) * inDestination.mValue);
290}
291
292Quat Quat::SLERP(QuatArg inDestination, float inFraction) const
293{
294 // Difference at which to LERP instead of SLERP
295 const float delta = 0.0001f;
296
297 // Calc cosine
298 float sign_scale1 = 1.0f;
299 float cos_omega = Dot(inDestination);
300
301 // Adjust signs (if necessary)
302 if (cos_omega < 0.0f)
303 {
304 cos_omega = -cos_omega;
305 sign_scale1 = -1.0f;
306 }
307
308 // Calculate coefficients
309 float scale0, scale1;
310 if (1.0f - cos_omega > delta)
311 {
312 // Standard case (slerp)
313 float omega = ACos(cos_omega);
314 float sin_omega = Sin(omega);
315 scale0 = Sin((1.0f - inFraction) * omega) / sin_omega;
316 scale1 = sign_scale1 * Sin(inFraction * omega) / sin_omega;
317 }
318 else
319 {
320 // Quaternions are very close so we can do a linear interpolation
321 scale0 = 1.0f - inFraction;
322 scale1 = sign_scale1 * inFraction;
323 }
324
325 // Interpolate between the two quaternions
326 return Quat(Vec4::sReplicate(scale0) * mValue + Vec4::sReplicate(scale1) * inDestination.mValue).Normalized();
327}
328
330{
331 // Rotating a vector by a quaternion is done by: p' = q * (p, 0) * q^-1 (q^-1 = conjugated(q) for a unit quaternion)
332 // Using Rodrigues formula: https://en.m.wikipedia.org/wiki/Euler%E2%80%93Rodrigues_formula
333 // This is equivalent to: p' = p + 2 * (q.w * q.xyz x p + q.xyz x (q.xyz x p))
334 //
335 // This is:
336 //
337 // Vec3 xyz = GetXYZ();
338 // Vec3 q_cross_p = xyz.Cross(inValue);
339 // Vec3 q_cross_q_cross_p = xyz.Cross(q_cross_p);
340 // Vec3 v = mValue.SplatW3() * q_cross_p + q_cross_q_cross_p;
341 // return inValue + (v + v);
342 //
343 // But we can write out the cross products in a more efficient way:
345 Vec3 xyz = GetXYZ();
347 Vec3 q_cross_p = (inValue.Swizzle<SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X>() * xyz - yzx * inValue).Swizzle<SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X>();
348 Vec3 q_cross_q_cross_p = (q_cross_p.Swizzle<SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X>() * xyz - yzx * q_cross_p).Swizzle<SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X>();
349 Vec3 v = mValue.SplatW3() * q_cross_p + q_cross_q_cross_p;
350 return inValue + (v + v);
351}
352
354{
356 Vec3 xyz = GetXYZ(); // Needs to be negated, but we do this in the equations below
358 Vec3 q_cross_p = (yzx * inValue - inValue.Swizzle<SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X>() * xyz).Swizzle<SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X>();
359 Vec3 q_cross_q_cross_p = (yzx * q_cross_p - q_cross_p.Swizzle<SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X>() * xyz).Swizzle<SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X>();
360 Vec3 v = mValue.SplatW3() * q_cross_p + q_cross_q_cross_p;
361 return inValue + (v + v);
362}
363
365{
366 // This is *this * Vec3::sAxisX() written out:
368 Vec4 t = mValue + mValue;
369 return Vec3(t.SplatX() * mValue + (t.SplatW() * mValue.Swizzle<SWIZZLE_W, SWIZZLE_Z, SWIZZLE_Y, SWIZZLE_X>()).FlipSign<1, 1, -1, 1>() - Vec4(1, 0, 0, 0));
370}
371
373{
374 // This is *this * Vec3::sAxisY() written out:
376 Vec4 t = mValue + mValue;
377 return Vec3(t.SplatY() * mValue + (t.SplatW() * mValue.Swizzle<SWIZZLE_Z, SWIZZLE_W, SWIZZLE_X, SWIZZLE_Y>()).FlipSign<-1, 1, 1, 1>() - Vec4(0, 1, 0, 0));
378}
379
381{
382 // This is *this * Vec3::sAxisZ() written out:
384 Vec4 t = mValue + mValue;
385 return Vec3(t.SplatZ() * mValue + (t.SplatW() * mValue.Swizzle<SWIZZLE_Y, SWIZZLE_X, SWIZZLE_W, SWIZZLE_Z>()).FlipSign<1, -1, 1, 1>() - Vec4(0, 0, 1, 0));
386}
387
388void Quat::StoreFloat3(Float3 *outV) const
389{
392}
393
395{
397 float w = sqrt(max(1.0f - v.LengthSq(), 0.0f)); // It is possible that the length of v is a fraction above 1, and we don't want to introduce NaN's in that case so we clamp to 0
398 return Quat(Vec4(v, w));
399}
400
#define JPH_NAMESPACE_END
Definition Core.h:419
#define JPH_NAMESPACE_BEGIN
Definition Core.h:413
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
JPH_INLINE constexpr T Square(T inV)
Square a value.
Definition Math.h:55
@ SWIZZLE_Z
Use the Z component.
Definition Swizzle.h:14
@ SWIZZLE_W
Use the W component.
Definition Swizzle.h:15
@ SWIZZLE_X
Use the X component.
Definition Swizzle.h:12
@ SWIZZLE_Y
Use the Y component.
Definition Swizzle.h:13
JPH_INLINE float ACos(float inX)
Definition Trigonometry.h:42
JPH_INLINE float ATan2(float inY, float inX)
Arc tangent of y / x using the signs of the arguments to determine the correct quadrant (returns valu...
Definition Trigonometry.h:74
JPH_NAMESPACE_BEGIN JPH_INLINE float Sin(float inX)
Sine of x (input in radians)
Definition Trigonometry.h:12
JPH_INLINE float ASin(float inX)
Definition Trigonometry.h:35
Class that holds 3 floats. Used as a storage class. Convert to Vec3 for calculations.
Definition Float3.h:13
Definition Quat.h:33
static Quat sRandom(Random &inRandom)
Random unit quaternion.
Definition Quat.inl:208
JPH_INLINE Vec3 InverseRotate(Vec3Arg inValue) const
Rotate a vector by the inverse of this quaternion.
Definition Quat.inl:353
JPH_INLINE float GetW() const
Get W component (real part)
Definition Quat.h:78
static JPH_INLINE Quat sMultiplyImaginary(Vec3Arg inLHS, QuatArg inRHS)
Multiply a quaternion with imaginary components and no real component (x, y, z, 0) with a quaternion.
Definition Quat.inl:74
static Quat sEulerAngles(Vec3Arg inAngles)
Conversion from Euler angles. Rotation order is X then Y then Z (RotZ * RotY * RotX)....
Definition Quat.inl:219
JPH_INLINE float GetY() const
Get Y component (imaginary part j)
Definition Quat.h:72
JPH_INLINE float GetZ() const
Get Z component (imaginary part k)
Definition Quat.h:75
static JPH_INLINE Quat sRotation(Vec3Arg inAxis, float inAngle)
Rotation from axis and angle.
Definition Quat.inl:128
JPH_INLINE float GetX() const
Get X component (imaginary part i)
Definition Quat.h:69
JPH_INLINE Quat LERP(QuatArg inDestination, float inFraction) const
Definition Quat.inl:286
static JPH_INLINE Quat sLoadFloat3Unsafe(const Float3 &inV)
Load 3 floats from memory (X, Y and Z component and then calculates W) reads 32 bits extra which it d...
Definition Quat.inl:394
JPH_INLINE float LengthSq() const
Definition Quat.h:132
JPH_INLINE void GetAxisAngle(Vec3 &outAxis, float &outAngle) const
Get axis and angle that represents this quaternion, outAngle will always be in the range .
Definition Quat.inl:137
static JPH_INLINE Quat sIdentity()
Definition Quat.h:103
JPH_INLINE void GetSwingTwist(Quat &outSwing, Quat &outTwist) const
Definition Quat.inl:269
static JPH_INLINE Quat sFromTo(Vec3Arg inFrom, Vec3Arg inTo)
Definition Quat.inl:154
friend Quat operator*(float inValue, QuatArg inRHS)
Definition Quat.h:154
JPH_INLINE Quat EnsureWPositive() const
Ensures that the W component is positive by negating the entire quaternion if it is not....
Definition Quat.h:187
JPH_INLINE Quat GetTwist(Vec3Arg inAxis) const
Definition Quat.inl:259
JPH_INLINE float Dot(QuatArg inRHS) const
Dot product.
Definition Quat.h:178
Quat()=default
Intentionally not initialized for performance reasons.
JPH_INLINE Vec3 RotateAxisZ() const
Rotate a the vector (0, 0, 1) with this quaternion.
Definition Quat.inl:380
JPH_INLINE Vec3 RotateAxisX() const
Rotate a the vector (1, 0, 0) with this quaternion.
Definition Quat.inl:364
JPH_INLINE Vec3 RotateAxisY() const
Rotate a the vector (0, 1, 0) with this quaternion.
Definition Quat.inl:372
Vec3 GetEulerAngles() const
Conversion to Euler angles. Rotation order is X then Y then Z (RotZ * RotY * RotX)....
Definition Quat.inl:239
bool IsNormalized(float inTolerance=1.0e-5f) const
If the length of this quaternion is 1 +/- inTolerance.
Definition Quat.h:59
JPH_INLINE void StoreFloat3(Float3 *outV) const
Store 3 as floats to memory (X, Y and Z component)
Definition Quat.inl:388
JPH_INLINE Vec3 GetXYZ() const
Get the imaginary part of the quaternion.
Definition Quat.h:81
Vec4 mValue
4 vector that stores [x, y, z, w] parts of the quaternion
Definition Quat.h:251
JPH_INLINE Quat SLERP(QuatArg inDestination, float inFraction) const
Definition Quat.inl:292
Definition UVec4.h:12
Definition Vec3.h:17
JPH_INLINE float Dot(Vec3Arg inV2) const
Dot product.
Definition Vec3.inl:650
JPH_INLINE Vec3 Normalized() const
Normalize vector.
Definition Vec3.inl:707
JPH_INLINE Vec3 Cross(Vec3Arg inV2) const
Cross product.
Definition Vec3.inl:595
JPH_INLINE Vec3 GetNormalizedPerpendicular() const
Get normalized vector that is perpendicular to this vector.
Definition Vec3.inl:827
JPH_INLINE float GetX() const
Get individual components.
Definition Vec3.h:127
JPH_INLINE bool IsNormalized(float inTolerance=1.0e-6f) const
Test if vector is normalized.
Definition Vec3.inl:752
JPH_INLINE Vec3 NormalizedOr(Vec3Arg inZeroValue) const
Normalize vector or return inZeroValue if the length of the vector is zero.
Definition Vec3.inl:721
Type mValue
Definition Vec3.h:293
JPH_INLINE float GetY() const
Definition Vec3.h:128
JPH_INLINE void StoreFloat3(Float3 *outV) const
Store 3 floats to memory.
Definition Vec3.inl:772
JPH_INLINE float LengthSq() const
Squared length of vector.
Definition Vec3.inl:666
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:103
static JPH_INLINE Vec3 sLoadFloat3Unsafe(const Float3 &inV)
Load 3 floats from memory (reads 32 bits extra which it doesn't use)
Definition Vec3.inl:135
JPH_INLINE float GetZ() const
Definition Vec3.h:129
JPH_INLINE Vec3 Swizzle() const
Swizzle the elements in inV.
Definition Vec4.h:14
JPH_INLINE Vec4 SplatX() const
Replicate the X component to all components.
Definition Vec4.inl:568
JPH_INLINE Vec3 SplatW3() const
Replicate the W component to all components.
Definition Vec4.inl:645
JPH_INLINE Vec4 FlipSign() const
Flips the signs of the components, e.g. FlipSign<-1, 1, -1, 1>() will flip the signs of the X and Z c...
Definition Vec4.inl:760
JPH_INLINE float GetW() const
Definition Vec4.h:119
JPH_INLINE Vec4 SplatY() const
Replicate the Y component to all components.
Definition Vec4.inl:579
JPH_INLINE Vec4 SplatZ() const
Replicate the Z component to all components.
Definition Vec4.inl:590
JPH_INLINE Vec4 SplatW() const
Replicate the W component to all components.
Definition Vec4.inl:601
JPH_INLINE float GetX() const
Get individual components.
Definition Vec4.h:116
JPH_INLINE Vec4 Swizzle() const
Swizzle the elements in inV.
Type mValue
Definition Vec4.h:296
JPH_INLINE float GetZ() const
Definition Vec4.h:118
static JPH_INLINE Vec4 sSelect(Vec4Arg inNotSet, Vec4Arg inSet, UVec4Arg inControl)
Component wise select, returns inNotSet when highest bit of inControl = 0 and inSet when highest bit ...
Definition Vec4.inl:259
JPH_INLINE float GetY() const
Definition Vec4.h:117
static JPH_INLINE Vec4 sReplicate(float inV)
Replicate inV across all components.
Definition Vec4.inl:74
void SinCos(Vec4 &outSin, Vec4 &outCos) const
Calculate the sine and cosine for each element of this vector (input in radians)
Definition Vec4.inl:842