ezEngine  Milestone 9
ezVec4Template< Type > Class Template Reference

A 4-component vector class. More...

#include <Vec4.h>

Public Types

typedef Type ComponentType

Public Member Functions

 ezVec4Template ()
 Default-constructed vector is uninitialized (for speed)
 ezVec4Template (Type X, Type Y, Type Z, Type W)
 Initializes the vector with x,y,z,w.
 ezVec4Template (Type xyzw)
 Initializes all 4 components with xyzw.
const ezVec2Template< Type > GetAsVec2 () const
 Returns an ezVec2Template with x and y from this vector.
const ezVec3Template< Type > GetAsVec3 () const
 Returns an ezVec3Template with x,y and z from this vector.
const Type * GetData () const
 Returns the data as an array.
Type * GetData ()
 Returns the data as an array.
void Set (Type xyzw)
 Sets all 4 components to this value.
void Set (Type x, Type y, Type z, Type w)
 Sets the vector to these values.
void SetZero ()
 Sets the vector to all zero.
Type GetLength () const
 Returns the length of the vector.
Type GetLengthSquared () const
 Returns the squared length. Faster, since no square-root is taken. Useful, if one only wants to compare the lengths of two vectors.
Type GetLengthAndNormalize ()
 Normalizes this vector and returns its previous length in one operation. More efficient than calling GetLength and then Normalize.
const ezVec4Template GetNormalized () const
 Returns a normalized version of this vector, leaves the vector itself unchanged.
void Normalize ()
 Normalizes this vector.
ezResult NormalizeIfNotZero (const ezVec4Template &vFallback=ezVec4Template(1, 0, 0, 0), Type fEpsilon=ezMath::BasicType< Type >::SmallEpsilon())
 Tries to normalize this vector. If the vector is too close to zero, EZ_FAILURE is returned and the vector is set to the given fallback value.
bool IsZero () const
 Returns, whether this vector is (0, 0, 0, 0).
bool IsZero (Type fEpsilon) const
 Returns, whether this vector is (0, 0, 0, 0).
bool IsNormalized (Type fEpsilon=ezMath::BasicType< Type >::HugeEpsilon()) const
 Returns, whether the squared length of this vector is between 0.999f and 1.001f. More...
bool IsNaN () const
 Returns true, if any of x, y, z or w is NaN.
bool IsValid () const
 Checks that all components are finite numbers.
const ezVec4Template operator- () const
 Returns the negation of this vector.
void operator+= (const ezVec4Template &cc)
 Adds cc component-wise to this vector.
void operator-= (const ezVec4Template &cc)
 Subtracts cc component-wise from this vector.
void operator*= (Type f)
 Multiplies all components of this vector with f.
void operator/= (Type f)
 Divides all components of this vector by f.
bool IsIdentical (const ezVec4Template &rhs) const
 Equality Check (bitwise).
bool IsEqual (const ezVec4Template &rhs, Type fEpsilon) const
 Equality Check with epsilon.
Type Dot (const ezVec4Template &rhs) const
 Returns the Dot-product of the two vectors (commutative, order does not matter).
const ezVec4Template CompMin (const ezVec4Template &rhs) const
 Returns the component-wise minimum of *this and rhs.
const ezVec4Template CompMax (const ezVec4Template &rhs) const
 Returns the component-wise maximum of *this and rhs.
const ezVec4Template CompMul (const ezVec4Template &rhs) const
 Returns the component-wise multiplication of *this and rhs.
const ezVec4Template CompDiv (const ezVec4Template &rhs) const
 Returns the component-wise division of *this and rhs.
const ezVec4Template Abs () const
 brief Returns the component-wise absolute of *this.

Static Public Member Functions

static const ezVec4Template ZeroVector ()
 Static function that returns a zero-vector.

Public Attributes

Type x
Type y
Type z
Type w

Detailed Description

template<typename Type>
class ezVec4Template< Type >

A 4-component vector class.

Member Function Documentation

◆ IsNormalized()

template<typename Type >
bool ezVec4Template< Type >::IsNormalized ( Type  fEpsilon = ezMath::BasicType<Type>::HugeEpsilon()) const

Returns, whether the squared length of this vector is between 0.999f and 1.001f.

Normalization, especially with SSE is not very precise. So this function checks whether the (squared) length is between a lower and upper limit.

The documentation for this class was generated from the following files: