Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
om::math::VectorND< T, 2 > Class Template Reference

A class that represents a 2-dimensional point or vector. More...

#include <omVector2D.h>

Public Member Functions

 VectorND ()
 Create a new 2D vector with all elements equal to zero. More...
 
 VectorND (T value)
 Create a new 2D vector with all elements equal to a single value. More...
 
 VectorND (const T array[2])
 Create a new 2D vector from a pointer to a 2 element array. More...
 
 VectorND (T newX, T newY)
 Create a new 2D vector by specifying it's x and y values. More...
 
template<typename U >
 VectorND (const VectorND< U, 2 > &vector)
 Create a new 2D vector from an existing vector of a different template type. More...
 
 VectorND (const VectorND &vector)
 Create a new 2D vector from an existing vector with the same template type. More...
 
VectorNDoperator= (const VectorND &vector)
 Create a new 2D vector from an existing vector with a different template type. More...
 
getMagnitude () const
 Return the magnitude of this vector (the length). More...
 
getMagnitudeSquared () const
 Return the square of the magnitude of this vector. More...
 
VectorND normalize () const
 Return a normalized version of this vector. More...
 
VectorND normalize (T &magnitude) const
 Return a normalized version of this vector, placing the vector's magnitude in the output parameter. More...
 
VectorND projectOn (const VectorND &vector) const
 Project this vector on another vector and return the projected vector. More...
 
VectorND projectOnNormalized (const VectorND &vector) const
 Project this vector on a normalized vector and return the projected vector. More...
 
getDistanceTo (const VectorND &vector) const
 Return the distance from this vector to another in 2D Euclidean space. More...
 
getDistanceToSquared (const VectorND &vector) const
 Return the square of the distance from this vector to another in 2D Euclidean space. More...
 
T * toArray ()
 Return a pointer to the internal storage of this vector. More...
 
const T * toArray () const
 Return a const pointer to the internal storage of this vector. More...
 
getMin () const
 Return the minimum coordinate of this vector. More...
 
getMax () const
 Return the maximum coordinate of this vector. More...
 
T & get (Index index)
 Return a reference to the vector coordinate at the specified index. More...
 
const T & get (Index index) const
 Return a const reference to the vector coordinate at the specified index. More...
 
T & operator[] (Index index)
 Return a reference to the vector coordinate at the specified index. More...
 
const T & operator[] (Index index) const
 Return a const reference to the vector coordinate at the specified index. More...
 
void setAll (T newX, T newY)
 Set the X and Y coordinates of the vector to the specified values. More...
 
void set (Index index, T newValue)
 Set the coordinate of this vector at the specified index to a new value. More...
 
Bool operator== (const VectorND &v) const
 Return whether or not this vector is equal to another for all components. More...
 
Bool operator!= (const VectorND &v) const
 Return whether or not this vector is not equal to another for any component. More...
 
VectorND operator- () const
 Negate each component of this vector and return the result. More...
 
VectorND operator+ () const
 Return copy of the original vector. More...
 
VectorND operator+ (T value) const
 Add a scalar to every component of this vector and return the result. More...
 
VectorND operator- (T value) const
 Subtract a scalar from every component of this vector and return the result. More...
 
VectorND operator* (T value) const
 Multiply every component of this vector by a scalar and return the result. More...
 
VectorND operator/ (T value) const
 Divide every component of this vector by a scalar and return the result. More...
 
VectorND operator+ (const VectorND &vector) const
 Add this vector to another and return the result and return the result. More...
 
VectorND operator- (const VectorND &vector) const
 Subtract a vector from this vector and return the result. More...
 
VectorND operator* (const VectorND &vector) const
 Multiply this vector by another vector and return the result. More...
 
VectorND operator/ (const VectorND &vector) const
 Divide this vector by another vector and return the result. More...
 
VectorNDoperator+= (T value)
 Add a scalar to each component of this vector and modify the original vector. More...
 
VectorNDoperator-= (T value)
 Subtract a scalar from each component of this vector and modify the original vector. More...
 
VectorNDoperator*= (T value)
 Multiply each component of this vector by a scalar and modify the original vector. More...
 
VectorNDoperator/= (T value)
 Divide each component of this vector by a scalar and modify the original vector. More...
 
VectorNDoperator+= (const VectorND &vector)
 Add a vector to this vector, modifying this vector. More...
 
VectorNDoperator-= (const VectorND &vector)
 Subtract a vector from this vector, modifying this vector. More...
 
VectorNDoperator*= (const VectorND &vector)
 Multiply this vector by another vector and modify this vector. More...
 
VectorNDoperator/= (const VectorND &vector)
 Divide this vector by another vector and modify this vector. More...
 
data::String toString () const
 Convert this 2D vector into a human-readable string representation. More...
 
 operator data::String () const
 Convert this 2D vector into a human-readable string representation. More...
 

Static Public Member Functions

static VectorND polar (T angle)
 Convert the specified polar angle in radians to a unit-length 2D vector. More...
 
static VectorND polar (T angle, T r)
 Convert the specified polar coordinates in radians to an r-length 2D vector. More...
 

