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

Public Member Functions

 Vector3 (const float rawArray[])
 
 Vector3 (float xyz)
 
 Vector3 (const Vector2 &xy, float z)
 
 Vector3 (float x, float y, float z)
 
 Vector3 (const Vector3 &other)
 
void * operator new (size_t _size)
 
void operator delete (void *p)
 
 operator const __m128 (void) const
 Casts a Vector3 object to a __m128 This operator casts a Vector3 to an instrinsic __m128.
 
Vector3 operator+ (float s) const
 Adds all elements in this Vector3 by a given scalar This operation returns a new Vector3. More...
 
Vector3 operator- (float s) const
 Subtracts all elements in this Vector3 by a given scalar This operation returns a new Vector3. More...
 
Vector3 operator* (float s) const
 Multiplies all elements in this Vector3 by a given scalar This operation returns a new Vector3. More...
 
Vector3 operator/ (float s) const
 Divides all elements in this Vector3 by a given scalar This operation returns a new Vector3. More...
 
Vector3 operator+= (float s)
 Adds all elements in this Vector3 by a given scalar This operation affects the elements in this Vector3. More...
 
Vector3 operator-= (float s)
 Subtracts all elements in this Vector3 by a given scalar This operation affects the elements in this Vector3. More...
 
Vector3 operator*= (float s)
 Multiplies all elements in this Vector3 by a given scalar This operation affects the elements in this Vector3. More...
 
Vector3 operator/= (float s)
 Divides all elements in this Vector3 by a given scalar This operation affects the elements in this Vector3. More...
 
Vector3 operator+ (const Vector3 &u) const
 Adds all of the elements from a given vector to this one. More...
 
Vector3 operator- (const Vector3 &u) const
 Subtracts all of the elements from this vector by a given vector. More...
 
Vector3 operator* (const Vector3 &u) const
 Executes memberwise multiplication on two vectors. More...
 
Vector3 operator/ (const Vector3 &u) const
 Executes memberwise division on two vectors. More...
 
Vector3 operator+= (const Vector3 &u)
 Adds all of the elements from a given vector to this one. More...
 
Vector3 operator-= (const Vector3 &u)
 Subtracts all of the elements from this vector by a given one. More...
 
Vector3 operator*= (const Vector3 &u)
 memberwise multiplication that stores the result in the first operand More...
 
Vector3 operator/= (const Vector3 &u)
 memberwise division that stores the result in the first operand More...
 
bool operator== (const Vector3 &u) const
 Compares the values of this Vector3 to another given Vector3. More...
 
bool operator!= (const Vector3 &u) const
 Compares the values of this Vector3 to another given Vector3. More...
 
const float & operator[] (int i) const
 Fetches an element of this Vector at the index i by reference. More...
 
float & operator[] (int i)
 Fetches an element of this Vector at the index i by reference. More...
 
 operator Vector2 () const
 
float MagnitudeSquared () const
 Calculates the magnitude squared of this vector. More...
 
float Magnitude () const
 Calculates the magnitude of this vector. More...
 
Vector3 Normalized () const
 Calculates a normalized copy of this float. More...
 
Vector3 Normalize ()
 Normalizes this vector in place. More...
 
Float3 ToFloat3 () const
 Stores values from SIMD registers into Float3. More...
 
 Vector3 ()
 Create a Vector3 with all 3 elements being 0.
 
 Vector3 (float x, float y, float z)
 Create a Vector3 with the elements x, y and z.
 
 Vector3 (const Vector3 &other)
 Create a copy of an existing Vector3.
 
 Vector3 (Vector4 &v4)
 Create a Vector3 with the first three elements of a given Vector4 all divided by the 4th element.
 
void * operator new (size_t _size)
 Allocate a 16byte aligned array of Vector3s.
 
void operator delete (void *p)
 Delete an array of Vector3s.
 
 operator const __m128 (void) const
 Fetch the Vector3's SSE intrinsic __m128.
 
float getX ()
 Returns the first element. More...
 
