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

vuVector Class Reference

A class for representing 3d vectors. More...

#include <vuVector.h>

Collaboration diagram for vuVector:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 vuVector ()
 Default constructor making a zero vector.
 vuVector (const vuVector &v)
 Copy constructor.
 vuVector (float v1, float v2, float v3)
 Constructor initializing to a 3d vector in homogenous space.
 vuVector (float v1, float v2, float v3, float v4)
 Constructor initializing to a homogenous 3d vector.
 vuVector (float v)
 Constructor initializing the x,y,z coordinates to v.
 vuVector (const float *v)
 Constructor initializing the vector from an array of floats.
 ~vuVector ()
 The destructor.
vuVectoroperator= (const vuVector &v)
 The assignment operator.
vuVectoroperator= (float v)
 Assigns the value v to the x,y,z elements of the vector.
vuVectoroperator= (const float *v)
 Assigns a 3d float array to the vector.
float norm (void) const
 Computes the 2-norm on the vector (lenght operator).
float norm2 (void) const
 Computes squared 2-norm (scalar product with itself).
vuVectormakeUnit (void)
 Normalizes the vector to a length of 1.
vuVectornormalize (void)
 Normalizes the vector in homogenous space.
vuVector inv (void) const
 Returns the entry-wise inverse of the vector.
vuVectorinvEq (void)
 Inverts the vector entry-wise.
vuVector mul (const vuVector &rhs) const
 Returns the entry-wise product of the vector with another vector.
vuVectormulEq (const vuVector &rhs)
 Multiplies the vector, entry-wise, by another vector.
vuVector div (const vuVector &rhs) const
 Returns the entry-wise division of the vector by another vector.
vuVectordivEq (const vuVector &rhs)
 Divides the vector, entry-wise, by another vector.
floatoperator[] (dword index)
 The access operator.
const floatoperator[] (dword index) const
 The const access operator.
floatgetData (void)
 Returns the data pointer.
float const * getData (void) const
 const version of getData()
float dot (const vuVector &v) const
 Returns the dot product of the vector with another vector.
vuVector cross (const vuVector &v) const
 Returns the cross product of the vector with another vector.
vuVector operator+ (const vuVector &v) const
 Returns the sum of the vector with another vector.
vuVector operator- (const vuVector &v) const
 Returns the difference of the vector from another vector.
vuVector operator * (const vuMatrix &m) const
 Returns the product of the vector and a matrix.
vuMatrix operator * (const vuVector &v) const
 Returns the product of the vector with another vector.
vuVector operator * (float s) const
 Returns the product of the vector with a scalar.
vuVector operator/ (float s) const
 Returns the fraction of the vector with a scalar.
vuVectoroperator+= (const vuVector &v)
 Adds a vector to this vector.
vuVectoroperator-= (const vuVector &v)
 Subtracts a vector from this vector.
vuVectoroperator *= (const vuMatrix &m)
 Multiplies the vector by a matrix.
vuVectoroperator *= (float s)
 Multiplies the vector by a scalar.
bool operator== (const vuVector &v) const
 An equality operator, comparing only the x,y,z coordinates.
bool operator!= (const vuVector &v) const
 An inequality operator, comparing only the x,y,z coordinates.
int getDominantAxis () const
 Returns index of component with highest absolute.
void print ()
 prints values to the stdout
int load (char *load_from)
 this will load the values referenced by load_from
void save (char *save_to)
 this will set read_to to be the four ascii values in x, y, z, w
vuString getString ()
 returns a c-string representation without '
'

Private Attributes

float val [4]
 The coordinates of the vector stored as a floating point array.

Friends

class vuMatrix
float dot (const vuVector &v1, const vuVector &v2)
 Returns the dot product of two vectors.
vuVector cross (const vuVector &v1, const vuVector &v2)
 Returns the cross product of two vectors.
const vuVector operator * (float s, const vuVector &v)
 Returns the product of a scalar with a vector.
