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

NUM::Vector3< T > Class Template Reference

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

#include <vector3.h>

Collaboration diagram for NUM::Vector3< T >:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { X = 0, Y = 1, Z = 2 }
enum  _Mul { Mul }
 Dummy enums for constructor selection; mostly internal use. More...

enum  _TrafoDir { TrafoDir }
enum  _TrafoNorm { TrafoNorm }

Public Member Functions

 Vector3 ()
 Default constructor does not initialize the variables.

 Vector3 (T x, T y, T z)
 Construct 3dim vector with specified entries.

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

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

 Vector3 (_Mul, const OMatrix< T > &a, const Vector3< T > &b)
 See vector3.h.

 Vector3 (_TrafoDir, const OMatrix< T > &m, const Vector3< T > &b)
 See vector3.h.

 Vector3 (_TrafoNorm, const Vector3< T > &a, const OMatrix< T > &m)
 See vector3.h.

 ~Vector3 ()
 Destructor (a no-op).

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 3.

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

Vector3 & 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.

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

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

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

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

Vector3 & operator/= (T a)
Vector3 & cross (const Vector3 &a, const Vector3 &b)
 Compute the vector (cross) product of two vectors; store result in *this.

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.

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

bool IsNull (T epsilon) const

Static Public Attributes

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

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

const Vector3< T > UZ
 Unity vectors in x,y and z direction as well as the 0 vector:.

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


Private Attributes

T v [3]
 Internally stores the vector.


Detailed Description

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

3dim 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 144 of file vector3.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 
Z 

Definition at line 149 of file vector3.h.

template<typename T = dbl>
enum NUM::Vector3::_Mul
 

Dummy enums for constructor selection; mostly internal use.

Enumeration values:
Mul 

Definition at line 155 of file vector3.h.

template<typename T = dbl>
enum NUM::Vector3::_TrafoDir
 

Enumeration values:
TrafoDir 

Definition at line 156 of file vector3.h.

template<typename T = dbl>
enum NUM::Vector3::_TrafoNorm
 

Enumeration values:
TrafoNorm 

Definition at line 157 of file vector3.h.


Constructor & Destructor Documentation

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

Default constructor does not initialize the variables.

Todo:
Implement faster version with vector support (SSE,...); see gcc-info: vector_size, V4SI, __builtin_ia32_addsubpd

Definition at line 167 of file vector3.h.

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

Construct 3dim vector with specified entries.

Definition at line 169 of file vector3.h.

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

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

Copy-constructor as usual.

Definition at line 172 of file vector3.h.

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

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

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

Definition at line 175 of file vector3.h.

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

template<typename T>
NUM::Vector3< T >::Vector3 (  _Mul  ,
const OMatrix< T > &  a,
const Vector3< T > &  b
)  [inline]
 

See vector3.h.

Definition at line 307 of file omatrix.h.

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

template<typename T>
NUM::Vector3< T >::Vector3 (  _TrafoDir  ,
const OMatrix< T > &  m,
const Vector3< T > &  b
)  [inline]
 

See vector3.h.

Definition at line 315 of file omatrix.h.

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

template<typename T>
NUM::Vector3< T >::Vector3 (  _TrafoNorm  ,
const Vector3< T > &  a,
const OMatrix< T > &  m
)  [inline]
 

See vector3.h.

Definition at line 323 of file omatrix.h.

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

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

Destructor (a no-op).

Definition at line 185 of file vector3.h.


Member Function Documentation

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

Add a*f to *this.

Definition at line 236 of file vector3.h.

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

template<typename T = dbl>
Vector3& NUM::Vector3< T >::cross (  const Vector3< T > &  a,
const Vector3< T > &  b
)  [inline]
 

Compute the vector (cross) product of two vectors; store result in *this.

Definition at line 248 of file vector3.h.

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

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

Get dimension of vector. This is always 3.

Definition at line 197 of file vector3.h.

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

Compare vector against 0 with specified epsilon value:

See also:
equal() to compare two vectors.

Definition at line 266 of file vector3.h.

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

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

Get the length of the vector (Euclidic norm).

Definition at line 212 of file vector3.h.

References NUM::Vector3< T >::len2().

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

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

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

Definition at line 209 of file vector3.h.

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

Referenced by NUM::angle(), and NUM::Vector3< T >::len().

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

Get the largest element of the vector.

Definition at line 220 of file vector3.h.

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

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

Get the smallest element of the vector.

Definition at line 224 of file vector3.h.

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

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

Change the sign of every element:.

Definition at line 261 of file vector3.h.

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

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

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

Definition at line 216 of file vector3.h.

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

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

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

Definition at line 257 of file vector3.h.

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

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

Bring the vector to length 1; returns previous length.

Definition at line 254 of file vector3.h.

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

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

Multiply vector with sclar value:.

Definition at line 240 of file vector3.h.

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

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

Definition at line 194 of file vector3.h.

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

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

Get internally used array of elements. Use with care.

Definition at line 193 of file vector3.h.

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

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

Add a vector to this one:.

Definition at line 229 of file vector3.h.

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

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

Subtract a vector from this one:.

Definition at line 232 of file vector3.h.

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

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

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

Definition at line 244 of file vector3.h.

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

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

Assignment operator: Copy passed vector.

Definition at line 201 of file vector3.h.

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

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

Definition at line 190 of file vector3.h.

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

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

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

Definition at line 189 of file vector3.h.

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

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

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

Definition at line 205 of file vector3.h.

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


Member Data Documentation

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

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

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

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

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

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

template<typename T = dbl>
const Vector3< flt > NUM::Vector3<>::UZ [static]
 

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

template<typename T = dbl>
T NUM::Vector3< T >::v[3] [private]
 

Internally stores the vector.

Definition at line 161 of file vector3.h.

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


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