Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

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 Methods

 vector3 (void)
 Default Constructor. More...

 vector3 (real_t x_, real_t y_, real_t z_)
 Constructor. More...

 vector3 (real_t *r3)
 Constructor. More...

 vector3 (const math::vector3 &p)
 Copy Constructor.

math::vector3 & operator= (const math::vector3 &p)
 Assignment Operator.

void set (real_t x_, real_t y_, real_t z_)
 Sets vector to (x_, y_, z_).

real_t operator() (unsigned int index) const
 Array like read access to vector. More...

real_toperator() (unsigned int index)
 Array like write access to vector. More...

math::vector3 operator+ (const math::vector3 &rhs) const
 Vector Addition. More...

math::vector3 operator- (const math::vector3 &rhs) const
 Vector Subtraction. More...

math::vector3 operator * (const math::vector3 &rhs) const
 Vector Component Multiplication. More...

math::vector3 operator/ (const math::vector3 &rhs) const
 Vector Component Division. More...

math::vector3 operator- (void) const
 Returns the negated (flipped) vector. More...

math::vector3 operator * (real_t rhs) const
 Scalar Multiplication. More...

math::vector3 operator/ (real_t rhs) const
 Scalar Division. More...

void operator-= (const math::vector3 &v)
 Vector Subtraction. More...

void operator+= (const math::vector3 &v)
 Vector Addition. More...

void operator *= (const math::vector3 &rhs)
 Vector Component Multiplication. More...

void operator/= (const math::vector3 &rhs)
 Vector Component Division. More...

void operator-= (real_t rhs)
 Scalar Subtraction. More...

void operator+= (real_t rhs)
 Scalar Addition. More...

void operator *= (real_t rhs)
 Scalar Multiplication. More...

void operator/= (real_t rhs)
 Scalar Division. More...

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. More...

void normalize (void)
 Normalizes the vector. More...

void negate (void)
 Negates (flips) the vector. More...

bool operator== (const math::vector3 &rhs) const
 Equals operator. More...

bool operator!= (const math::vector3 &rhs) const
 Not equals operator. More...

 operator const real_t * (void) const
 Cast operator to const real_t*. More...


Static Public Attributes

const vector3 ZERO
 The vector .

const vector3 X_AXIS
 The vector .

const vector3 Y_AXIS
 The vector .

const vector3 Z_AXIS
 The vector .


Friends

math::vector3 operator * (real_t lhs, const math::vector3 &rhs)
 Scalar Multiplication. More...

std::ostream & operator<< (std::ostream &o, const math::vector3 &vec)
 stream output operator. More...

math::vector3 math::cross (const math::vector3 &lhs, const math::vector3 &rhs)
 Cross Product. More...

void math::add (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
 Vector Addition. More...

void math::subtract (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
 Vector Subtraction. More...

void math::multiply (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
 Vector Component Multiplication. More...

void math::divide (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
 Vector Component Division. More...

void math::multiply (math::vector3 &dest, const math::vector3 &lhs, real_t rhs)
 Scalar Multiplication. More...

void math::multiply (math::vector3 &dest, real_t rhs, const math::vector3 &lhs)
 Scalar Multiplication. More...

real_t math::dot (const math::vector3 &lhs, const math::vector3 &rhs)
 Dot Product. More...


Detailed Description

A 3-dimensional vector.

Definition at line 32 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 150 of file vector.h.

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

Constructor.

Sets vector to (x_, y_, z_).

Definition at line 160 of file vector.h.

References real_t.

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 171 of file vector.h.

References real_t.


Member Function Documentation

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

Returns the length of the vector.

The length of a vector is defined as: .

Definition at line 446 of file vector.h.

Referenced by math::quaternion::from_angle_axis.

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 471 of file vector.h.

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

Normalizes the vector.

Sets this vector to be unit length. A unit length vector is defined as .

Definition at line 457 of file vector.h.

References math::equals.

Referenced by gl::matrix4::build_look_at.

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 301 of file vector.h.

References real_t.

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 258 of file vector.h.

References m_data.

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 394 of file vector.h.

References real_t.

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 349 of file vector.h.

References m_data.

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 508 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 497 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 217 of file vector.h.

References real_t.

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 206 of file vector.h.

References real_t.

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 229 of file vector.h.

References m_data.

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 383 of file vector.h.

References real_t.

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 338 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 285 of file vector.h.

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 244 of file vector.h.

References m_data.

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 372 of file vector.h.

References real_t.

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 328 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. \warn No divide by zero checks.

Definition at line 316 of file vector.h.

References real_t.

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&) \warn No divide by zero checks.

Definition at line 273 of file vector.h.

References m_data.

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. \warn No divide by zero checks.

Definition at line 406 of file vector.h.

References real_t.

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. \warn No divide by zero checks.

Definition at line 361 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 484 of file vector.h.

References math::equals, and m_data.


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).

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).

math::vector3 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.

Definition at line 14 of file vector.cpp.

std::ostream& 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.

Definition at line 24 of file vector.cpp.


Generated on Tue Feb 11 18:49:50 2003 for uber by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002