vector3d Class Reference

Basic 3D-vector class with fundamental vector operations. More...

#include <vector3d.h>

List of all members.

Public Member Functions

 vector3d ()
 Default constructor constructs a zero- vector.
 vector3d (double X, double Y, double Z)
 Constructor with coordinates.
double operator[] (int i) const
 Return coordinates via index (0,1,2).
double & operator[] (int i)
 Acces vector coordinates via index mode (0,1,2).
 operator const double * () const
 Returning the memory address of the vector.
vector3doperator= (const vector3d &v)
 = operator.
vector3doperator/= (double k)
 Divides the vector by k.
double squaredNorm () const
 Calculates the squared norm of the vector.
double norm () const
 Calculates the norm of the vector.
vector3d project (const vector3d &a)
 Reurns the projection of the vector on vector a.
double normalize ()
 Normalizes the vector.

Static Public Member Functions

static double vecAngle (const vector3d &a, const vector3d &b)
 angle (degrees) between vector a and vector b

static double vecRadAngle (const vector3d &a, const vector3d &b)
 angle (radians) between vector a and vector b


Public Attributes

union {
   struct {
      double   x
      double   y
      double   z
   } 
   double   c [3]
}; 

Friends

vector3d operator- (const vector3d &a, const vector3d &b)
 Subtracts vector b from vector a.
double operator* (const vector3d &a, const vector3d &b)
 Dot product of vector a and vector b.
vector3d operator* (const vector3d &a, float k)
 Returns the product of the vector a with a scalar k.
vector3d operator* (float k, const vector3d &a)
 Returns the product of the vector a with a scalar k.
vector3d operator+ (const vector3d &a, const vector3d &b)
 Sum of vector a and vector b.
vector3d operator/ (const vector3d &a, double k)
 Division of vector a by k.
bool operator== (const vector3d &a, const vector3d &b)
 Checks wether two vectors are equal.
vector3d cross (const vector3d &a, const vector3d &b)
 crossproduct of vector a and vector b


Detailed Description

Basic 3D-vector class with fundamental vector operations.


Constructor & Destructor Documentation

vector3d::vector3d (  )  [inline]

Default constructor constructs a zero- vector.


Member Function Documentation

double& vector3d::operator[] ( int  i  )  [inline]

Acces vector coordinates via index mode (0,1,2).

(lvalue)

vector3d::operator const double * (  )  const [inline]

Returning the memory address of the vector.

Useful for passing the vector to openGL functions

vector3d& vector3d::operator= ( const vector3d v  )  [inline]

= operator.

vector3d& vector3d::operator/= ( double  k  )  [inline]

Divides the vector by k.

*

vector3d& operator/=(float k) { x /=k; y /=k; z /=k; return *this; }

Divides the vector by k.

double vector3d::squaredNorm (  )  const [inline]

Calculates the squared norm of the vector.

$x^2+y^2+z^2$

double vector3d::norm (  )  const [inline]

Calculates the norm of the vector.

$\sqrt{x^2+y^2+z^2}$

vector3d vector3d::project ( const vector3d a  )  [inline]

Reurns the projection of the vector on vector a.

double vector3d::normalize (  )  [inline]

Normalizes the vector.

If the vector is a null vector (norm() < vector3d_ZERO) the vector is not modified and function returns -1.
Otherwise the former norm of the vector is returned.

static double vector3d::vecAngle ( const vector3d a,
const vector3d b 
) [inline, static]

angle (degrees) between vector a and vector b

$\alpha=\arccos(\frac{\overrightarrow{ a}*\overrightarrow{ b}}{|\overrightarrow{ a}|*|\overrightarrow{ b}|})$

static double vector3d::vecRadAngle ( const vector3d a,
const vector3d b 
) [inline, static]

angle (radians) between vector a and vector b

$\alpha=\arccos(\frac{\overrightarrow{ a}*\overrightarrow{ b}}{|\overrightarrow{ a}|*|\overrightarrow{ b}|})$


Friends And Related Function Documentation

double operator* ( const vector3d a,
const vector3d b 
) [friend]

Dot product of vector a and vector b.

vector3d operator* ( const vector3d a,
float  k 
) [friend]

Returns the product of the vector a with a scalar k.

vector3d operator* ( float  k,
const vector3d a 
) [friend]

Returns the product of the vector a with a scalar k.

vector3d operator/ ( const vector3d a,
double  k 
) [friend]

Division of vector a by k.

friend vector3d operator/(const vector3d &a, float k) { return vector3d(a.x/k, a.y/k, a.z/k); }

Division of vector a by k.

bool operator== ( const vector3d a,
const vector3d b 
) [friend]

Checks wether two vectors are equal.

The two vectors are equal, If the norm of the difference of the two vectors is smaller than vector3d_ZERO

vector3d cross ( const vector3d a,
const vector3d b 
) [friend]

crossproduct of vector a and vector b


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

Generated on Fri Apr 25 12:16:23 2008 for vector3d by  doxygen 1.5.5