float getY ()
 Returns the second element. More...
 
float getZ ()
 Returns the third element. More...
 
float getMagnitude ()
 Returns the magnitude of the vector. More...
 
float * getAsArray ()
 Returns this Vector3 as a pointer to an array of floats. More...
 
void setX (float x)
 Sets the first element. More...
 
void setY (float y)
 Sets the second element. More...
 
void setZ (float z)
 Sets the third element. More...
 
Vector3 operator* (float s)
 Multiplies all elements in this Vector3 by a given scalar This operation returns a new Vector3. More...
 
Vector3 operator/ (float s)
 Divides all elements in this Vector3 by a given scalar This operation returns a new Vector3. More...
 
Vector3 operator- (float s)
 Subtracts all elements in this Vector3 by a given scalar This operation returns a new Vector3. More...
 
Vector3 operator+ (float s)
 Adds all elements in this Vector3 by a given scalar This operation returns a new Vector3. More...
 
Vector3 operator*= (float s)
 Multiplies all elements in this Vector3 by a given scalar This operation affects the elements in this Vector3. More...
 
Vector3 operator/= (float s)
 Divides all elements in this Vector3 by a given scalar This operation affects the elements in this Vector3. More...
 
Vector3 operator-= (float s)
 Subtracts all elements in this Vector3 by a given scalar This operation affects the elements in this Vector3. More...
 
Vector3 operator+= (float s)
 Adds all elements in this Vector3 by a given scalar This operation affects the elements in this Vector3. More...
 
bool operator> (Vector3 u)
 Compares the magnitue of this Vector3 to another given Vector3. More...
 
bool operator< (Vector3 u)
 Compares the magnitue of this Vector3 to another given Vector3. More...
 
bool operator== (Vector3 u)
 Compares the values of this Vector3 to another given Vector3. More...
 
bool operator!= (Vector3 u)
 Compares the values of this Vector3 to another given Vector3. More...
 
float operator* (Vector3 u)
 Executes the Dot product this Vector3 and another as this * other. More...
 
Vector3 operator+ (Vector3 u)
 Adds all of the elements from a given vector to this one. More...
 
Vector3 operator- (Vector3 u)
 Subtracts all of the elements from this vector by a given vector. More...
 
Vector3 operator+= (Vector3 u)
 Adds all of the elements from a given vector to this one. More...
 
