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

Public Member Functions

 Vector2 (const float rawArray[])
 
 Vector2 (float xy)
 
 Vector2 (float x, float y)
 
 Vector2 (const Vector2 &other)
 
 Vector2 (const __m128 &vector)
 
 Vector2 (__m128 &&vector)
 
void * operator new (size_t _size)
 
void operator delete (void *p)
 
void * operator new[] (size_t size)
 
void operator delete[] (void *p)
 
 operator __m128 (void) const
 Casts a Vector2 object to a __m128 This operator casts a Vector2 to an intrinsic __m128.
 
Vector2 operator+ (float s) const
 Adds all elements in Vector2 by a given scalar This operator returns a new Vector2. More...
 
Vector2 operator- (float s) const
 Subtracts all elements in Vector2 by a given scalar This operator returns a new Vector2. More...
 
Vector2 operator* (float s) const
 Multiplies all elements in Vector2 by a given scalar This operator returns a new Vector2. More...
 
Vector2 operator/ (float s) const
 Divides all elements in Vector2 by a given scalar This operator returns a new Vector2. More...
 
Vector2operator+= (float s)
 Adds all elements in this Vector2 by a given scalar This operation affects the elements in this Vector2. More...
 
Vector2operator-= (float s)
 Subtracts all elements in this Vector2 by a given scalar This operation affects the elements in this Vector2. More...
 
Vector2operator*= (float s)
 Multiplies all elements in this Vector2 by a given scalar This operation affects the elements in this Vector2. More...
 
Vector2operator/= (float s)
 Divides all elements in this Vector2 by a given scalar This operation affects the elements in this Vector2. More...
 
Vector2 operator+ (const Vector2 &u) const
 Adds all of the elements from a given Vector2 to this one. More...
 
Vector2 operator- (const Vector2 &u) const
 Subtracts all of the elements from a given Vector2 to this one. More...
 
Vector2 operator* (const Vector2 &u) const
 Multiplies all of the elements from a given Vector2 to this one. More...
 
Vector2 operator/ (const Vector2 &u) const
 Divides all of the elements from a given Vector2 to this one. More...
 
Vector2operator+= (const Vector2 &u)
 Adds all of the elements from a given Vector2 to this one. More...
 
Vector2operator-= (const Vector2 &u)
 Subtracts all of the elements from a given Vector2 to this one. More...
 
Vector2operator*= (const Vector2 &u)
 Multiplies all of the elements from a given Vector2 to this one. More...
 
Vector2operator/= (const Vector2 &u)
 Divides all of the elements from a given Vector2 to this one. More...
 
bool operator== (const Vector2 &u) const
 Compares the values of this Vector2 to another given Vector2. More...
 
bool operator!= (const Vector2 &u) const
 Compares the values of this Vector2 to another given Vector2. More...
 
const float & operator[] (size_t i) const
 Fetches an element of this Vector2 at the index i. More...
 
float & operator[] (size_t i)
 Fetches an element of this Vector2 at the index i. More...
 
float MagnitudeSquared () const
 Calculates the magnitude squared of this vector. More...
 
float Magnitude () const
 Calculates the magnitude of this vector. More...
 
Vector2 Normalized () const
 Calculates a normalized copy of this float. More...
 
Vector2 Normalize ()
 Normalizes this vector in place. More...
 
Float2 ToFloat2 () const
 Stores values from SIMD registers into Float2. More...
 
 Vector2 ()
 Create a Vector2 with both elements being 0.
 
 Vector2 (float x, float y)
 Create a Vector2 with the elements described by x and y.
 
 Vector2 (const Vector2 &other)
 Create a Vector2 with the elements of another Vector2.
 
float getX ()
 Returns the first element. More...
 
float getY ()
 Returns the second element. More...
 
float getMagnitude ()
 Returns the magnitude. 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...
 
float operator* (Vector2 u)
 Performs the dot procduct between this Vector2 and another Vector2. More...
 
Vector2 operator* (float s)
 Multiplies a scalar into this Vector2. More...
 
Vector2 operator+ (Vector2 u)
 Adds another Vector2 to this one. More...
 
float & operator[] (int i)
 Fetches an element of this Vector at the index i. More...
 

Static Public Member Functions

static float Dot (const Vector2 &v, const Vector2 &u)
 Calculates the dot product of two vectors. More...
 
static float Angle (const Vector2 &v, const Vector2 &u)
 Calculates the angle between two vectors. More...
 
static float Distance (const Vector2 &v, const Vector2 &u)
 Calculates the distance between two vectors. More...
 