ostream & operator<< (ostream &out, const vuVector &v)
 writes the foure elements to a stream; separated by whitespaces
istream & operator>> (istream &in, vuVector &v)
 reads a vector from a stream

Detailed Description

A class for representing 3d vectors.

The vuVector class is a 3D homogeneous vector that works in conjunction with the vuMatrix class (a 4x4 matrix). The elements of the vuVector are all single precision floating- point numbers.

Definition at line 28 of file vuVector.h.


Constructor & Destructor Documentation

vuVector::vuVector  ) 
 

Default constructor making a zero vector.

Definition at line 7 of file vuVector.cpp.

References val.

vuVector::vuVector const vuVector v  ) 
 

Copy constructor.

Definition at line 14 of file vuVector.cpp.

References val.

vuVector::vuVector float  v1,
float  v2,
float  v3
 

Constructor initializing to a 3d vector in homogenous space.

Definition at line 23 of file vuVector.cpp.

References val.

vuVector::vuVector float  v1,
float  v2,
float  v3,
float  v4
 

Constructor initializing to a homogenous 3d vector.

Definition at line 32 of file vuVector.cpp.

References val.

vuVector::vuVector float  v  ) 
 

Constructor initializing the x,y,z coordinates to v.

Definition at line 41 of file vuVector.cpp.

References val.

vuVector::vuVector const float v  ) 
 

Constructor initializing the vector from an array of floats.

Parameters:
v An array of 3 floating point values corresponding to x,y,z.

Definition at line 48 of file vuVector.cpp.

References val.

vuVector::~vuVector  ) 
 

The destructor.

Definition at line 57 of file vuVector.cpp.


Member Function Documentation

vuVector vuVector::cross const vuVector v  )  const
 

Returns the cross product of the vector with another vector.

Definition at line 241 of file vuVector.cpp.

References val.

vuVector vuVector::div const vuVector rhs  )  const
 

Returns the entry-wise division of the vector by another vector.

Definition at line 198 of file vuVector.cpp.

References val.

vuVector & vuVector::divEq const vuVector rhs  ) 
 

Divides the vector, entry-wise, by another vector.

Definition at line 209 of file vuVector.cpp.

References val.

float vuVector::dot const vuVector v  )  const
 

Returns the dot product of the vector with another vector.

Definition at line 235 of file vuVector.cpp.

References val.

float const * vuVector::getData void   )  const
 

const version of getData()

Definition at line 114 of file vuVector.cpp.

float * vuVector::getData void   ) 
 

Returns the data pointer.

The data is stored as a four dimensional float array. The getData() function can both retrieve and modify; it is similar to the [] operator. To warrant the return of a const pointer (for use in other const member functions) explicitly cast the pointer returned to (const).

Definition at line 111 of file vuVector.cpp.

Referenced by MCMesh::_compileData(), vuGrid::drawLine(), vu1112111::drawSplatOrtho(), vu1512111::drawSplatOrtho(), vu111211a::drawTetNormals(), vuCamera::getViewMat(), vuParallelCamera::project(), MCMesh::render(), vu111211a::render(), vu1512112::sortByDistance(), and vu1112117::updateShLight().

int vuVector::getDominantAxis  )  const
 

Returns index of component with highest absolute.

Definition at line 418 of file vuVector.cpp.

References val.

Referenced by main().

vuString vuVector::getString  ) 
 

returns a c-string representation without '
'

Definition at line 556 of file vuVector.cpp.

References val.

vuVector vuVector::inv void   )  const
 

Returns the entry-wise inverse of the vector.

Entry wise meaning that each of the x, y, z coordinates is treated separately, leaving the fourth w coordinate untouched.

Definition at line 158 of file vuVector.cpp.

References val.

vuVector & vuVector::invEq void   ) 
 

Inverts the vector entry-wise.

Definition at line 169 of file vuVector.cpp.

References val.

int vuVector::load char *  load_from  ) 
 

