3#include <Foundation/Math/Math.h>
4#include <Foundation/Math/Vec3.h>
7template <
typename Type>
12 PL_DECLARE_POD_TYPE();
14 using ComponentType = Type;
36 PL_DECLARE_IF_FLOAT_TYPE
43#if PL_ENABLED(PL_MATH_CHECK_FOR_NAN)
44 void AssertNotNaN()
const
46 PL_ASSERT_ALWAYS(!
IsNaN(),
"This object contains NaN values. This can happen when you forgot to initialize it before using it. Please "
47 "check that all code-paths properly initialize this object.");
60 const Type*
GetData()
const {
return &x; }
71 void Set(Type x, Type y, Type z, Type w);
79 PL_DECLARE_IF_FLOAT_TYPE
88 PL_DECLARE_IF_FLOAT_TYPE
92 PL_DECLARE_IF_FLOAT_TYPE
96 PL_DECLARE_IF_FLOAT_TYPE
101 PL_DECLARE_IF_FLOAT_TYPE
108 bool IsZero(Type fEpsilon)
const;
111 PL_DECLARE_IF_FLOAT_TYPE
112 bool IsNormalized(Type fEpsilon = plMath::HugeEpsilon<Type>())
const;
171template <
typename Type>
174template <
typename Type>
178template <
typename Type>
181template <
typename Type>
185template <
typename Type>
189template <
typename Type>
192template <
typename Type>
196template <
typename Type>
199#include <Foundation/Math/Implementation/Vec4_inl.h>
A 2-component vector class.
Definition Vec2.h:14
A 3-component vector class.
Definition Vec3.h:9
A 4-component vector class.
Definition Vec4.h:9
PL_DECLARE_IF_FLOAT_TYPE bool IsNormalized(Type fEpsilon=plMath::HugeEpsilon< Type >()) const
Returns, whether the squared length of this vector is between 0.999f and 1.001f.
Definition Vec4_inl.h:202
PL_DECLARE_IF_FLOAT_TYPE plResult NormalizeIfNotZero(const plVec4Template< Type > &vFallback=plVec4Template< Type >(1, 0, 0, 0), Type fEpsilon=plMath::SmallEpsilon< Type >())
Tries to normalize this vector. If the vector is too close to zero, PL_FAILURE is returned and the ve...
Definition Vec4_inl.h:182
plVec4Template()
Default-constructed vector is uninitialized (for speed)
Definition Vec4_inl.h:63
const plVec4Template< Type > CompMin(const plVec4Template< Type > &rhs) const
Returns the component-wise minimum of *this and rhs.
Definition Vec4_inl.h:327
bool IsZero() const
Returns, whether this vector is (0, 0, 0, 0).
Definition Vec4_inl.h:209
bool IsEqual(const plVec4Template< Type > &rhs, Type fEpsilon) const
Equality Check with epsilon.
Definition Vec4_inl.h:444
const plVec4Template< Type > CompDiv(const plVec4Template< Type > &rhs) const
Returns the component-wise division of *this and rhs.
Definition Vec4_inl.h:366
void SetZero()
Sets the vector to all zero.
Definition Vec4_inl.h:139
PL_DECLARE_IF_FLOAT_TYPE Type GetLengthAndNormalize()
Normalizes this vector and returns its previous length in one operation. More efficient than calling ...
Definition Vec4_inl.h:159
const plVec3Template< Type > GetAsVec3() const
Returns an plVec3Template with x,y and z from this vector.
Definition Vec4_inl.h:112
void operator-=(const plVec4Template< Type > &vCc)
Subtracts cc component-wise from this vector.
Definition Vec4_inl.h:274
bool IsNaN() const
Returns true, if any of x, y, z or w is NaN.
Definition Vec4_inl.h:225
const plVec4Template< Type > CompClamp(const plVec4Template< Type > &vLow, const plVec4Template< Type > &vHigh) const
Returns the component-wise clamped value of *this between low and high.
Definition Vec4_inl.h:345
PL_DECLARE_IF_FLOAT_TYPE void Normalize()
Normalizes this vector.
Definition Vec4_inl.h:176
const plVec4Template< Type > operator-() const
Returns the negation of this vector.
Definition Vec4_inl.h:255
void operator/=(Type f)
Divides all components of this vector by f.
Definition Vec4_inl.h:296
const plVec4Template< Type > Abs() const
brief Returns the component-wise absolute of *this.
Definition Vec4_inl.h:376
static plVec4Template< Type > MakeZero()
Returns a vector with all components set to zero.
Definition Vec4.h:41
Type * GetData()
Returns the data as an array.
Definition Vec4.h:63
const Type * GetData() const
Returns the data as an array.
Definition Vec4.h:60
PL_DECLARE_IF_FLOAT_TYPE const plVec4Template< Type > GetNormalized() const
Returns a normalized version of this vector, leaves the vector itself unchanged.
Definition Vec4_inl.h:167
Type Dot(const plVec4Template< Type > &rhs) const
Returns the dot-product of the two vectors (commutative, order does not matter).
Definition Vec4_inl.h:318
void operator*=(Type f)
Multiplies all components of this vector with f.
Definition Vec4_inl.h:285
void Set(Type xyzw)
Sets all 4 components to this value.
Definition Vec4_inl.h:121
const plVec4Template< Type > CompMul(const plVec4Template< Type > &rhs) const
Returns the component-wise multiplication of *this and rhs.
Definition Vec4_inl.h:355
void operator+=(const plVec4Template< Type > &vCc)
Adds cc component-wise to this vector.
Definition Vec4_inl.h:263
bool IsIdentical(const plVec4Template< Type > &rhs) const
Equality Check (bitwise).
Definition Vec4_inl.h:435
const plVec4Template< Type > CompMax(const plVec4Template< Type > &rhs) const
Returns the component-wise maximum of *this and rhs.
Definition Vec4_inl.h:336
static PL_DECLARE_IF_FLOAT_TYPE plVec4Template< Type > MakeNaN()
Returns a vector with all components set to Not-a-Number (NaN).
Definition Vec4.h:38
const plVec2Template< Type > GetAsVec2() const
Returns an plVec2Template with x and y from this vector.
Definition Vec4_inl.h:103
bool IsValid() const
Checks that all components are finite numbers.
Definition Vec4_inl.h:240
Type GetLengthSquared() const
Returns the squared length. Faster, since no square-root is taken. Useful, if one only wants to compa...
Definition Vec4_inl.h:151
PL_DECLARE_IF_FLOAT_TYPE Type GetLength() const
Returns the length of the vector.
Definition Vec4_inl.h:145
constexpr TYPE NaN()
Returns the value for NaN as the template type. Returns zero, if the type does not support NaN.
Definition Constants_inl.h:58
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54