static float Dot (Vector2 v, Vector2 u)
 Executes the Dot product on two Vector2s as v * u. More...
 
static Vector2 Normalize (Vector2 v)
 Normalizes a Vector2. More...
 

Public Attributes

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

Member Function Documentation

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

Calculates the angle between two vectors.

Parameters
vFirst Vector2 used to calculate angle
uSecond Vector2 used to calculate angle
Returns
The angle between v and u as a float
float Vector2::Distance ( const Vector2 v,
const Vector2 u 
)
inlinestatic

Calculates the distance between two vectors.

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

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

Parameters
vThe first Vector2
uThe second Vector2
Returns
The Dot product of v and u as a float
float Vector2::Dot ( const Vector2 v,
const Vector2 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 * Vector2::getAsArray ( )

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

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

Returns the magnitude.

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

Returns the first element.

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

Returns the second element.

Returns
The second element
float Vector2::Magnitude ( ) const
inline

Calculates the magnitude of this vector.

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

Calculates the magnitude squared of this vector.

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

Normalizes a Vector2.

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

Normalizes this vector in place.

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

Calculates a normalized copy of this float.

Returns
the copy
bool Vector2::operator!= ( const Vector2 u) const
inline

Compares the values of this Vector2 to another given Vector2.

Parameters
uThe other Vector2
Returns
True if this Vector2 does not have the same values of the other Vector2
float Vector2::operator* ( Vector2  u)

Performs the dot procduct between this Vector2 and another Vector2.

Parameters
uThe other Vector2
Returns
The dot product between this vector and u
Vector2 Vector2::operator* ( float  s)

Multiplies a scalar into this Vector2.

Parameters
sThe other scalar
Returns
A Vector2 whose elements have been multiplied by s
Vector2 Vector2::operator* ( float  s) const
inline

Multiplies all elements in Vector2 by a given scalar This operator returns a new Vector2.

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

Multiplies all of the elements from a given Vector2 to this one.

Parameters
uThe other Vector2
Returns
A new vector with the products of all the pairs of elements
Vector2 & Vector2::operator*= ( float  s)
inline

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

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

Multiplies all of the elements from a given Vector2 to this one.

Parameters
uThe other Vector2
Returns
This Vector2 with the products of all the pairs of elements
Vector2 Vector2::operator+ ( Vector2  u)

Adds another Vector2 to this one.

Parameters
uThe other Vector2
Returns
A Vector2 whose elements are a result of this Vector2 added to u
Vector2 Vector2::operator+ ( float  s) const
inline

Adds all elements in Vector2 by a given scalar This operator returns a new Vector2.

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

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

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

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

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

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

Parameters
uThe other Vector2
Returns
This Vector2 with the sums of all the pairs of elements
Vector2 Vector2::operator- ( float  s) const
inline

Subtracts all elements in Vector2 by a given scalar This operator returns a new Vector2.

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

Subtracts all of the elements from a given Vector2 to this one.

Parameters
uThe other Vector2
Returns
A new vector with the differences of all the pairs of elements
Vector2 & Vector2::operator-= ( float  s)
inline

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

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

Subtracts all of the elements from a given Vector2 to this one.

Parameters
uThe other Vector2
Returns
This Vector2 with the differences of all the pairs of elements
Vector2 Vector2::operator/ ( float  s) const
inline

Divides all elements in Vector2 by a given scalar This operator returns a new Vector2.

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

Divides all of the elements from a given Vector2 to this one.

Parameters
uThe other Vector2
Returns
A new vector with the quocient of all the pairs of elements
Vector2 & Vector2::operator/= ( float  s)
inline

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

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

Divides all of the elements from a given Vector2 to this one.

Parameters
uThe other Vector2
Returns
This Vector2 with the quocient of all the pairs of elements
bool Vector2::operator== ( const Vector2 u) const
inline

Compares the values of this Vector2 to another given Vector2.

Parameters
uThe other Vector2
Returns
True if this Vector2 has the same values of the other Vector2
float & Vector2::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 Vector2 at the index i This will throw an index out of range exception if you go beyond an index if 1
const float & Vector2::operator[] ( size_t  i) const
inline

Fetches an element of this Vector2 at the index i.

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

Fetches an element of this Vector2 at the index i.

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

Sets the first element.

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

Sets the second element.

Parameters
yThe float you want to be the second element of this vector
Float2 Vector2::ToFloat2 ( ) const
inline

Stores values from SIMD registers into Float2.

Returns
Float2 with Vector2 data.

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