Public Attributes

union om::math::VectorND< T, 2 >:: { ... }  
 
v [2]
 An array that contains the vector components. More...
 
r
 The red component of a 2-component color. More...
 
g
 The green component of a 2-component color. More...
 
x
 The X coordinate of a 3D vector. More...
 
y
 The Y coordinate of a 3D vector. More...
 
Swizzle2D< T, 2, 0, 0 > xx
 A permutation of the vector elements that consists of the X element repeated twice. More...
 
Swizzle2D< T, 2, 1, 1 > yy
 A permutation of the vector elements that consists of the Y element repeated twice. More...
 
Swizzle2D< T, 2, 0, 1 > xy
 A permutation of the vector elements that is the same as the original vector. More...
 
Swizzle2D< T, 2, 1, 0 > yx
 A permutation of the vector elements that consists of the X and Y element swapped. More...
 

Static Public Attributes

static const VectorND ZERO
 A constant vector with all elements equal to zero. More...
 

Detailed Description

template<typename T>
class om::math::VectorND< T, 2 >

A class that represents a 2-dimensional point or vector.

Constructor & Destructor Documentation

template<typename T >
om::math::VectorND< T, 2 >::VectorND ( )
inline

Create a new 2D vector with all elements equal to zero.

template<typename T >
om::math::VectorND< T, 2 >::VectorND ( value)
inlineexplicit

Create a new 2D vector with all elements equal to a single value.

template<typename T >
om::math::VectorND< T, 2 >::VectorND ( const T  array[2])
inlineexplicit

Create a new 2D vector from a pointer to a 2 element array.

template<typename T >
om::math::VectorND< T, 2 >::VectorND ( newX,
newY 
)
inline

Create a new 2D vector by specifying it's x and y values.

template<typename T >
template<typename U >
om::math::VectorND< T, 2 >::VectorND ( const VectorND< U, 2 > &  vector)
inline

Create a new 2D vector from an existing vector of a different template type.

template<typename T >
om::math::VectorND< T, 2 >::VectorND ( const VectorND< T, 2 > &  vector)
inline

Create a new 2D vector from an existing vector with the same template type.

This is declared because the auto-generated one was not working with the crazy uniform mess.

Member Function Documentation

template<typename T >
VectorND& om::math::VectorND< T, 2 >::operator= ( const VectorND< T, 2 > &  vector)
inline

Create a new 2D vector from an existing vector with a different template type.

This is declared because the auto-generated one was not working with the crazy uniform mess.

template<typename T >
static VectorND om::math::VectorND< T, 2 >::polar ( angle)
inlinestatic

Convert the specified polar angle in radians to a unit-length 2D vector.

template<typename T >
static VectorND om::math::VectorND< T, 2 >::polar ( angle,
r 
)
inlinestatic

Convert the specified polar coordinates in radians to an r-length 2D vector.

template<typename T >
T om::math::VectorND< T, 2 >::getMagnitude ( ) const
inline

Return the magnitude of this vector (the length).

template<typename T >
T om::math::VectorND< T, 2 >::getMagnitudeSquared ( ) const
inline

Return the square of the magnitude of this vector.

template<typename T >
VectorND om::math::VectorND< T, 2 >::normalize ( ) const
inline

Return a normalized version of this vector.

template<typename T >
VectorND om::math::VectorND< T, 2 >::normalize ( T &  magnitude) const
inline

Return a normalized version of this vector, placing the vector's magnitude in the output parameter.

template<typename T >
VectorND om::math::VectorND< T, 2 >::projectOn ( const VectorND< T, 2 > &  vector) const
inline

Project this vector on another vector and return the projected vector.

template<typename T >
VectorND om::math::VectorND< T, 2 >::projectOnNormalized ( const VectorND< T, 2 > &  vector) const
inline

Project this vector on a normalized vector and return the projected vector.

template<typename T >
T om::math::VectorND< T, 2 >::getDistanceTo ( const VectorND< T, 2 > &  vector) const
inline

Return the distance from this vector to another in 2D Euclidean space.

template<typename T >
T om::math::VectorND< T, 2 >::getDistanceToSquared ( const VectorND< T, 2 > &  vector) const
inline

Return the square of the distance from this vector to another in 2D Euclidean space.

template<typename T >
T* om::math::VectorND< T, 2 >::toArray ( )
inline

Return a pointer to the internal storage of this vector.

template<typename T >
const T* om::math::VectorND< T, 2 >::toArray ( ) const
inline

Return a const pointer to the internal storage of this vector.

template<typename T >
T om::math::VectorND< T, 2 >::getMin ( ) const
inline

Return the minimum coordinate of this vector.

template<typename T >
T om::math::VectorND< T, 2 >::getMax ( ) const
inline

Return the maximum coordinate of this vector.

template<typename T >
T& om::math::VectorND< T, 2 >::get ( Index  index)
inline

Return a reference to the vector coordinate at the specified index.

template<typename T >
const T& om::math::VectorND< T, 2 >::get ( Index  index) const
inline

