math::vector3 Class Reference

A 3-dimensional vector. More...

#include <vector.h>

Collaboration diagram for math::vector3:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 vector3 (void)
 Default Constructor.
 vector3 (real_t x_, real_t y_, real_t z_)
 Constructor.
 vector3 (real_t *r3)
 Constructor.
 vector3 (const math::vector3 &p)
 Copy Constructor.
math::vector3operator= (const math::vector3 &p)
 Assignment Operator.
void set (real_t x_, real_t y_, real_t z_)
 Sets vector to (x_, y_, z_).
void set (real_t *r3)
 Sets vector to array.
real_t operator() (unsigned int index) const
 Array like read access to vector.
real_toperator() (unsigned int index)
 Array like write access to vector.
math::vector3 operator+ (const math::vector3 &rhs) const
 Vector Addition.
math::vector3 operator- (const math::vector3 &rhs) const
 Vector Subtraction.
math::vector3 operator* (const math::vector3 &rhs) const
 Vector Component Multiplication.
math::vector3 operator/ (const math::vector3 &rhs) const
 Vector Component Division.
math::vector3 operator- (void) const
 Returns the negated (flipped) vector.
math::vector3 operator* (real_t rhs) const
 Scalar Multiplication.
math::vector3 operator/ (real_t rhs) const
 Scalar Division.
void operator-= (const math::vector3 &v)
 Vector Subtraction.
void operator+= (const math::vector3 &v)
 Vector Addition.
void operator*= (const math::vector3 &rhs)
 Vector Component Multiplication.
void operator/= (const math::vector3 &rhs)
 Vector Component Division.
void operator-= (real_t rhs)
 Scalar Subtraction.
void operator+= (real_t rhs)
 Scalar Addition.
void operator*= (real_t rhs)
 Scalar Multiplication.
void operator/= (real_t rhs)
 Scalar Division.
real_t x (void) const
 Returns a copy of x.
real_t y (void) const
 Returns a copy of y.
real_t z (void) const
 Returns a copy of z.
void x (real_t x_)
 Sets the value of x.
void y (real_t y_)
 Sets the value of y.
void z (real_t z_)
 Sets the value of z.
double length (void) const
 Returns the length of the vector.
void normalize (void)
 Normalizes the vector.
void negate (void)
 Negates (flips) the vector.
bool operator== (const math::vector3 &rhs) const
 Equals operator.
bool operator!= (const math::vector3 &rhs) const
 Not equals operator.
 operator const real_t * (void) const
 Cast operator to const real_t*.

Static Public Member Functions

static math::vector3 lerp (real_t percent, const math::vector3 &a, const math::vector3 &b)
 Linear Interpretation.

Static Public Attributes

static const vector3 ZERO
 The vector $(0,0,0)$.
static const vector3 X_AXIS
 The vector $(1,0,0)$.
static const vector3 Y_AXIS
 The vector $(0,1,0)$.
static const vector3 Z_AXIS
 The vector $(0,0,1)$.

Friends

math::vector3 math::operator* (real_t lhs, const math::vector3 &rhs)
 Scalar Multiplication.
std::ostream & math::operator<< (std::ostream &o, const math::vector3 &vec)
 stream output operator
math::vector3 math::cross (const math::vector3 &lhs, const math::vector3 &rhs)
 Cross Product.