this will load the values referenced by load_from

the values will come in as ascii values and will have to be converted to floats. they will be received in the format; x, y, z, w the last position will be returned.

Definition at line 492 of file vuVector.cpp.

References get_next_blank(), get_next_comma(), strip_white_space(), and val.

Referenced by vuCamera::RestoreShotBasic(), vuParallelCamera::RestoreShotOrtho(), and vuPerspectiveCamera::RestoreShotPersp().

Here is the call graph for this function:

vuVector & vuVector::makeUnit void   ) 
 

Normalizes the vector to a length of 1.

This makes a unit vector which points in the same direction as the instance.

Definition at line 130 of file vuVector.cpp.

References val.

Referenced by Scanner::_calcViewVectors(), MCMesh::_compileData(), vuSphVwFlt_Blend< SIZE, TYPE >::_factor(), MarchingCubesBase::calcVertex(), vuFourierVolume< S >::calcViewVectors(), ns_vu1112112::vu1112112::Cast(), vu111211A::computeViewMatrix(), vu1512119::computeViewMatrix(), vu111211A::computeZNormalizedViewingVectorLength(), vu1512119::computeZNormalizedViewingVectorLength(), vuSphVwFlt_Blend< SIZE, TYPE >::filter(), vuSphericFilter< SIZE, TYPE >::getNearestViews(), MCMesh::MCTriangle::GetNormal(), vuFourierCluster< SIZE, TYPE >::handleSlice(), vuSphericInteractive< SIZE, TYPE >::indexOfNearestView(), vuPerspectiveCamera::init(), vuParallelCamera::init(), vu1512113::intersectRayWithBox(), vu1512122::intersectRayWithBox(), vu1512119::makeIntermediateImageOrtho(), vu111211A::makeIntermediateImageOrthoFastClass(), vu111211A::makeIntermediateImagePerspective(), vu1512119::makeIntermediateImagePerspective(), vuShearWarp::OnButtonApplyViewing(), vuBCCShearWarp::OnButtonApplyViewing(), vuSpectral::OnButtonLightPos(), vuSpecFVR::OnButtonLightPos(), vuSimpleFBR< SIZE, TYPE >::OnButtonSnap2View(), vu111211A::preClassification(), vu1512112::preprocess(), vu1611_2< SIZE, TYPE >::preview(), vu1512113::renderImage(), vu1512122::renderImage(), vu1512119::runlengthEncode(), Volume::setCamera(), vuCamera::setLookAtVector(), vuCamera::setRightVector(), vuCamera::setUpVector(), vuFourierVolume< S >::setViewVectors(), vu1112118::setViewVectors(), vu1112117::setViewVectors(), vu111211A::shearOrtho(), vu1512119::shearOrtho(), vu111211A::shearPerspective(), vu1512119::shearPerspective(), vu1512112::sortByDistance(), vuArcBall::turn(), and vuFourierCluster< SIZE, TYPE >::weightView().

vuVector vuVector::mul const vuVector rhs  )  const
 

Returns the entry-wise product of the vector with another vector.

Definition at line 178 of file vuVector.cpp.

References val.

Referenced by vuMatrix::makeRotate().

vuVector & vuVector::mulEq const vuVector rhs  ) 
 

Multiplies the vector, entry-wise, by another vector.

Definition at line 189 of file vuVector.cpp.

References val.

float vuVector::norm void   )  const
 

Computes the 2-norm on the vector (lenght operator).

Definition at line 118 of file vuVector.cpp.

References val.

