HatchitMath
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
Hatchit::Math::Vector4 Class Reference

Public Member Functions

 Vector4 (const float rawArray[])
 
 Vector4 (float xyzw)
 
 Vector4 (float x, float y, float z, float w)
 
 Vector4 (const Vector2 &xy, float z, float w)
 
 Vector4 (const Vector3 &xyz, float w)
 
 Vector4 (const Vector4 &other)
 
 Vector4 (__m128 v)
 
void * operator new (size_t _size)
 
void operator delete (void *p)
 
 operator __m128 (void) const
 
Vector4 operator+ (float s) const
 Adds all elements in this Vector4 by a given scalar This operation returns a new Vector4. More...
 
Vector4 operator- (float s) const
 Subtracts all elements in this Vector4 by a given scalar This operation returns a new Vector4. More...
 
Vector4 operator* (float s) const
 Multiplies all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4. More...
 
Vector4 operator/ (float s) const
 Divides all elements in this Vector4 by a given scalar This operation returns a new Vector4. More...
 
Vector4operator+= (float s)
 Adds all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4. More...
 
Vector4operator-= (float s)
 Subtracts all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4. More...
 
Vector4operator*= (float s)
 Multiplies all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4. More...
 
Vector4operator/= (float s)
 Divides all of the elements from this vector by a given scalar This operation affects the elements in this Vector4. More...
 
bool operator== (const Vector4 &u) const
 Compares the values of this Vector4 to another given Vector4. More...
 
bool operator!= (const Vector4 &u) const
 Compares the values of this Vector4 to another given Vector4. More...
 
Vector4 operator+ (const Vector4 &u) const
 Adds all of the elements from a given vector to this one. More...
 
Vector4 operator- (const Vector4 &u) const
 Subtracts all of the elements from this vector by a given vector. More...
 
Vector4 operator* (const Vector4 &u) const
 Executes memberwise multiplication on this Vector4. More...
 
Vector4 operator/ (const Vector4 &u) const
 Executes memberwise division on this Vector4. More...
 
Vector4operator+= (const Vector4 &u)
 Adds all of the elements from a given vector to this one. More...
 
Vector4operator-= (const Vector4 &u)
 Subtracts all of the elements from this vector by a given one. More...
 
Vector4operator*= (const Vector4 &u)
 Multiplies all of the elements of this vector by a given one. More...
 
Vector4operator/= (const Vector4 &u)
 Divides all the elements of this vector by the elements of a given vector. More...
 
float & operator[] (size_t i)
 Fetches an element of this Vector at the index i. More...
 
const float & operator[] (size_t i) const
 Fetches an element of this Vector at the index i. More...
 
 operator Vector3 () const
 
 operator Vector2 () const
 
Vector4 Normalized () const
 
Vector4 NormalizedEst () const
 
float Magnitude () const
 
float MagnitudeSqr () const
 
Float4 ToFloat4 () const
 Stores values from SIMD registers into Float4. More...
 
 Vector4 ()
 Create a Vector4 with all 4 elements being 0.
 
 Vector4 (float x, float y, float z, float w)
 Create a Vector4 with the elements x, y and z.
 
 Vector4 (const Vector4 &other)
 Create a copy of an existing Vector4.
 
 Vector4 (Vector3 &v3, float w)
 Create a Vector4 with the first three elements of a given Vector3 and a fourth given float w.
 
void * operator new (size_t _size)
 Allocate a 16byte aligned array of Vector4s.
 
void operator delete (void *p)
 Delete an array of Vector4s.
 
 operator const __m128 (void) const
 Cast Vector4's SSE intrinsic to __m128.
 
float magSqr ()
 
float mag ()
 Returns the magnitude of the vector. More...
 
Vector4 normalized ()
 Normalizes a Vector4. More...
 
float * getAsArray ()
 Returns this Vector4 as a pointer to an array of floats. More...
 
Vector4 operator* (float s)
 Multiplies all elements in this Vector4 by a given scalar This operation returns a new Vector4. More...
 
