VVector Class Reference

Basic 3D vector arithmetic functionality. More...

#include <VVector.hh>

List of all members.

Public Member Functions

 VVector ()
 Creates an uninitialized vector.
 VVector (bool zero_)
 Creates an initialized (to zero) or uninitialized vector.
 VVector (double val)
 Creates an initialized vector with the same value for x, y and z.
 VVector (const f3 fv)
 Create and initialize a vector from array of floats.
 VVector (const d3 dv)
 Create and initialize a vector from array of doubles.
 VVector (double x, double y, double z)
 Create and initialize a vector from 3 doubles.
const double operator[] (int i) const
 Read-only access an element in the vector.
double & operator[] (int i)
 Write access to an element in the vector.
double & x ()
 Get element 0 of the vector.
double & y ()
 Get element 1 of the vector.
double & z ()
 Get element 2 of the vector.
const double x () const
 Get element 0 of the vector.
const double y () const
 Get element 1 of the vector.
const double z () const
 Get element 2 of the vector.
 operator const double * () const
 Implicit conversion to array of doubles.
const VVector operator+ (const VVector &rhs) const
 Add 2 vectors.
const VVector operator- (const VVector &rhs) const
 Subtract a vector from this vector.
double operator * (const VVector &rhs) const
 Dot product between vectors.
const VVector operator * (double scalar) const
 Multiply each element with a scalar.
const VVector operator/ (double scalar) const
 Divide each element with a scalar.
VVectoroperator+= (const VVector &rhs)
 Add a vector to this vector.
VVectoroperator-= (const VVector &rhs)
 Subtract a vector from this vector.
VVectoroperator *= (double scalar)
 Mutliply this vector with a scalar.
VVectoroperator/= (double scalar)
 Divide this vector with a scalar.
const VVector crossproduct (const VVector &with) const
 Cross product of this vector and with.
const VVector projection (const VVector &onto) const
 Projection, vectors does not have to be of unit length.
const VVector perpendicular (const VVector &to) const
 Perpendicular part, vectors does not have to be of unit length.
const VVector rotX (double angleRad) const
 Rotate angleRad rad around X axis.
const VVector rotY (double angleRad) const
 Rotate angleRad rad around Y axis.
const VVector rotZ (double angleRad) const
 Rotate angleRad rad around Z axis.
const VVector rotN (const VVector &n, double angleRad) const
 Rotate angleRad rad around arbitrary axis.
const double length () const
 Compute the length of the vector.
void normalize ()
 Normalize the vector (i.e. make it length 1 and same direction).
void set (double x, double y, double z)
 Set the value of the vector.
void zero ()

Static Private Member Functions

static double & getDummy ()

Private Attributes

d3 m_vval

Friends

std::ostream & operator<< (std::ostream &o, const VVector &v)
 Print vector in format [x, y, z].


Detailed Description

Basic 3D vector arithmetic functionality.


Constructor & Destructor Documentation

VVector::VVector (  )  [inline]

Creates an uninitialized vector.

VVector::VVector ( bool  zero_  )  [inline, explicit]

Creates an initialized (to zero) or uninitialized vector.

Parameters:
zero_ if true the vector is initilized to [0,0,0]

VVector::VVector ( double  val  )  [inline, explicit]

Creates an initialized vector with the same value for x, y and z.

Parameters:
val The value to initialize the vector with v = (val, val, val)
See also:
set

VVector(bool zero_)

VVector(double x, double y, double z)

VVector::VVector ( const f3  fv  )  [inline, explicit]

Create and initialize a vector from array of floats.

Parameters:
fv pointer to vector of 3 floats

VVector::VVector ( const d3  dv  )  [inline, explicit]

Create and initialize a vector from array of doubles.

Parameters:
dv pointer to vector of 3 doubles

VVector::VVector ( double  x,
double  y,
double  z 
) [inline]

Create and initialize a vector from 3 doubles.

Parameters:
x value of element 0
y value of element 1
z value of element 2


Member Function Documentation

