40#define PX_PIDIV2 1.570796327f
46PX_FORCE_INLINE QuatV QuatVLoadXYZW(
const PxF32 x,
const PxF32 y,
const PxF32 z,
const PxF32 w)
48 return V4LoadXYZW(x, y, z, w);
61PX_FORCE_INLINE QuatV QuatV_From_RotationAxisAngle(
const Vec3V u,
const FloatV a)
64 const FloatV half = FLoad(0.5f);
65 const FloatV hangle = FMul(a, half);
66 const FloatV piByTwo(FLoad(PX_PIDIV2));
67 const FloatV PiByTwoMinHangle(FSub(piByTwo, hangle));
68 const Vec4V hangle2(Vec4V_From_Vec3V(V3Merge(hangle, PiByTwoMinHangle, hangle)));
73 const Vec4V _sina = V4Sin(hangle2);
74 const FloatV sina = V4GetX(_sina);
75 const FloatV cosa = V4GetY(_sina);
77 const Vec3V v = V3Scale(u, sina);
79 return V4SetW(Vec4V_From_Vec3V(v), cosa);
85 return V4Normalize(q);
105 return V4SetW(V4Neg(q), V4GetW(q));
110 return Vec3V_From_Vec4V(q);
122 const FloatV two = FLoad(2.f);
123 const FloatV w = V4GetW(q);
124 const Vec3V u = Vec3V_From_Vec4V(q);
126 const FloatV x2 = FMul(V3GetX(u), two);
127 const FloatV w2 = FMul(w, two);
129 const Vec3V a = V3Scale(u, x2);
130 const Vec3V tmp = V3Merge(w, V3GetZ(u), FNeg(V3GetY(u)));
133 const Vec3V ab = V3ScaleAdd(tmp, w2, a);
134 return V3SetX(ab, FSub(V3GetX(ab), FOne()));
146 const FloatV two = FLoad(2.f);
147 const FloatV w = V4GetW(q);
148 const Vec3V u = Vec3V_From_Vec4V(q);
150 const FloatV y2 = FMul(V3GetY(u), two);
151 const FloatV w2 = FMul(w, two);
153 const Vec3V a = V3Scale(u, y2);
154 const Vec3V tmp = V3Merge(FNeg(V3GetZ(u)), w, V3GetX(u));
157 const Vec3V ab = V3ScaleAdd(tmp, w2, a);
158 return V3SetY(ab, FSub(V3GetY(ab), FOne()));
170 const FloatV two = FLoad(2.f);
171 const FloatV w = V4GetW(q);
172 const Vec3V u = Vec3V_From_Vec4V(q);
174 const FloatV z2 = FMul(V3GetZ(u), two);
175 const FloatV w2 = FMul(w, two);
177 const Vec3V a = V3Scale(u, z2);
178 const Vec3V tmp = V3Merge(V3GetY(u), FNeg(V3GetX(u)), w);
181 const Vec3V ab = V3ScaleAdd(tmp, w2, a);
182 return V3SetZ(ab, FSub(V3GetZ(ab), FOne()));
192 const FloatV two = FLoad(2.f);
194 const FloatV nhalf = FLoad(-0.5f);
195 const Vec3V u = Vec3V_From_Vec4V(q);
196 const FloatV w = V4GetW(q);
198 const FloatV w2 = FScaleAdd(w, w, nhalf);
199 const Vec3V a = V3Scale(v, w2);
203 const Vec3V temp = V3ScaleAdd(V3Cross(u, v), w, a);
204 return V3Scale(V3ScaleAdd(u, V3Dot(u, v), temp), two);
207PX_FORCE_INLINE Vec3V QuatTransform(
const QuatV q,
const Vec3V p,
const Vec3V v)
210 const FloatV two = FLoad(2.f);
212 const FloatV nhalf = FLoad(-0.5f);
213 const Vec3V u = Vec3V_From_Vec4V(q);
214 const FloatV w = V4GetW(q);
216 const FloatV w2 = FScaleAdd(w, w, nhalf);
217 const Vec3V a = V3Scale(v, w2);
221 const Vec3V temp = V3ScaleAdd(V3Cross(u, v), w, a);
222 const Vec3V z = V3ScaleAdd(u, V3Dot(u, v), temp);
223 return V3ScaleAdd(z, two, p);
232 const FloatV two = FLoad(2.f);
233 const FloatV nhalf = FLoad(-0.5f);
234 const Vec3V u = Vec3V_From_Vec4V(q);
235 const FloatV w = V4GetW(q);
236 const FloatV w2 = FScaleAdd(w, w, nhalf);
237 const Vec3V a = V3Scale(v, w2);
241 const Vec3V temp = V3NegScaleSub(V3Cross(u, v), w, a);
242 return V3Scale(V3ScaleAdd(u, V3Dot(u, v), temp), two);
247 const Vec3V imagA = Vec3V_From_Vec4V(a);
248 const Vec3V imagB = Vec3V_From_Vec4V(b);
249 const FloatV rA = V4GetW(a);
250 const FloatV rB = V4GetW(b);
252 const FloatV real = FSub(FMul(rA, rB), V3Dot(imagA, imagB));
253 const Vec3V v0 = V3Scale(imagA, rB);
254 const Vec3V v1 = V3Scale(imagB, rA);
255 const Vec3V v2 = V3Cross(imagA, imagB);
256 const Vec3V imag = V3Add(V3Add(v0, v1), v2);
258 return V4SetW(Vec4V_From_Vec3V(imag), real);
278 return V4Scale(a, b);
283 return V4Merge(floatVArray);
286PX_FORCE_INLINE QuatV QuatMerge(
const FloatVArg x,
const FloatVArg y,
const FloatVArg z,
const FloatVArg w)
288 return V4Merge(x, y, z, w);
293 return V4SetW(V4Zero(), FOne());
298 return isFiniteVec4V(q);
301#if PX_LINUX && PX_CLANG
302#pragma clang diagnostic push
303#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
308 const FloatV unitTolerance = FLoad(1e-4f);
309 const FloatV tmp = FAbs(FSub(QuatLength(q), FOne()));
310 const BoolV con = FIsGrtr(unitTolerance, tmp);
311 return isFiniteVec4V(q) & (BAllEqTTTT(con) == 1);
316 const FloatV unitTolerance = FLoad(1e-2f);
317 const FloatV tmp = FAbs(FSub(QuatLength(q), FOne()));
318 const BoolV con = FIsGrtr(unitTolerance, tmp);
319 return isFiniteVec4V(q) & (BAllEqTTTT(con) == 1);
322#if PX_LINUX && PX_CLANG
323#pragma clang diagnostic pop
375 const FloatV one = FOne();
376 const FloatV x = V4GetX(q);
377 const FloatV y = V4GetY(q);
378 const FloatV z = V4GetZ(q);
379 const FloatV w = V4GetW(q);
381 const FloatV x2 = FAdd(x, x);
382 const FloatV y2 = FAdd(y, y);
383 const FloatV z2 = FAdd(z, z);
385 const FloatV xx = FMul(x2, x);
386 const FloatV yy = FMul(y2, y);
387 const FloatV zz = FMul(z2, z);
389 const FloatV xy = FMul(x2, y);
390 const FloatV xz = FMul(x2, z);
391 const FloatV xw = FMul(x2, w);
393 const FloatV yz = FMul(y2, z);
394 const FloatV yw = FMul(y2, w);
395 const FloatV zw = FMul(z2, w);
397 const FloatV v = FSub(one, xx);
399 const Vec3V column0 = V3Merge(FSub(FSub(one, yy), zz), FAdd(xy, zw), FSub(xz, yw));
400 const Vec3V column1 = V3Merge(FSub(xy, zw), FSub(v, zz), FAdd(yz, xw));
401 const Vec3V column2 = V3Merge(FAdd(xz, yw), FSub(yz, xw), FSub(v, yy));
402 return Mat33V(column0, column1, column2);
407 const FloatV one = FOne();
408 const FloatV
zero = FZero();
409 const FloatV half = FLoad(0.5f);
410 const FloatV two = FLoad(2.f);
411 const FloatV scale = FLoad(0.25f);
412 const FloatV a00 = V3GetX(a.col0);
413 const FloatV a11 = V3GetY(a.col1);
414 const FloatV a22 = V3GetZ(a.col2);
416 const FloatV a21 = V3GetZ(a.col1);
417 const FloatV a12 = V3GetY(a.col2);
418 const FloatV a02 = V3GetX(a.col2);
419 const FloatV a20 = V3GetZ(a.col0);
420 const FloatV a10 = V3GetY(a.col0);
421 const FloatV a01 = V3GetX(a.col1);
423 const Vec3V vec0 = V3Merge(a21, a02, a10);
424 const Vec3V
vec1 = V3Merge(a12, a20, a01);
425 const Vec3V v = V3Sub(vec0, vec1);
426 const Vec3V g = V3Add(vec0, vec1);
428 const FloatV trace = FAdd(a00, FAdd(a11, a22));
430 if(FAllGrtrOrEq(trace, zero))
432 const FloatV h = FSqrt(FAdd(trace, one));
433 const FloatV w = FMul(half, h);
434 const FloatV s = FMul(half, FRecip(h));
435 const Vec3V u = V3Scale(v, s);
436 return V4SetW(Vec4V_From_Vec3V(u), w);
440 const FloatV ntrace = FNeg(trace);
441 const Vec3V d = V3Merge(a00, a11, a22);
442 const BoolV con0 = BAllTrue3(V3IsGrtrOrEq(V3Splat(a00), d));
443 const BoolV con1 = BAllTrue3(V3IsGrtrOrEq(V3Splat(a11), d));
445 const FloatV t0 = FAdd(one, FScaleAdd(a00, two, ntrace));
446 const FloatV t1 = FAdd(one, FScaleAdd(a11, two, ntrace));
447 const FloatV t2 = FAdd(one, FScaleAdd(a22, two, ntrace));
449 const FloatV t = FSel(con0, t0, FSel(con1, t1, t2));
451 const FloatV h = FMul(two, FSqrt(t));
452 const FloatV s = FRecip(h);
453 const FloatV g0 = FMul(scale, h);
454 const Vec3V vs = V3Scale(v, s);
455 const Vec3V gs = V3Scale(g, s);
456 const FloatV gsx = V3GetX(gs);
457 const FloatV gsy = V3GetY(gs);
458 const FloatV gsz = V3GetZ(gs);
461 const Vec4V v0 = V4Merge(g0, gsz, gsy, V3GetX(vs));
462 const Vec4V v1 = V4Merge(gsz, g0, gsx, V3GetY(vs));
463 const Vec4V v2 = V4Merge(gsy, gsx, g0, V3GetZ(vs));
464 return V4Sel(con0, v0, V4Sel(con1, v1, v2));
vec< 1, float, defaultp > vec1
1 components vector of single-precision floating-point numbers.
Definition vector_float1.hpp:28
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
GLM_FUNC_DECL GLM_CONSTEXPR genType zero()
Definition constants.inl:6
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39