Referenced by MarchingCubesBase::calcVertex(), vuSplat::glOnMouse(), vuSpecSplat::glOnMouse(), vuSpecFVR::glOnMouse(), vuShearWarp::glOnMouse(), vuPreviewWin::glOnMouse(), vuFVR::glOnMouse(), vuCellProjector::glOnMouse(), vuBccSplat::glOnMouse(), vuBCCSheetSplatter::glOnMouse(), vuBCCShearWarp::glOnMouse(), vuBCCMarchingTetrahedra::glOnMouse(), vuPerspectiveCamera::init(), main(), vuBasicUtility::onKeyboardRotate(), vuBasicUtility::onMouseLeftMoving(), realTrans(), ns_vu1112112::vuSampleRay::SamplingDistance(), ns_vu1112113::vuSampleRay::SamplingDistance(), and vuSpherical::vuSpherical().

float vuVector::norm2 void   )  const
 

Computes squared 2-norm (scalar product with itself).

Definition at line 124 of file vuVector.cpp.

References val.

Referenced by vu1512113::renderImage(), and vuArcBall::turn().

vuVector & vuVector::normalize void   ) 
 

Normalizes the vector in homogenous space.

Divides the whole vector by the 4th coordinate to make it 1.

Definition at line 146 of file vuVector.cpp.

References val.

Referenced by vuConvexHull::angleThreshold(), ns_vu1112112::Parser::ReadGeneral(), vuSphericView< SIZE, TYPE >::writeIntoBuffer(), and vuSphericView< SIZE, TYPE >::writeToFileStream().

vuVector vuVector::operator * float  s  )  const
 

Returns the product of the vector with a scalar.

Definition at line 298 of file vuVector.cpp.

References val.

vuMatrix vuVector::operator * const vuVector v  )  const
 

Returns the product of the vector with another vector.

Definition at line 287 of file vuVector.cpp.

References dword, val, and vuMatrix::val.

vuVector vuVector::operator * const vuMatrix m  )  const
 

Returns the product of the vector and a matrix.

Definition at line 275 of file vuVector.cpp.

References dword, vuMatrix::val, and val.

vuVector & vuVector::operator *= float  s  ) 
 

Multiplies the vector by a scalar.

Definition at line 397 of file vuVector.cpp.

References val.

vuVector & vuVector::operator *= const vuMatrix m  ) 
 

Multiplies the vector by a matrix.

Definition at line 379 of file vuVector.cpp.

References dword, vuMatrix::val, and val.

bool vuVector::operator!= const vuVector v  )  const
 

An inequality operator, comparing only the x,y,z coordinates.

Definition at line 413 of file vuVector.cpp.

References operator==().

Here is the call graph for this function:

vuVector vuVector::operator+ const vuVector v  )  const
 

Returns the sum of the vector with another vector.

Definition at line 253 of file vuVector.cpp.

References val.

vuVector & vuVector::operator+= const vuVector v  ) 
 

Adds a vector to this vector.

Definition at line 331 of file vuVector.cpp.

References val.

vuVector vuVector::operator- const vuVector v  )  const
 

Returns the difference of the vector from another vector.

Definition at line 264 of file vuVector.cpp.

References val.

vuVector & vuVector::operator-= const vuVector v  ) 
 

Subtracts a vector from this vector.

Definition at line 341 of file vuVector.cpp.

References val.

vuVector vuVector::operator/ float  s  )  const
 

Returns the fraction of the vector with a scalar.

Definition at line 309 of file vuVector.cpp.

References val.

vuVector & vuVector::operator= const float v  ) 
 

Assigns a 3d float array to the vector.

Definition at line 83 of file vuVector.cpp.

References val.

vuVector & vuVector::operator= float  v  ) 
 

Assigns the value v to the x,y,z elements of the vector.

Definition at line 75 of file vuVector.cpp.

References val.

vuVector & vuVector::operator= const vuVector v  ) 
 

The assignment operator.

Definition at line 62 of file vuVector.cpp.

References val.

bool vuVector::operator== const vuVector v  )  const
 

An equality operator, comparing only the x,y,z coordinates.

Definition at line 407 of file vuVector.cpp.

References val.

Referenced by operator!=().

const float & vuVector::operator[] dword  index  )  const
 

The const access operator.

Definition at line 99 of file vuVector.cpp.

References dword, and val.