const VVector VVector::crossproduct ( const VVector with  )  const [inline]

Cross product of this vector and with.

static double& VVector::getDummy (  )  [inline, static, private]

const double VVector::length (  )  const [inline]

Compute the length of the vector.

void VVector::normalize (  )  [inline]

Normalize the vector (i.e. make it length 1 and same direction).

const VVector VVector::operator * ( double  scalar  )  const [inline]

Multiply each element with a scalar.

double VVector::operator * ( const VVector rhs  )  const [inline]

Dot product between vectors.

Parameters:
rhs The vector to multiply with this vector
Returns:
A vector that has the value of this vector * rhs

VVector& VVector::operator *= ( double  scalar  )  [inline]

Mutliply this vector with a scalar.

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

Implicit conversion to array of doubles.

const VVector VVector::operator+ ( const VVector rhs  )  const [inline]

Add 2 vectors.

VVector& VVector::operator+= ( const VVector rhs  )  [inline]

Add a vector to this vector.

const VVector VVector::operator- ( const VVector rhs  )  const [inline]

Subtract a vector from this vector.

Parameters:
rhs The vector to subtract from this vector
Returns:
A vector that has the value of this vector - rhs

VVector& VVector::operator-= ( const VVector rhs  )  [inline]

Subtract a vector from this vector.

const VVector VVector::operator/ ( double  scalar  )  const [inline]

Divide each element with a scalar.

VVector& VVector::operator/= ( double  scalar  )  [inline]

Divide this vector with a scalar.

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

Write access to an element in the vector.

If i < 0 or i > 3 an undefined dummy value is returned (and a warning is printed on stderr if NDEBUG was not defined at compile time).

const double VVector::operator[] ( int  i  )  const [inline]

Read-only access an element in the vector.

If i < 0 or i > 3 an undefined dummy value is returned (and a warning is printed on stderr if NDEBUG was not defined at compile time).

const VVector VVector::perpendicular ( const VVector to  )  const [inline]

Perpendicular part, vectors does not have to be of unit length.

Parameters:
to The vector to take the perpendicular part to

const VVector VVector::projection ( const VVector onto  )  const [inline]

Projection, vectors does not have to be of unit length.

Parameters:
onto The vector to project this vector on

const VVector VVector::rotN ( const VVector n,
double  angleRad 
) const [inline]

Rotate angleRad rad around arbitrary axis.

Parameters:
n The vector to rotate around
angleRad The number of radians to rotate
Returns:
A vector rotate angleRad around n

const VVector VVector::rotX ( double  angleRad  )  const [inline]

Rotate angleRad rad around X axis.

Parameters:
angleRad The number of radians to rotate
Returns:
A vector rotate angleRad around X-axis

const VVector VVector::rotY ( double  angleRad  )  const [inline]

Rotate angleRad rad around Y axis.

Parameters:
angleRad The number of radians to rotate
Returns:
A vector rotate angleRad around Y-axis

const VVector VVector::rotZ ( double  angleRad  )  const [inline]

Rotate angleRad rad around Z axis.

Parameters:
angleRad The number of radians to rotate
Returns:
A vector rotate angleRad around Z-axis

void VVector::set ( double  x,
double  y,
double  z 
) [inline]

Set the value of the vector.

const double VVector::x (  )  const [inline]

Get element 0 of the vector.

double& VVector::x (  )  [inline]

Get element 0 of the vector.

const double VVector::y (  )  const [inline]

Get element 1 of the vector.

double& VVector::y (  )  [inline]

Get element 1 of the vector.

const double VVector::z (  )  const [inline]

Get element 2 of the vector.

double& VVector::z (  )  [inline]

Get element 2 of the vector.

void VVector::zero (  )  [inline]


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const VVector v 
) [friend]

Print vector in format [x, y, z].


Member Data Documentation

d3 VVector::m_vval [private]


The documentation for this class was generated from the following file:
Generated on Sun Mar 11 15:33:27 2007 for MetalWarriors by  doxygen 1.4.7