Vector3 operator-= (Vector3 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 Vector4 ()
 Returns a Vector4 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 Vector3 Cross (const Vector3 &v, const Vector3 &u)
 Calculates the cross product of two vectors. More...
 
static float Dot (const Vector3 &v, const Vector3 &u)
 Calculates the dot product of two vectors. More...
 
static float Angle (const Vector3 &v, const Vector3 &u)
 Calculates the angle between two vectors. More...
 
static float Distance (const Vector3 &v, const Vector3 &u)
 Calculates the distance between two vectors. More...
 
static Vector3 Cross (Vector3 v, Vector3 u)
 Executes the cross product on two given Vector3s as v X u. More...
 
static float Dot (Vector3 v, Vector3 u)
 Executes the Dot product on two Vector3s as v * u. More...
 
static Vector3 Normalize (Vector3 v)
 Normalizes a Vector3. More...
 

Public Attributes

union {
   struct {
      float   x
 
      float   y
 
      float   z
 
   } 
 
   float   m_data [3]
 
   __m128   m_vector
 
}; 
 

Friends

class Matrix4
 

Member Function Documentation

float Vector3::Angle ( const Vector3 v,
const Vector3 u 
)
inlinestatic

Calculates the angle between two vectors.

Parameters
vFirst Vector3 used to calculate angle
uSecond Vector3 used to calculate angle
Returns
The angle between v and u as a float
Vector3 Vector3::Cross ( Vector3  v,
Vector3  u 
)
static

Executes the cross product on two given Vector3s as v X u.

Parameters
vThe first Vector3
uThe second Vector3
Returns
The corss product of v and u as a Vector3
Vector3 Vector3::Cross ( const Vector3 v,
const Vector3 u 
)
inlinestatic

Calculates the cross product of two vectors.

Parameters
v,uvectors used to calculate the cross product
Returns
cross product as a vector3
float Vector3::Distance ( const Vector3 v,
const Vector3 u 
)
inlinestatic

Calculates the distance between two vectors.

Parameters
vFirst Vector3 used to calculate distance
uSecond Vector3 used to calculate distance
Returns
The distance between v and u as a float
float Vector3::Dot ( Vector3  v,
Vector3  u 
)
static

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

Parameters
vThe first Vector3
uThe second Vector3
Returns
The Dot product of v and u as a float
float Vector3::Dot ( const Vector3 v,
const Vector3 u 
)
inlinestatic

Calculates the dot product of two vectors.

Parameters
v,uvectors used to calculate the dot product
Returns
dot product as a float
float * Vector3::getAsArray ( )

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

Returns
This vector as an array of floats
float Vector3::getMagnitude ( )

Returns the magnitude of the vector.

Returns
The magnitude as a float
float Vector3::getX ( void  )

Returns the first element.

Returns
The first element
float Vector3::getY ( void  )

Returns the second element.

Returns
The second element
float Vector3::getZ ( void  )

Returns the third element.

Returns
The third element
float Vector3::Magnitude ( ) const
inline

Calculates the magnitude of this vector.

Returns
magnitude as a float
float Vector3::MagnitudeSquared ( ) const
inline

Calculates the magnitude squared of this vector.

Returns
magnitude squared as a float
Vector3 Vector3::Normalize ( Vector3  v)
static

Normalizes a Vector3.

Parameters
vThe Vector3 to normalize
Returns
A normalized version of v
Vector3 Vector3::Normalize ( )
inline

Normalizes this vector in place.

Returns
the same vector
Vector3 Vector3::Normalized ( ) const
inline

Calculates a normalized copy of this float.

Returns
the copy
bool Vector3::operator!= ( Vector3  u)

Compares the values of this Vector3 to another given Vector3.

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

Compares the values of this Vector3 to another given Vector3.

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

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

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

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

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

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

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

Executes memberwise multiplication on two vectors.

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

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

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

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

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

memberwise multiplication that stores the result in the first operand

Parameters
uother vector3
Returns
this
Vector3 Vector3::operator+ ( float  s)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Executes memberwise division on two vectors.

Parameters
uThe other Vector3
Returns
The quocient of this / u as a vector
Vector3 Hatchit::Math::Vector3::operator/= ( float  s)

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

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

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

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

memberwise division that stores the result in the first operand

Parameters
uother vector3
Returns
this
bool Vector3::operator< ( Vector3  u)

Compares the magnitue of this Vector3 to another given Vector3.

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

Compares the values of this Vector3 to another given Vector3.

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

Compares the values of this Vector3 to another given Vector3.

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

Compares the magnitue of this Vector3 to another given Vector3.

Parameters
uThe other Vector3
Returns
True if this Vector3 has a larger magnitude than the other Vector3
float& Hatchit::Math::Vector3::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 Vector3 at the index i This will throw an index out of range exception if you go beyond an index if 1
const float & Vector3::operator[] ( int  i) const
inline

Fetches an element of this Vector at the index i by reference.

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

Fetches an element of this Vector at the index i by reference.

Parameters
iThe index of the element to fetch
Returns
A float that is stored in this Vector3 at the index i This will throw an index out of range exception if you go beyond an index if 1
void Vector3::setX ( float  x)

Sets the first element.

Parameters
xThe float you want to be the first element of this vector
void Vector3::setY ( float  y)

Sets the second element.

Parameters
yThe float you want to be the second element of this vector
void Vector3::setZ ( float  z)

Sets the third element.

Parameters
zThe float you want to be the third element of this vector
Float3 Vector3::ToFloat3 ( ) const
inline

Stores values from SIMD registers into Float3.

Returns
Float3 with Vector3 data.

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