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

GCS::GVector3 Class Reference

Provides a vector with 3 elements and various mathematical operations. More...

#include <GVector3.h>

Collaboration diagram for GCS::GVector3:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GVector3 ()
 GVector3 (const double d)
 GVector3 (const double x, const double y, const double z)
 GVector3 (const double *component)
 GVector3 (const GVector3 &original)
double length () const
double lengthsq () const
GVector3reset ()
GVector3set (double x, double y, double z)
GVector3set (const GVector3 &original)
GVector3normalize ()
GVector3scaleXYZ (const GVector3 &scale)
GVector3scaleXYZ (double x, double y, double z)
GVector3add (const GVector3 &right)
GVector3sub (const GVector3 &right)
GVector3mul (double scalar)
double dot (const GVector3 &right) const
GVector3 cross (const GVector3 &right) const
GVector3operator= (const GVector3 &original)
GVector3 operator+ (const GVector3 &right) const
GVector3 operator- (const GVector3 &right) const
GVector3 operator * (double factor) const
GVector3operator+= (const GVector3 &right)
GVector3operator-= (const GVector3 &right)
bool operator== (const GVector3 &comp) const
double distanceTo (const GVector3 &p) const
double angleTo (const GVector3 &v) const
GVector3turnAroundAxis (const GVector3 &axis, double angle_rad)
GVector3projectTo (const GVector3 &v)

Detailed Description

Provides a vector with 3 elements and various mathematical operations.

Author:
Raphael Langerhorst

Gerald Degeneve

Todo:
move all inline methods into an implmenetation file


Constructor & Destructor Documentation

GCS::GVector3::GVector3  )  [inline]
 

Default constructor initializes all components to 0.

GCS::GVector3::GVector3 const double  d  )  [inline]
 

Initializes all components to the given value.

GCS::GVector3::GVector3 const double  x,
const double  y,
const double  z
[inline]
 

Initializes vector to given values.

GCS::GVector3::GVector3 const double *  component  )  [inline]
 

Initializes vector to given array.

Note:
The array must contain at least three doubles.

GCS::GVector3::GVector3 const GVector3 original  )  [inline]
 

Copy constructor


Member Function Documentation

GVector3 & GCS::GVector3::add const GVector3 right  )  [inline]
 

Mathematically adds given vector to this vector.

double GCS::GVector3::angleTo const GVector3 v  )  const [inline]
 

Calculates the angle (in radians!!) between two vectors.

If one of the involved vector's length is 0 then 0 is returned

Returns:
angle between vectors in rad

GVector3 GCS::GVector3::cross const GVector3 right  )  const [inline]
 

Calculates the cross product and returns a new vector.

Note:
: this operation does NOT change the current vector, instead, a new one is created for the result and returned.

double GCS::GVector3::distanceTo const GVector3 p  )  const [inline]
 

If a GVector3 is used as a point/position then this method can be used to calculate distances between two points.

Returns:
distance between positions

double GCS::GVector3::dot const GVector3 right  )  const [inline]
 

Calculates the dot product of this * right.

Note:
: no involved vectors are changed since the result is a scalar;

double GCS::GVector3::length  )  const [inline]
 

Calculates the length of the vector.

double GCS::GVector3::lengthsq  )  const [inline]
 

Calculates the square-length of the vector.

GVector3 & GCS::GVector3::mul double  scalar  )  [inline]
 

Scales the vector by given scalar.

GVector3 & GCS::GVector3::normalize  )  [inline]
 

Normalizes the vector to a length of 1. Be careful with vectors that have all components set to 0.

GVector3 GCS::GVector3::operator * double  factor  )  const [inline]
 

Multiplies this vector with given scalar and returns the result.

Note:
This vector is not changed by the operation.

GVector3 GCS::GVector3::operator+ const GVector3 right  )  const [inline]
 

Adds this vector to given vector and returns a new vector as the result.

GVector3 & GCS::GVector3::operator+= const GVector3 right  )  [inline]
 

Adds given vector to this vector.

GVector3 GCS::GVector3::operator- const GVector3 right  )  const [inline]
 

Subtracts this vector from given vector and returns a new vector as the result.

GVector3 & GCS::GVector3::operator-= const GVector3 right  )  [inline]
 

Subtracts given vector from this vector.

GVector3 & GCS::GVector3::operator= const GVector3 original  )  [inline]
 

Copies all members from given vector.

bool GCS::GVector3::operator== const GVector3 comp  )  const [inline]
 

Compares the given vector to this vector with an epsilon of 0.00001

Todo:
add an optional parameter for epsilon.

GVector3 & GCS::GVector3::projectTo const GVector3 v  )  [inline]
 

Projects this vector onto given vector and returns this vector. If the length of the given vector is 0 then this vector is NOT projected and returned as is.

GVector3 & GCS::GVector3::reset  )  [inline]
 

Resets the vector to x=y=z=0.

GVector3 & GCS::GVector3::scaleXYZ double  x,
double  y,
double  z
[inline]
 

This can be used for asymetric scaling. Every component is multiplied with the corresponding given value.

GVector3 & GCS::GVector3::scaleXYZ const GVector3 scale  )  [inline]
 

Simply calls scaleXYZ(scale.x,scale.y,scale.z);

GVector3 & GCS::GVector3::set const GVector3 original  )  [inline]
 

Copies values from given vector.

GVector3 & GCS::GVector3::set double  x,
double  y,
double  z
[inline]
 

Sets the vector to given values.

GVector3 & GCS::GVector3::sub const GVector3 right  )  [inline]
 

Mathematically subtracts given vector from this vector.

GVector3 & GCS::GVector3::turnAroundAxis const GVector3 axis,
double  angle_rad
[inline]
 

Turns this vector around given vector for given angle;

Parameters:
angle_rad angle in radians


Member Data Documentation

float GCS::GVector3::c[3]
 

Array of coordinates.

double GCS::GVector3::u
 

Texture coordinate u.

double GCS::GVector3::v
 

Texture coordinate v.

double GCS::GVector3::w
 

Texture coordinate w.

double GCS::GVector3::x
 

Point coordinate x.

double GCS::GVector3::y
 

Point coordinate y.

double GCS::GVector3::z
 

Point coordinate z.


The documentation for this class was generated from the following file:
Generated on Thu Oct 21 21:18:25 2004 for G System by doxygen 1.3.6