NdVector Class Template Reference

Inheritance diagram for NdVector:

Array List of all members.

Detailed Description

template<class T>
class NdVector< T >

Author:
Bill Smart

Version:
1.0
Date:
June 2005

Definition at line 202 of file Geometry.H.

Public Member Functions

 NdVector (const int dimension)
 Alocate a vector of the given dimension.
 NdVector (const int dimension, const T &value)
 Allocate a vector of the given dimension, and set all of its elements to the given value.
 NdVector (const NdPoint< T > &p1, const NdPoint< T > &p2)
 Allocate a vector from point p1 to point p2.
 NdVector (const NdVector< T > &vector)
 ~NdVector ()
bool operator== (const NdVector< T > &vec) const
Dimension
int n () const
 
Returns:
The dimension of the vector. */

Operations
NdVector< T > operator * (const double scalar) const
 Multiply the length of the vector by a scalar.
NdVector< T > operator/ (const double scalar) const
 Divide the length of the vector by a scalar.
NdVector< T > & operator *= (const double scalar)
 Multiply the length of the vector by a scalar.
NdVector< T > & operator/= (const double scalar)
 Divide the length of the vector by a scalar.
NdVector< T > operator+ (const NdVector< T > &vector) const
 Add two vectors together.
NdVector< T > operator- (const NdVector< T > &vector) const
 Subtract one vector from another.
NdVector< T > & operator+= (const NdVector< T > &vector)
 Add a vector to the current instance.
NdVector< T > & operator-= (const NdVector< T > &vector)
 Subtract a vector from the current instance.
NdVector< T > operator- () const
 Reverse the direction of a vector.
double operator * (const NdVector< T > &vector)
 Calculate the inner (dot) product of two vectors.
double length () const
 
Returns:
The length of the vector.

void normalize (const double new_length=1.0)
 Set the length of the vector to the specified value.


Constructor & Destructor Documentation

NdVector ( const int  dimension  )  [inline, explicit]

Alocate a vector of the given dimension.

Parameters:
[in] dimension The dimension of the vector.

Definition at line 206 of file Geometry.H.

NdVector ( const int  dimension,
const T &  value 
) [inline]

Allocate a vector of the given dimension, and set all of its elements to the given value.

Parameters:
[in] dimension The dimension of the vector.
[in] value The value to set the elements to.

Definition at line 210 of file Geometry.H.

NdVector ( const NdPoint< T > &  p1,
const NdPoint< T > &  p2 
) [inline]

Allocate a vector from point p1 to point p2.

Parameters:
[in] p1 The starting point.
[in] p2 The ending point.

Definition at line 214 of file Geometry.H.

References p1, and p2.

NdVector ( const NdVector< T > &  vector  )  [inline]

Definition at line 216 of file Geometry.H.

~NdVector (  )  [inline]

Definition at line 217 of file Geometry.H.


Member Function Documentation

bool operator== ( const NdVector< T > &  vec  )  const [inline]

Check if two vectors are the same.

Parameters:
[in] point The point to check against.

Definition at line 223 of file Geometry.H.

References n().

int n (  )  const [inline]

Returns:
The dimension of the vector. */

Definition at line 231 of file Geometry.H.

References size.

Referenced by length(), operator *(), operator+(), NdPoint::operator+(), operator+=(), NdPoint::operator+=(), operator-(), NdPoint::operator-(), operator-=(), NdPoint::operator-=(), operator==(), and operator>>().

NdVector<T> operator * ( const double  scalar  )  const [inline]

Multiply the length of the vector by a scalar.

Parameters:
[in] scalar The number to multiply the vector by.
Returns:
A scaled vector.

Definition at line 240 of file Geometry.H.

NdVector<T> operator/ ( const double  scalar  )  const [inline]

Divide the length of the vector by a scalar.

Parameters:
[in] scalar The number to divide the vector by.
Returns:
A scaled vector.

Definition at line 246 of file Geometry.H.

NdVector<T>& operator *= ( const double  scalar  )  [inline]

Multiply the length of the vector by a scalar.

Parameters:
[in] scalar The number to multiply the vector by.
Returns:
The modified vector.

Definition at line 253 of file Geometry.H.

NdVector<T>& operator/= ( const double  scalar  )  [inline]

Divide the length of the vector by a scalar.

Parameters:
[in] scalar The number to divide the vector by.
Returns:
The modified vector.

Definition at line 259 of file Geometry.H.

Referenced by normalize().

NdVector<T> operator+ ( const NdVector< T > &  vector  )  const [inline]

Add two vectors together.

Parameters:
[in] vector The vector to add.
Returns:
The sum of the vectors.

Definition at line 266 of file Geometry.H.

References n().

NdVector<T> operator- ( const NdVector< T > &  vector  )  const [inline]

Subtract one vector from another.

Parameters:
[in] vector The vector to subtract.
Returns:
The difference of the vectors.

Definition at line 272 of file Geometry.H.

References n().

NdVector<T>& operator+= ( const NdVector< T > &  vector  )  [inline]

Add a vector to the current instance.

Parameters:
[in] vector The vector to add.
Returns:
The modified vector.

Definition at line 279 of file Geometry.H.

References n().

NdVector<T>& operator-= ( const NdVector< T > &  vector  )  [inline]

Subtract a vector from the current instance.

Parameters:
[in] vector The vector to subtract.
Returns:
The modified vector.

Definition at line 286 of file Geometry.H.

References n().

NdVector<T> operator- (  )  const [inline]

Reverse the direction of a vector.

Returns:
A vector pointing in the opposite direction.

Definition at line 293 of file Geometry.H.

References n().

double operator * ( const NdVector< T > &  vector  )  [inline]

Calculate the inner (dot) product of two vectors.

Parameters:
[in] vector The second vector.
Returns:
The inner product.

Definition at line 301 of file Geometry.H.

References n().

double length (  )  const [inline]

Returns:
The length of the vector.

Definition at line 308 of file Geometry.H.

References n().

Referenced by normalize().

void normalize ( const double  new_length = 1.0  )  [inline]

Set the length of the vector to the specified value.

Parameters:
[in] new_length The new length of the vector.

Definition at line 318 of file Geometry.H.

References length(), and operator/=().


The documentation for this class was generated from the following file:
Generated on Thu Feb 1 15:31:55 2007 for WURDE by  doxygen 1.5.1