syBR::map2syBR::Vector3 Class Reference

Double-precision three-dimension vector. More...

#include <Vector3.hpp>

List of all members.

Public Member Functions

 Vector3 ()
 Constructor 1.
 Vector3 (const double x, const double y, const double z)
 Constructor 2.
 ~Vector3 ()
 Destructor.
const double getX () const
 Get the x component of the vector.
const double getY () const
 Get the y component of the vector.
const double getZ () const
 Get the z component of the vector.
void set (const double x, const double y, const double z)
 Set the x, y and z components of the vector.
void setX (const double x)
 Set the x component of the vector.
void setY (const double y)
 Set the y component of the vector.
void setZ (const double z)
 Set the z component of the vector.
void from3Array (const double components[3])
 Construct vector from a three-dimension array.
const double getLength () const
 Get the length / magnitude of the vector.
const Vector3 normalize () const
 Normalize the vector so that its length equals 1.
const double dotProduct (const Vector3 &right) const
 Calculate the dot-product of this vector with another one.
const Vector3 crossProduct (const Vector3 &right) const
 Calculate the cross-product of this vector with another one.
Vector3operator= (const Vector3 &right)
 Affectation operator.
Vector3 operator+ (const Vector3 &right) const
 Addition operator.
Vector3 operator- (const Vector3 &right) const
 Substraction operator.
Vector3 operator * (const double right) const
 Scalar multiplication operator.
Vector3 operator/ (const double right) const
 Scalar division operator.
void operator+= (const Vector3 &right)
 Addition-affectation operator.
void operator-= (const Vector3 &right)
 Substraction-affectation operator.
void operator *= (const double right)
 Scalar multiplication-affectation operator.
void operator/= (const double right)
 Scalar division-affectation operator.
bool operator== (const Vector3 &right) const
 Comparison operator.
bool operator!= (const Vector3 &right) const
 Comparison operator.

Private Attributes

double m_x
 x component of the vector
double m_y
 y component of the vector
double m_z
 z component of the vector
double m_lastCalculatedLength
 Last calculated value for the length.
bool m_lastCalculatedLengthIsValid
 One of these:
  • true if the length must be recalculated
  • false if m_lastCalculatedLength contains the length of the vector.


Detailed Description

Double-precision three-dimension vector.

Constructor & Destructor Documentation

syBR::map2syBR::Vector3::Vector3 (  ) 

Constructor 1.

syBR::map2syBR::Vector3::Vector3 ( const double  x,
const double  y,
const double  z 
)

Constructor 2.

Parameters:
x x component of the vector
y y component of the vector
z z component of the vector

syBR::map2syBR::Vector3::~Vector3 (  ) 

Destructor.


Member Function Documentation

const double syBR::map2syBR::Vector3::getX (  )  const

Get the x component of the vector.

Returns:
x component of the vector

const double syBR::map2syBR::Vector3::getY (  )  const

Get the y component of the vector.

Returns:
y component of the vector

const double syBR::map2syBR::Vector3::getZ (  )  const

Get the z component of the vector.

Returns:
z component of the vector

void syBR::map2syBR::Vector3::set ( const double  x,
const double  y,
const double  z 
)

Set the x, y and z components of the vector.

Parameters:
x x component of the vector
y y component of the vector
z z component of the vector

void syBR::map2syBR::Vector3::setX ( const double  x  ) 

Set the x component of the vector.

Parameters:
x x component of the vector

void syBR::map2syBR::Vector3::setY ( const double  y  ) 

Set the y component of the vector.

Parameters:
y y component of the vector

void syBR::map2syBR::Vector3::setZ ( const double  z  ) 

Set the z component of the vector.

Parameters:
z z component of the vector

void syBR::map2syBR::Vector3::from3Array ( const double  components[3]  ) 

Construct vector from a three-dimension array.

Parameters:
components Three-dimension array containing the values for the x, y and z components

const double syBR::map2syBR::Vector3::getLength (  )  const

Get the length / magnitude of the vector.

Returns:
Length / magnitude of the vector

const Vector3 syBR::map2syBR::Vector3::normalize (  )  const

Normalize the vector so that its length equals 1.

Returns:
Vector pointing in the same direction as this vector but with a length equal to 1

const double syBR::map2syBR::Vector3::dotProduct ( const Vector3 right  )  const

Calculate the dot-product of this vector with another one.

Parameters:
right Vector to calculate the dot product against
Returns:
Dot-product between the two vectors

const Vector3 syBR::map2syBR::Vector3::crossProduct ( const Vector3 right  )  const

Calculate the cross-product of this vector with another one.

Parameters:
right Vector to calculate the cross product against
Returns:
Cross-product between the two vectors

Vector3 & syBR::map2syBR::Vector3::operator= ( const Vector3 right  ) 

Affectation operator.

Parameters:
right Vector to affect to this one
Returns:
Result of the affectation

Vector3 syBR::map2syBR::Vector3::operator+ ( const Vector3 right  )  const

Addition operator.

Parameters:
right Vector to add to this one
Returns:
Result of the addition

Vector3 syBR::map2syBR::Vector3::operator- ( const Vector3 right  )  const

Substraction operator.

Parameters:
right Vector to substract from this one
Returns:
Result of the substraction

Vector3 syBR::map2syBR::Vector3::operator * ( const double  right  )  const

Scalar multiplication operator.

Parameters:
right Scalar by which this vector must be multiplied
Returns:
Result of the multiplication

Vector3 syBR::map2syBR::Vector3::operator/ ( const double  right  )  const

Scalar division operator.

Parameters:
right Scalar by which this vector must be divided
Returns:
One of these:
  • Result of the division if right is different than zero
  • This vector unmodified otherwise

void syBR::map2syBR::Vector3::operator+= ( const Vector3 right  ) 

Addition-affectation operator.

Parameters:
right Vector to add to this one

void syBR::map2syBR::Vector3::operator-= ( const Vector3 right  ) 

Substraction-affectation operator.

Parameters:
right Vector to substract from this one

void syBR::map2syBR::Vector3::operator *= ( const double  right  ) 

Scalar multiplication-affectation operator.

Parameters:
right Scalar by which this vector must be multiplied

void syBR::map2syBR::Vector3::operator/= ( const double  right  ) 

Scalar division-affectation operator.

Parameters:
right Scalar by which this vector must be divided

bool syBR::map2syBR::Vector3::operator== ( const Vector3 right  )  const

Comparison operator.

Compare two vectors by taking rounding errors in account.

Parameters:
right Vector to compare to
Returns:
One of these:
  • true if the two vectors are the same
  • false otherwise

bool syBR::map2syBR::Vector3::operator!= ( const Vector3 right  )  const

Comparison operator.

Compare two vectors by taking rounding errors in account.

Parameters:
right Vector to compare to
Returns:
One of these:
  • true if the two vectors are different
  • false otherwise


Member Data Documentation

double syBR::map2syBR::Vector3::m_x [private]

x component of the vector

double syBR::map2syBR::Vector3::m_y [private]

y component of the vector

double syBR::map2syBR::Vector3::m_z [private]

z component of the vector

double syBR::map2syBR::Vector3::m_lastCalculatedLength [mutable, private]

Last calculated value for the length.

bool syBR::map2syBR::Vector3::m_lastCalculatedLengthIsValid [mutable, private]

One of these:

It is used to avoid calculating the lenght of the vector each time getLength() is called.


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

Copyright © 2008 by Sebastien Frippiat
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:34 2008