float & vuVector::operator[] dword  index  ) 
 

The access operator.

Definition at line 93 of file vuVector.cpp.

References dword, and val.

void vuVector::print  ) 
 

prints values to the stdout

Definition at line 431 of file vuVector.cpp.

References val.

Referenced by vu1512112::read(), vu1512112::readRaw(), and realTrans().

void vuVector::save char *  save_to  ) 
 

this will set read_to to be the four ascii values in x, y, z, w

this will use the same format as load

Definition at line 516 of file vuVector.cpp.

References val.

Referenced by vuCamera::TakeSnapShotBasic(), vuParallelCamera::TakeSnapShotOrtho(), and vuPerspectiveCamera::TakeSnapShotPersp().


Friends And Related Function Documentation

vuVector cross const vuVector v1,
const vuVector v2
[friend]
 

Returns the cross product of two vectors.

Definition at line 224 of file vuVector.cpp.

Referenced by Scanner::_calcViewVectors(), vuFourierVolume< S >::calcViewVectors(), vu111211A::computeViewMatrix(), vu1512119::computeViewMatrix(), MCMesh::MCTriangle::GetNormal(), vu111211a::getNormal(), vuPerspectiveCamera::init(), vuParallelCamera::init(), vuShearWarp::OnButtonApplyViewing(), vuBCCShearWarp::OnButtonApplyViewing(), vuParallelCamera::project(), vuCamera::setLookAtVector(), vuCamera::setUpVector(), and vuArcBall::turn().

float dot const vuVector v1,
const vuVector v2
[friend]
 

Returns the dot product of two vectors.

Definition at line 218 of file vuVector.cpp.

Referenced by Scanner::_calcViewVectors(), vuConvexHull::angleThreshold(), vuSphLfFlt_FitAngle< SIZE, TYPE >::calcFilteredViews(), vuFourierVolume< S >::calcViewVectors(), ns_vu1112112::vu1112112::Cast(), vu1112113::Cast(), vuSphVwFlt_Blend< SIZE, TYPE >::filter(), vuSphericFilter< SIZE, TYPE >::getNearestViews(), vu111211a::getTetOrientation(), vu1512119::makeIntermediateImageOrtho(), vu111211A::makeIntermediateImageOrthoFastClass(), vu111211A::makeIntermediateImagePerspective(), vu1512119::makeIntermediateImagePerspective(), vuSimpleFBR< SIZE, TYPE >::OnButtonSnap2View(), vu111211A::preClassification(), vuParallelCamera::project(), realTrans(), vu1512113::renderImage(), vu1512122::renderImage(), ns_vu1112113::DatPnt::shade(), vu1512112::sortByDistance(), and vuArcBall::turn().

const vuVector operator * float  s,
const vuVector v
[friend]
 

Returns the product of a scalar with a vector.

Definition at line 320 of file vuVector.cpp.

ostream& operator<< ostream &  out,
const vuVector v
[friend]
 

writes the foure elements to a stream; separated by whitespaces

Definition at line 538 of file vuVector.cpp.

istream& operator>> istream &  in,
vuVector v
[friend]
 

reads a vector from a stream

Definition at line 547 of file vuVector.cpp.

friend class vuMatrix [friend]
 

Definition at line 30 of file vuVector.h.


Member Data Documentation

float vuVector::val[4] [private]
 

The coordinates of the vector stored as a floating point array.

Definition at line 166 of file vuVector.h.

Referenced by cross(), cross(), div(), divEq(), dot(), dot(), getDominantAxis(), getString(), inv(), invEq(), load(), makeUnit(), mul(), mulEq(), norm(), norm2(), normalize(), operator *(), operator *(), vuMatrix::operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator<<(), operator=(), operator==(), operator>>(), operator[](), print(), save(), and vuVector().


The documentation for this class was generated from the following files:
Generated on Wed Dec 15 21:22:08 2004 for vuVolume by  doxygen 1.3.9.1