Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

NUM::Vector2< T > Class Template Reference

2dim vector class template for types flt and dbl. More...

#include <vector2.h>

Collaboration diagram for NUM::Vector2< T >:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { X = 0, Y = 1 }

Public Member Functions

 Vector2 ()
 Default constructor does not initialize the variables.

 Vector2 (T x, T y)
 Construct 2dim vector with specified entries.

 Vector2 (const Vector2 &a)
 Copy-constructor as usual.

 Vector2 (const T *a)
 Construct a vector using passed elements a[0..1] (from array).

 ~Vector2 ()
T & operator[] (int i)
const T & operator[] (int i) const
 operator T * ()
 Get internally used array of elements. Use with care.

 operator const T * () const
int dim () const
 Get dimension of vector. This is always 2.

Vector2 & operator= (const Vector2 &a)
 Assignment operator: Copy passed vector.

Vector2 & promote (T a)
 "Promote" a value, i.e. set all elements of the vector to a.

T len2 () const
 Get the squared length (Euclidic norm) of the vector.

T len () const
 Get the length of the vector (Euclidic norm).

T norm1 () const
 Get the 1-norm of the vector, i.e. |x|+|y|+|z|,.

T max () const
 Get the largest element of the vector.

T min () const
 Get the smallest element of the vector.

Vector2 & operator+= (const Vector2 &a)
 Add a vector to this one:.

Vector2 & operator-= (const Vector2 &a)
 Subtract a vector from this one:.

Vector2 & AddScaled (const Vector2 &a, T f)
 Add a*f to *this.

Vector2 & operator *= (T a)
 Multiply vector with sclar value:.

Vector2 & operator/= (T a)
T normalize ()
 Bring the vector to length 1; returns previous length.

T normalize (T wl)
 Bring the vector to specified length l; returns previous length.

Vector2 & neg ()
 Change the sign of every element:.

bool IsNull (T epsilon) const

Static Public Attributes

const Vector2< T > UX
 Unity vectors in x and y direction as well as the 0 vector:.

const Vector2< T > UY
 Unity vectors in x and y direction as well as the 0 vector:.

const Vector2< T > Null
 Unity vectors in x and y direction as well as the 0 vector:.


Private Attributes

T v [2]
 Internally stores the vector.


Detailed Description

template<typename T = dbl>
class NUM::Vector2< T >

2dim vector class template for types flt and dbl.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
See also:
File vector3.h for more information about speed.
This class is meant to be quite fast and hence does applies some optimizations like:

Definition at line 49 of file vector2.h.


Member Enumeration Documentation

template<typename T = dbl>
anonymous enum
 

These are just array indices which may come handy if one wants to make code more readable.

Enumeration values:
X 
Y 

Definition at line 54 of file vector2.h.


Constructor & Destructor Documentation

template<typename T = dbl>
NUM::Vector2< T >::Vector2 (   )  [inline]
 

Default constructor does not initialize the variables.

Definition at line 65 of file vector2.h.

template<typename T = dbl>
NUM::Vector2< T >::Vector2 (  T  x,
T  y
)  [inline]
 

Construct 2dim vector with specified entries.

Definition at line 67 of file vector2.h.

References NUM::Vector2< T >::v, and NUM::y.

template<typename T = dbl>
NUM::Vector2< T >::Vector2 (  const Vector2< T > &  a  )  [inline]
 

Copy-constructor as usual.

Definition at line 70 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
NUM::Vector2< T >::Vector2 (  const T *  a  )  [inline]
 

Construct a vector using passed elements a[0..1] (from array).

Definition at line 73 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
NUM::Vector2< T >::~Vector2 (   )  [inline]
 

Definition at line 75 of file vector2.h.


Member Function Documentation

template<typename T = dbl>
Vector2& NUM::Vector2< T >::AddScaled (  const Vector2< T > &  a,
T  f
)  [inline]
 

Add a*f to *this.

Definition at line 124 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
int NUM::Vector2< T >::dim (   )  const [inline]
 

Get dimension of vector. This is always 2.

Definition at line 87 of file vector2.h.

template<typename T = dbl>
bool NUM::Vector2< T >::IsNull (  T  epsilon  )  const [inline]
 

Compare vector against 0 with specified epsilon value:

See also:
equal() to compare two vectors.

Definition at line 148 of file vector2.h.

References NUM::fabs(), and NUM::Vector2< T >::v.

template<typename T = dbl>
T NUM::Vector2< T >::len (   )  const [inline]
 

Get the length of the vector (Euclidic norm).

Definition at line 102 of file vector2.h.

References NUM::Vector2< T >::v.

Referenced by NUM::normalize(), and NUM::Vector2< T >::normalize().

template<typename T = dbl>
T NUM::Vector2< T >::len2 (   )  const [inline]
 

