32class [[nodiscard]] alignas(JPH_VECTOR_ALIGNMENT)
Quat
41 inline Quat(
float inX,
float inY,
float inZ,
float inW) : mValue(inX, inY, inZ, inW) { }
49 inline bool operator == (
QuatArg inRHS)
const {
return mValue == inRHS.
mValue; }
52 inline bool operator != (
QuatArg inRHS)
const {
return mValue != inRHS.
mValue; }
55 inline bool IsClose(
QuatArg inRHS,
float inMaxDistSq = 1.0e-12f)
const {
return mValue.IsClose(inRHS.
mValue, inMaxDistSq); }
58 inline bool IsNormalized(
float inTolerance = 1.0e-5f)
const {
return mValue.IsNormalized(inTolerance); }
61 inline bool IsNaN()
const {
return mValue.IsNaN(); }
68 JPH_INLINE
float GetX()
const {
return mValue.GetX(); }
71 JPH_INLINE
float GetY()
const {
return mValue.GetY(); }
74 JPH_INLINE
float GetZ()
const {
return mValue.GetZ(); }
77 JPH_INLINE
float GetW()
const {
return mValue.GetW(); }
98 JPH_INLINE
static Quat sRotation(
Vec3Arg inAxis,
float inAngle);
101 JPH_INLINE
void GetAxisAngle(
Vec3 &outAxis,
float &outAngle)
const;
108 template <
class Random>
109 inline static Quat sRandom(Random &inRandom);
115 inline Vec3 GetEulerAngles()
const;
122 JPH_INLINE
float LengthSq()
const {
return mValue.LengthSq(); }
126 JPH_INLINE
float Length()
const {
return mValue.Length(); }
137 JPH_INLINE
void operator *= (
float inValue) { mValue *= inValue; }
138 JPH_INLINE
void operator /= (
float inValue) { mValue /= inValue; }
139 JPH_INLINE
Quat operator - ()
const {
return Quat(-mValue); }
145 JPH_INLINE
Quat operator / (
float inValue)
const {
return Quat(mValue / inValue); }
153 JPH_INLINE
Vec3 InverseRotate(
Vec3Arg inValue)
const;
156 JPH_INLINE
Vec3 RotateAxisX()
const;
159 JPH_INLINE
Vec3 RotateAxisY()
const;
162 JPH_INLINE
Vec3 RotateAxisZ()
const;
213 JPH_INLINE
void GetSwingTwist(
Quat &outSwing,
Quat &outTwist)
const;
219 JPH_INLINE
Quat LERP(
QuatArg inDestination,
float inFraction)
const;
226 JPH_INLINE
Quat SLERP(
QuatArg inDestination,
float inFraction)
const;
229 static JPH_INLINE
Quat sLoadFloat3Unsafe(
const Float3 &inV);
232 JPH_INLINE
void StoreFloat3(
Float3 *outV)
const;
235 friend ostream & operator << (ostream &inStream,
QuatArg inQ) { inStream << inQ.
mValue;
return inStream; }
241static_assert(is_trivial<Quat>(),
"Is supposed to be a trivial type!");
#define JPH_NAMESPACE_END
Definition Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition Core.h:234
DVec3 operator*(double inV1, DVec3Arg inV2)
Definition DVec3.inl:447
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:29
@ 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 ATan(float inX)
Arc tangent of x (returns value in the range [-PI / 2, PI / 2])
Definition Trigonometry.h:48
Class that holds 3 floats. Used as a storage class. Convert to Vec3 for calculations.
Definition Float3.h:13
Quat(const Quat &inRHS)=default
JPH_INLINE float GetW() const
Get W component (real part)
Definition Quat.h:77
JPH_INLINE float GetY() const
Get Y component (imaginary part j)
Definition Quat.h:71
JPH_INLINE float GetZ() const
Get Z component (imaginary part k)
Definition Quat.h:74
JPH_INLINE float GetX() const
Get X component (imaginary part i)
Definition Quat.h:68
JPH_INLINE float LengthSq() const
Definition Quat.h:122
bool IsNaN() const
If any component of this quaternion is a NaN (not a number)
Definition Quat.h:61
static JPH_INLINE Quat sIdentity()
Definition Quat.h:93
JPH_INLINE Vec4 GetXYZW() const
Get the quaternion as a Vec4.
Definition Quat.h:83
bool IsClose(QuatArg inRHS, float inMaxDistSq=1.0e-12f) const
If this quaternion is close to inRHS. Note that q and -q represent the same rotation,...
Definition Quat.h:55
JPH_INLINE Quat Normalized() const
Normalize the quaternion (make it length 1)
Definition Quat.h:129
JPH_INLINE Quat EnsureWPositive() const
Ensures that the W component is positive by negating the entire quaternion if it is not....
Definition Quat.h:174
Quat(Vec4Arg inV)
Definition Quat.h:42
JPH_INLINE float Dot(QuatArg inRHS) const
Dot product
Definition Quat.h:165
Quat()=default
Intentionally not initialized for performance reasons.
JPH_INLINE float Length() const
Definition Quat.h:126
JPH_INLINE Quat GetPerpendicular() const
Get a quaternion that is perpendicular to this quaternion.
Definition Quat.h:177
JPH_INLINE Quat Inversed() const
Get inverse quaternion.
Definition Quat.h:171
JPH_INLINE Quat Conjugated() const
The conjugate [w, -x, -y, -z] is the same as the inverse for unit quaternions.
Definition Quat.h:168
JPH_INLINE float GetRotationAngle(Vec3Arg inAxis) const
Get rotation angle around inAxis (uses Swing Twist Decomposition to get the twist quaternion and uses...
Definition Quat.h:180
Quat(float inX, float inY, float inZ, float inW)
Definition Quat.h:41
bool IsNormalized(float inTolerance=1.0e-5f) const
If the length of this quaternion is 1 +/- inTolerance.
Definition Quat.h:58
static JPH_INLINE Quat sZero()
Definition Quat.h:90
JPH_INLINE Vec3 GetXYZ() const
Get the imaginary part of the quaternion.
Definition Quat.h:80
Vec4 mValue
4 vector that stores [x, y, z, w] parts of the quaternion
Definition Quat.h:238
static JPH_INLINE UVec4 sReplicate(uint32 inV)
Replicate int inV across all components.
Definition UVec4.inl:56
JPH_INLINE Vec4 ReinterpretAsFloat() const
Reinterpret UVec4 as a Vec4 (doesn't change the bits)
Definition UVec4.inl:332
static JPH_INLINE Vec4 sAnd(Vec4Arg inV1, Vec4Arg inV2)
Logical and (component wise)
Definition Vec4.inl:290
static JPH_INLINE Vec4 sXor(Vec4Arg inV1, Vec4Arg inV2)
Logical xor (component wise)
Definition Vec4.inl:279
static JPH_INLINE Vec4 sZero()
Vector with all zeros.
Definition Vec4.inl:63
JPH_INLINE Vec4 Swizzle() const
Swizzle the elements in inV.