Vector4 operator/ (float s)
 Divides all elements in this Vector4 by a given scalar This operation returns a new Vector4. More...
 
Vector4 operator- (float s)
 Subtracts all elements in this Vector4 by a given scalar This operation returns a new Vector4. More...
 
Vector4 operator+ (float s)
 Adds all elements in this Vector4 by a given scalar This operation returns a new Vector4. More...
 
Vector4 operator*= (float s)
 Multiplies all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4. More...
 
Vector4 operator/= (float s)
 Divides all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4. More...
 
Vector4 operator-= (float s)
 Subtracts all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4. More...
 
Vector4 operator+= (float s)
 Adds all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4. More...
 
bool operator> (Vector4 u)
 Compares the magnitue of this Vector4 to another given Vector4. More...
 
bool operator< (Vector4 u)
 Compares the magnitue of this Vector4 to another given Vector4. More...
 
bool operator== (Vector4 u)
 Compares the values of this Vector4 to another given Vector4. More...
 
bool operator!= (Vector4 u)
 Compares the values of this Vector4 to another given Vector4. More...
 
float operator* (Vector4 u)
 Executes the Dot product this Vector4 and another as this * other. More...
 
Vector4 operator+ (Vector4 u)
 Adds all of the elements from a given vector to this one. More...
 
Vector4 operator- (Vector4 u)
 Subtracts all of the elements from this vector by a given vector. More...
 
Vector4 operator+= (Vector4 u)
 Adds all of the elements from a given vector to this one. More...
 
Vector4 operator-= (Vector4 u)
 Subtracts all of the elements from this vector by a given one. More...
 
float & operator[] (int i)
 Fetches an element of this Vector at the index i. More...
 
 operator Vector3 ()
 Returns a Vector3 with the first three elements from this vector and the last one being 0.
 
 operator Vector2 ()
 Returns a Vector2 with the fist two elements from this vector.
 

Static Public Member Functions

static float Dot (const Vector4 &v, const Vector4 &u)
 
static float Dot (Vector4 v, Vector4 u)
 Executes the Dot product on two Vector4s as v * u. More...
 

Public Attributes

union {
   __m128   m_vector
 
   struct {
      float   x
 
      float   y
 
      float   z
 
      float   w
 
   } 
 
   float   m_data [4]
 
}; 
 
union {
   __m128   m_vector
 
   struct {
      float   x
 
      float   y
 
      float   z
 
      float   w
 
   } 
 
   float   data [4]
 
}; 
 

Friends

class Matrix4
 
class Quaternion
 

Member Function Documentation

float Vector4::Dot ( Vector4  v,
Vector4  u 
)
static

Executes the Dot product on two Vector4s as v * u.

Parameters
vThe first Vector4
uThe second Vector4
Returns
The Dot product of v and u as a float
float * Vector4::getAsArray ( )

Returns this Vector4 as a pointer to an array of floats.

Returns
This vector as an array of floats
float Vector4::mag ( )

Returns the magnitude of the vector.

Returns
The magnitude as a float
Vector4 Vector4::normalized ( )

Normalizes a Vector4.

Parameters
vThe Vector4 to normalize
Returns
A normalized version of v
bool Vector4::operator!= ( Vector4  u)

Compares the values of this Vector4 to another given Vector4.

Parameters
uThe other Vector4
Returns
True if this Vector4 does not have the same values as the other Vector4
bool Vector4::operator!= ( const Vector4 rhs) const
inline

Compares the values of this Vector4 to another given Vector4.

Parameters
uThe other Vector4
Returns
True if this Vector4 does not have the same values as the other Vector4
Vector4 Vector4::operator* ( float  s)

Multiplies all elements in this Vector4 by a given scalar This operation returns a new Vector4.

Parameters
sThe scalar to multiply this Vector4 by
Returns
A Vector4 after all the elements have been multiplied by s
float Vector4::operator* ( Vector4  u)