Return a const reference to the vector coordinate at the specified index.

template<typename T >
T& om::math::VectorND< T, 2 >::operator[] ( Index  index)
inline

Return a reference to the vector coordinate at the specified index.

template<typename T >
const T& om::math::VectorND< T, 2 >::operator[] ( Index  index) const
inline

Return a const reference to the vector coordinate at the specified index.

template<typename T >
void om::math::VectorND< T, 2 >::setAll ( newX,
newY 
)
inline

Set the X and Y coordinates of the vector to the specified values.

template<typename T >
void om::math::VectorND< T, 2 >::set ( Index  index,
newValue 
)
inline

Set the coordinate of this vector at the specified index to a new value.

template<typename T >
Bool om::math::VectorND< T, 2 >::operator== ( const VectorND< T, 2 > &  v) const
inline

Return whether or not this vector is equal to another for all components.

template<typename T >
Bool om::math::VectorND< T, 2 >::operator!= ( const VectorND< T, 2 > &  v) const
inline

Return whether or not this vector is not equal to another for any component.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator- ( ) const
inline

Negate each component of this vector and return the result.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator+ ( ) const
inline

Return copy of the original vector.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator+ ( value) const
inline

Add a scalar to every component of this vector and return the result.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator- ( value) const
inline

Subtract a scalar from every component of this vector and return the result.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator* ( value) const
inline

Multiply every component of this vector by a scalar and return the result.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator/ ( value) const
inline

Divide every component of this vector by a scalar and return the result.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator+ ( const VectorND< T, 2 > &  vector) const
inline

Add this vector to another and return the result and return the result.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator- ( const VectorND< T, 2 > &  vector) const
inline

Subtract a vector from this vector and return the result.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator* ( const VectorND< T, 2 > &  vector) const
inline

Multiply this vector by another vector and return the result.

template<typename T >
VectorND om::math::VectorND< T, 2 >::operator/ ( const VectorND< T, 2 > &  vector) const
inline

Divide this vector by another vector and return the result.

template<typename T >
VectorND& om::math::VectorND< T, 2 >::operator+= ( value)
inline

Add a scalar to each component of this vector and modify the original vector.

template<typename T >
VectorND& om::math::VectorND< T, 2 >::operator-= ( value)
inline

Subtract a scalar from each component of this vector and modify the original vector.

template<typename T >
VectorND& om::math::VectorND< T, 2 >::operator*= ( value)
inline

Multiply each component of this vector by a scalar and modify the original vector.

template<typename T >
VectorND& om::math::VectorND< T, 2 >::operator/= ( value)
inline

Divide each component of this vector by a scalar and modify the original vector.

template<typename T >
VectorND& om::math::VectorND< T, 2 >::operator+= ( const VectorND< T, 2 > &  vector)
inline

Add a vector to this vector, modifying this vector.

template<typename T >
VectorND& om::math::VectorND< T, 2 >::operator-= ( const VectorND< T, 2 > &  vector)
inline

Subtract a vector from this vector, modifying this vector.

template<typename T >
VectorND& om::math::VectorND< T, 2 >::operator*= ( const VectorND< T, 2 > &  vector)
inline

Multiply this vector by another vector and modify this vector.

template<typename T >
VectorND& om::math::VectorND< T, 2 >::operator/= ( const VectorND< T, 2 > &  vector)
inline

Divide this vector by another vector and modify this vector.

template<typename T >
data::String om::math::VectorND< T, 2 >::toString ( ) const
inline

Convert this 2D vector into a human-readable string representation.

template<typename T >
om::math::VectorND< T, 2 >::operator data::String ( ) const
inline

Convert this 2D vector into a human-readable string representation.

Member Data Documentation

template<typename T >
T om::math::VectorND< T, 2 >::v[2]

An array that contains the vector components.

template<typename T >
T om::math::VectorND< T, 2 >::r

The red component of a 2-component color.

template<typename T >
T om::math::VectorND< T, 2 >::g

The green component of a 2-component color.

template<typename T >
T om::math::VectorND< T, 2 >::x

The X coordinate of a 3D vector.

template<typename T >
T om::math::VectorND< T, 2 >::y

The Y coordinate of a 3D vector.

template<typename T >
Swizzle2D<T,2,0,0> om::math::VectorND< T, 2 >::xx

A permutation of the vector elements that consists of the X element repeated twice.

template<typename T >
Swizzle2D<T,2,1,1> om::math::VectorND< T, 2 >::yy

A permutation of the vector elements that consists of the Y element repeated twice.

template<typename T >
Swizzle2D<T,2,0,1> om::math::VectorND< T, 2 >::xy

A permutation of the vector elements that is the same as the original vector.

template<typename T >
Swizzle2D<T,2,1,0> om::math::VectorND< T, 2 >::yx

A permutation of the vector elements that consists of the X and Y element swapped.

union { ... }
template<typename T >
const VectorND< T, 2 > om::math::VectorND< T, 2 >::ZERO
static

A constant vector with all elements equal to zero.


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