void math::add (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
 Vector Addition.
void math::subtract (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
 Vector Subtraction.
void math::multiply (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
 Vector Component Multiplication.
void math::divide (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
 Vector Component Division.
void math::multiply (math::vector3 &dest, const math::vector3 &lhs, real_t rhs)
 Scalar Multiplication.
void math::multiply (math::vector3 &dest, real_t rhs, const math::vector3 &lhs)
 Scalar Multiplication.
real_t math::dot (const math::vector3 &lhs, const math::vector3 &rhs)
 Dot Product.


Detailed Description

A 3-dimensional vector.

Definition at line 52 of file vector.h.


Constructor & Destructor Documentation

math::vector3::vector3 ( void   )  [inline]

Default Constructor.

Initializes the x, y, and z components to 0.0.

Definition at line 170 of file vector.h.

Referenced by operator*(), operator+(), operator-(), and operator/().

math::vector3::vector3 ( real_t  x_,
real_t  y_,
real_t  z_ 
) [inline]

Constructor.

Sets vector to (x_, y_, z_).

Definition at line 180 of file vector.h.

math::vector3::vector3 ( real_t r3  )  [inline]

Constructor.

Sets vector to what r3 points too.

Parameters:
r3 Pointer to a real_t[ 3 ]

Definition at line 191 of file vector.h.


Member Function Documentation

double math::vector3::length ( void   )  const [inline]

Returns the length of the vector.

The length of a vector is defined as: $\sqrt{x^2+y^2+z^2}$.

Definition at line 477 of file vector.h.

Referenced by math::quaternion::from_angle_axis(), and normalize().

math::vector3 math::vector3::lerp ( real_t  percent,
const math::vector3 a,
const math::vector3 b 
) [static]

Linear Interpretation.

Interprets the between the two vectors that a and b describe.

Parameters:
percent A real_t between [0-1] descibing how much to interpret between qa and qb.
a Initial vector.
b Ending vector.

Definition at line 135 of file vector.cpp.

void math::vector3::negate ( void   )  [inline]

Negates (flips) the vector.

Note:
The internal data of the vector is changed. No vector is returned.
See also:
math::vector3::operator-() const

Definition at line 502 of file vector.h.

Referenced by math::quaternion::slerp().

void math::vector3::normalize ( void   )  [inline]

Normalizes the vector.

Sets this vector to be unit length. A unit length vector is defined as $\hat{v}\equiv\frac{v}{|v|}$.

Definition at line 488 of file vector.h.

References math::equals(), and length().

math::vector3::operator const real_t * ( void   )  const [inline]

Cast operator to const real_t*.

Returns a read only pointer to the vector's x, y, z data.

Definition at line 539 of file vector.h.

bool math::vector3::operator!= ( const math::vector3 rhs  )  const [inline]

Not equals operator.

Checks if the vector is not equal to rhs.

Note:
Accounts for precision errors.
Returns:
True is the vectors are not equal.

Definition at line 528 of file vector.h.

References math::equals(), and m_data.

real_t& math::vector3::operator() ( unsigned int  index  )  [inline]

Array like write access to vector.

Returns a reference to either the x, y, or z component of the vector based on the index passed in. If the index is not 0, 1, or 3, abort( ) may be called.

Definition at line 248 of file vector.h.

real_t math::vector3::operator() ( unsigned int  index  )  const [inline]

Array like read access to vector.

Returns a copy of either the x, y, or z component of the vector based on the index passed in. If the index is not 0, 1, or 3, abort( ) may be called.

See also:
math::vector3::operator()(unsigned int) for write access

Definition at line 237 of file vector.h.

math::vector3 math::vector3::operator* ( real_t  rhs  )  const [inline]

Scalar Multiplication.

Returns the scalar product of the vector and rhs.

See also:
math::multiply(math::vector3&,const math::vector3&,real_t)
Parameters:
rhs A scalar.

Definition at line 332 of file vector.h.

References vector3().

math::vector3 math::vector3::operator* ( const math::vector3 rhs  )  const [inline]

Vector Component Multiplication.

Multiplies the corresponding components of the vector and rhs, returning the result.

See also:
math::multiply(math::vector3&,const math::vector3&,const math::vector3&)

Definition at line 289 of file vector.h.

References m_data, and vector3().

void math::vector3::operator*= ( real_t  rhs  )  [inline]

Scalar Multiplication.

Multiplies rhs to each component in the vector. The result is stored in this vector.

Definition at line 425 of file vector.h.

void math::vector3::operator*= ( const math::vector3 rhs  )  [inline]

Vector Component Multiplication.

Multiplies the corresponding components of the vector and rhs, The result is stored in this vector.

Definition at line 380 of file vector.h.

References m_data.

math::vector3 math::vector3::operator+ ( const math::vector3 rhs  )  const [inline]

Vector Addition.

Returns the vector sum of the vector and rhs.

See also:
math::add(math::vector3&,const math::vector3&,const math::vector3&)

Definition at line 260 of file vector.h.

References m_data, and vector3().

void math::vector3::operator+= ( real_t  rhs  )  [inline]

Scalar Addition.

Adds rhs to each component in the vector. The result is stored in this vector.

Definition at line 414 of file vector.h.

void math::vector3::operator+= ( const math::vector3 v  )  [inline]

Vector Addition.

Adds v to the vector. The result is stored in this vector.

Definition at line 369 of file vector.h.

References m_data.

math::vector3 math::vector3::operator- ( void   )  const [inline]

Returns the negated (flipped) vector.

Note:
A new vector is returned. This vector's data is unchanged.

Definition at line 316 of file vector.h.

References vector3().

math::vector3 math::vector3::operator- ( const math::vector3 rhs  )  const [inline]

Vector Subtraction.

Returns the vector difference of the vector and rhs.

See also:
math::subtract(math::vector3&,const math::vector3&,const math::vector3&)

Definition at line 275 of file vector.h.

References m_data, and vector3().

void math::vector3::operator-= ( real_t  rhs  )  [inline]

Scalar Subtraction.

Subtracts rhs from each component in the vector. The result is stored in this vector.

Definition at line 403 of file vector.h.

void math::vector3::operator-= ( const math::vector3 v  )  [inline]

Vector Subtraction.

Subtracts v from the vector. The result is stored in this vector.

Definition at line 359 of file vector.h.

References m_data.

math::vector3 math::vector3::operator/ ( real_t  rhs  )  const [inline]

Scalar Division.

Divides each component of the vector by rhs, returning the result.

Parameters:
rhs A scalar.
Warning:
No divide by zero checks.

Definition at line 347 of file vector.h.

References vector3().

math::vector3 math::vector3::operator/ ( const math::vector3 rhs  )  const [inline]

Vector Component Division.

Divides the corresponding components of this by rhs, returning the result.

See also:
math::divide(math::vector3&,const math::vector3&,const math::vector3&)
Warning:
No divide by zero checks.

Definition at line 304 of file vector.h.

References m_data, and vector3().

void math::vector3::operator/= ( real_t  rhs  )  [inline]

Scalar Division.

Divides rhs from each component in the vector. The result is stored in this vector.

Warning:
No divide by zero checks.

Definition at line 437 of file vector.h.

void math::vector3::operator/= ( const math::vector3 rhs  )  [inline]

Vector Component Division.

Divides the corresponding components of the vector by rhs, The result is stored in this vector.

Warning:
No divide by zero checks.

Definition at line 392 of file vector.h.

References m_data.

bool math::vector3::operator== ( const math::vector3 rhs  )  const [inline]

Equals operator.

Checks if the vector is equal to rhs.

Note:
Accounts for precision errors.
Returns:
True is the vectors are equal.

Definition at line 515 of file vector.h.

References math::equals(), and m_data.

void math::vector3::set ( real_t r3  )  [inline]

Sets vector to array.

Sets vector to what r3 points too.

Parameters:
r3 Pointer to a real_t[ 3 ]

Definition at line 224 of file vector.h.


Friends And Related Function Documentation

void math::add ( math::vector3 dest,
const math::vector3 lhs,
const math::vector3 rhs 
) [friend]

Vector Addition.

Computes the vector sum of lhs and rhs, placing the result in dest.

Note:
This function will always be faster than math::vector3::operator+(const math::vector3&) const
See also:
math::vector3::operator+(const math::vector3&) const
Parameters:
dest Vector sum of lhs and rhs (ouput of function).

math::vector3 math::cross ( const math::vector3 lhs,
const math::vector3 rhs 
) [friend]

Cross Product.

Returns the cross product of lhs and rhs.

void math::divide ( math::vector3 dest,
const math::vector3 lhs,
const math::vector3 rhs 
) [friend]

Vector Component Division.

Divides the corresponding components of lhs by rhs, and places the result in dest.

Note:
This function will always be faster than math::vector3::operator/(const math::vector3&) const
See also:
math::vector3::operator/(const math::vector3&) const
Parameters:
dest Result of the division of each component of lhs and rhs (ouput of function).

real_t math::dot ( const math::vector3 lhs,
const math::vector3 rhs 
) [friend]

Dot Product.

Returns the dot product of lhs and rhs.

void math::multiply ( math::vector3 dest,
real_t  rhs,
const math::vector3 lhs 
) [friend]

Scalar Multiplication.

Computes the scalar product of lhs and rhs, placing the result in dest.

Note:
This function will always be faster than math::vector3::operator*(real_t) const
See also:
math::vector3::operator-(real_t) const
Parameters:
dest Scalar product of lhs and rhs (ouput of function).
lhs A scalar.

void math::multiply ( math::vector3 dest,
const math::vector3 lhs,
real_t  rhs 
) [friend]

Scalar Multiplication.

Computes the scalar product of lhs and rhs, placing the result in dest.

Note:
This function will always be faster than math::vector3::operator*(real_t) const
See also:
math::vector3::operator-(real_t) const
Parameters:
dest Scalar product of lhs and rhs (ouput of function).
rhs A scalar.

void math::multiply ( math::vector3 dest,
const math::vector3 lhs,
const math::vector3 rhs 
) [friend]

Vector Component Multiplication.

Multiplies the corresponding components of lhs and rhs, and places the result in dest.

Note:
This function will always be faster than math::vector3::operator*(const math::vector3&) const
See also:
math::vector3::operator*(const math::vector3&) const
Parameters:
dest Result of the multiplication of each component of lhs and rhs (ouput of function).

math::vector3 math::operator* ( real_t  lhs,
const math::vector3 rhs 
) [friend]

Scalar Multiplication.

Returns the scalar product of lhs and rhs.

See also:
math::vector3::operator*(real_t) const
Parameters:
lhs A scalar.

std::ostream& math::operator<< ( std::ostream &  o,
const math::vector3 vec 
) [friend]

stream output operator

Outputs vec as follows:

x y z

No new line is placed at the end of the stream.

void math::subtract ( math::vector3 dest,
const math::vector3 lhs,
const math::vector3 rhs 
) [friend]

Vector Subtraction.

Computes the vector difference of lhs and rhs, placing the result in dest.

Note:
This function will always be faster than math::vector3::operator-(const math::vector3&) const
See also:
math::vector3::operator-(const math::vector3&) const
Parameters:
dest Vector difference of lhs and rhs (ouput of function).


Generated on Sat Feb 21 16:38:12 2009 for Flock of Birds Library by  doxygen 1.5.7.1