Executes the Dot product this Vector4 and another as this * other.

Parameters
uThe other Vector4
Returns
The Dot product of this * u as a float
Vector4 Vector4::operator* ( float  s) const
inline

Multiplies all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4.

Parameters
sThe scalar to multiply this Vector4 by
Returns
A Vector4 after all the elements have been multiplied by s
Vector4 Vector4::operator* ( const Vector4 rhs) const
inline

Executes memberwise multiplication on this Vector4.

Parameters
uThe other Vector4
Returns
The products of this * u as a Vector4
Vector4 Hatchit::Math::Vector4::operator*= ( float  s)

Multiplies all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4.

Parameters
sThe scalar to multiply this Vector4 by
Returns
This Vector4 after all the elements have been multiplied by s
Vector4 Vector4::operator*= ( float  s)
inline

Multiplies all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4.

Parameters
sThe scalar to multiply this Vector4 by
Returns
This Vector4 after all the elements have been multiplied by s
Vector4 & Vector4::operator*= ( const Vector4 rhs)
inline

Multiplies all of the elements of this vector by a given one.

Parameters
uThe Vector4 which to multiply the elements by
Returns
This vector with the products of this vector's elements and the given vector's elements.
Vector4 Vector4::operator+ ( float  s)

Adds all elements in this Vector4 by a given scalar This operation returns a new Vector4.

Parameters
sThe scalar to add this Vector4 by
Returns
A Vector4 after all the elements have been added by s
Vector4 Vector4::operator+ ( Vector4  u)

Adds all of the elements from a given vector to this one.

Parameters
uThe other Vector4
Returns
A new vector with the sums of all the pairs of elements
Vector4 Vector4::operator+ ( float  s) const
inline

Adds all elements in this Vector4 by a given scalar This operation returns a new Vector4.

Parameters
sThe scalar to add this Vector4 by
Returns
A Vector4 after all the elements have been added by s
Vector4 Vector4::operator+ ( const Vector4 rhs) const
inline

Adds all of the elements from a given vector to this one.

Parameters
uThe other Vector4
Returns
A new vector with the sums of all the pairs of elements
Vector4 Hatchit::Math::Vector4::operator+= ( float  s)

Adds all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4.

Parameters
sThe scalar to add this Vector4 by
Returns
This Vector4 after all the elements have been added by s
Vector4 Vector4::operator+= ( Vector4  u)

Adds all of the elements from a given vector to this one.

Parameters
uThe other Vector4
Returns
This vector with the sums of all the pairs of elements
Vector4 Vector4::operator+= ( float  s)
inline

Adds all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4.

Parameters
sThe scalar to add this Vector4 by
Returns
This Vector4 after all the elements have been added by s
Vector4 & Vector4::operator+= ( const Vector4 rhs)
inline

Adds all of the elements from a given vector to this one.

Parameters
uThe other Vector4
Returns
This vector with the sums of all the pairs of elements
Vector4 Vector4::operator- ( float  s)

Subtracts all elements in this Vector4 by a given scalar This operation returns a new Vector4.

Parameters
sThe scalar to subtract this Vector4 by
Returns
A Vector4 after all the elements have been subtracted by s
Vector4 Vector4::operator- ( Vector4  u)

Subtracts all of the elements from this vector by a given vector.

Parameters
uThe other Vector4
Returns
A new vector with the differences of all the pairs of elemens
Vector4 Vector4::operator- ( float  s) const
inline

Subtracts all elements in this Vector4 by a given scalar This operation returns a new Vector4.

Parameters
sThe scalar to subtract this Vector4 by
Returns
A Vector4 after all the elements have been subtracted by s
Vector4 Vector4::operator- ( const Vector4 u) const
inline

Subtracts all of the elements from this vector by a given vector.

Parameters
uThe other Vector4
Returns
A new vector with the differences of all the pairs of elemens
Vector4 Hatchit::Math::Vector4::operator-= ( float  s)

Subtracts all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4.