Get the squared length (Euclidic norm) of the vector.

Definition at line 99 of file vector2.h.

References NUM::Vector2< T >::v.

Referenced by NUM::angle().

template<typename T = dbl>
T NUM::Vector2< T >::max (   )  const [inline]
 

Get the largest element of the vector.

Definition at line 110 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
T NUM::Vector2< T >::min (   )  const [inline]
 

Get the smallest element of the vector.

Definition at line 113 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
Vector2& NUM::Vector2< T >::neg (   )  [inline]
 

Change the sign of every element:.

Definition at line 143 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
T NUM::Vector2< T >::norm1 (   )  const [inline]
 

Get the 1-norm of the vector, i.e. |x|+|y|+|z|,.

Definition at line 106 of file vector2.h.

References NUM::fabs(), and NUM::Vector2< T >::v.

template<typename T = dbl>
T NUM::Vector2< T >::normalize (  T  wl  )  [inline]
 

Bring the vector to specified length l; returns previous length.

Definition at line 139 of file vector2.h.

References NUM::Vector2< T >::len(), and NUM::Vector2< T >::v.

template<typename T = dbl>
T NUM::Vector2< T >::normalize (   )  [inline]
 

Bring the vector to length 1; returns previous length.

Definition at line 136 of file vector2.h.

References NUM::Vector2< T >::len(), and NUM::Vector2< T >::v.

template<typename T = dbl>
Vector2& NUM::Vector2< T >::operator *= (  T  a  )  [inline]
 

Multiply vector with sclar value:.

Definition at line 128 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
NUM::Vector2< T >::operator const T * (   )  const [inline]
 

Definition at line 84 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
NUM::Vector2< T >::operator T * (   )  [inline]
 

Get internally used array of elements. Use with care.

Definition at line 83 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
Vector2& NUM::Vector2< T >::operator+= (  const Vector2< T > &  a  )  [inline]
 

Add a vector to this one:.

Definition at line 117 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
Vector2& NUM::Vector2< T >::operator-= (  const Vector2< T > &  a  )  [inline]
 

Subtract a vector from this one:.

Definition at line 120 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
Vector2& NUM::Vector2< T >::operator/= (  T  a  )  [inline]
 

Divide vector by scalar value. For speed reasons, you should better multiply with 1/a.

Definition at line 132 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
Vector2& NUM::Vector2< T >::operator= (  const Vector2< T > &  a  )  [inline]
 

Assignment operator: Copy passed vector.

Definition at line 91 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
const T& NUM::Vector2< T >::operator[] (  int  i  )  const [inline]
 

Definition at line 80 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
T& NUM::Vector2< T >::operator[] (  int  i  )  [inline]
 

Access to the vector members. Indices 0,1 or X,Y. No range check.

Definition at line 79 of file vector2.h.

References NUM::Vector2< T >::v.

template<typename T = dbl>
Vector2& NUM::Vector2< T >::promote (  T  a  )  [inline]
 

"Promote" a value, i.e. set all elements of the vector to a.

Definition at line 95 of file vector2.h.

References NUM::Vector2< T >::v.


Member Data Documentation

template<typename T = dbl>
const Vector2< flt > NUM::Vector2<>::Null [static]
 

Unity vectors in x and y direction as well as the 0 vector:.

template<typename T = dbl>
const Vector2< flt > NUM::Vector2<>::UX [static]
 

Unity vectors in x and y direction as well as the 0 vector:.

template<typename T = dbl>
const Vector2< flt > NUM::Vector2<>::UY [static]
 

Unity vectors in x and y direction as well as the 0 vector:.

template<typename T = dbl>
T NUM::Vector2< T >::v[2] [private]
 

Internally stores the vector.

Definition at line 61 of file vector2.h.

Referenced by NUM::Vector2< T >::AddScaled(), NUM::Vector2< T >::IsNull(), NUM::Vector2< T >::len(), NUM::Vector2< T >::len2(), NUM::Vector2< T >::max(), NUM::Vector2< T >::min(), NUM::Vector2< T >::neg(), NUM::Vector2< T >::norm1(), NUM::Vector2< T >::normalize(), NUM::Vector2< T >::operator *=(), NUM::Vector2< T >::operator const T *(), NUM::Vector2< T >::operator T *(), NUM::Vector2< T >::operator+=(), NUM::Vector2< T >::operator-=(), NUM::Vector2< T >::operator/=(), NUM::Vector2< T >::operator=(), NUM::Vector2< T >::operator[](), NUM::Vector2< T >::promote(), and NUM::Vector2< T >::Vector2().


The documentation for this class was generated from the following files:
Generated on Sat Feb 19 22:36:02 2005 for Ray by doxygen 1.3.5