Parameters
sThe scalar to subtract this Vector4 by
Returns
This Vector4 after all the elements have been subtracted by s
Vector4 Vector4::operator-= ( Vector4  u)

Subtracts all of the elements from this vector by a given one.

Parameters
uThe other Vector4
Returns
This vector with the differences of all the pairs of elements
Vector4 Vector4::operator-= ( float  s)
inline

Subtracts all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4.

Parameters
sThe scalar to subtract this Vector4 by
Returns
This Vector4 after all the elements have been subtracted by s
Vector4 & Vector4::operator-= ( const Vector4 rhs)
inline

Subtracts all of the elements from this vector by a given one.

Parameters
uThe other Vector4
Returns
This vector with the differences of all the pairs of elements
Vector4 Vector4::operator/ ( float  s)

Divides all elements in this Vector4 by a given scalar This operation returns a new Vector4.

Parameters
sThe scalar to divide this Vector4 by
Returns
A Vector4 after all the elements have been divided by s
Vector4 Vector4::operator/ ( float  s) const
inline

Divides all elements in this Vector4 by a given scalar This operation returns a new Vector4.

Parameters
sThe scalar to divide this Vector4 by
Returns
A Vector4 after all the elements have been divided by s
Vector4 Vector4::operator/ ( const Vector4 rhs) const
inline

Executes memberwise division on this Vector4.

Parameters
uThe Vector4 with the values to divide by
Returns
The quotients of this / u as a Vector4.
Vector4 Hatchit::Math::Vector4::operator/= ( float  s)

Divides all elements in this Vector4 by a given scalar This operation affects the elements in this Vector4.

Parameters
sThe scalar to divide this Vector4 by
Returns
This Vector4 after all the elements have been divided by s
Vector4 Vector4::operator/= ( float  s)
inline

Divides all of the elements from this vector by a given scalar This operation affects the elements in this Vector4.

Parameters
sScalar to divide elements by
Returns
This vector with the differences of all the pairs of elements
Vector4 & Vector4::operator/= ( const Vector4 rhs)
inline

Divides all the elements of this vector by the elements of a given vector.

Parameters
uThe Vector4 which to divide this vector4's elements by
Returns
This vector with the elements of this vector divided by the elements of the given vector's elements.
bool Vector4::operator< ( Vector4  u)

Compares the magnitue of this Vector4 to another given Vector4.

Parameters
uThe other Vector4
Returns
True if this Vector4 has a smaller magnitude than the other Vector4
bool Vector4::operator== ( Vector4  u)

Compares the values of this Vector4 to another given Vector4.

Parameters
uThe other Vector4
Returns
True if this Vector4 has the same values of the other Vector4
bool Vector4::operator== ( const Vector4 rhs) const
inline

Compares the values of this Vector4 to another given Vector4.

Parameters
uThe other Vector4
Returns
True if this Vector4 has the same values of the other Vector4
bool Vector4::operator> ( Vector4  u)

Compares the magnitue of this Vector4 to another given Vector4.

Parameters
uThe other Vector4
Returns
True if this Vector4 has a larger magnitude than the other Vector4
float & Vector4::operator[] ( int  i)

Fetches an element of this Vector at the index i.

Parameters
iThe index of the element to fetch
Returns
A float that is stored in this Vector4 at the index i This will throw an index out of range exception if you go beyond an index if 1
float & Vector4::operator[] ( size_t  i)
inline

Fetches an element of this Vector at the index i.

Parameters
iThe index of the element to fetch
Returns
A float that is stored in this Vector4 at the index i This will throw an index out of range exception if you go beyond an index if 1
const float & Vector4::operator[] ( size_t  i) const
inline

Fetches an element of this Vector at the index i.

Parameters
iThe index of the element to fetch
Returns
A float that is stored in this Vector4 at the index i This will throw an index out of range exception if you go beyond an index if 1
Float4 Vector4::ToFloat4 ( ) const
inline

Stores values from SIMD registers into Float4.

Returns
Float4 with Vector4 data.

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