GCS::GVector3 Class Reference

Provides a plane with. 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)
 GVector3 (const QString &values)
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
 operator double * ()
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)
QString toString () const
void fromString (const QString &string)

Public Attributes

union {
   struct {
      double   x
      double   y
      double   z
   } 
   struct {
      double   u
      double   v
      double   w
   } 
   double   c [3]
}; 

Detailed Description

Provides a plane with.

Author:
Gerald Degeneve


Constructor & Destructor Documentation

GCS::GVector3::GVector3 (  ) 

Default constructor initializes all components to 0.

GCS::GVector3::GVector3 ( const double  d  ) 

Initializes all components to the given value.

GCS::GVector3::GVector3 ( const double  x,
const double  y,
const double  z 
)

Initializes vector to given values.

GCS::GVector3::GVector3 ( const double *  component  ) 

Initializes vector to given array.

Note:
The array must contain at least three doubles.

GCS::GVector3::GVector3 ( const GVector3 original  ) 

Copy constructor

GCS::GVector3::GVector3 ( const QString &  values  ) 

Calls fromString() to initialize values.

See also:
fromString()


Member Function Documentation

GVector3 & GCS::GVector3::add ( const GVector3 right  ) 

Mathematically adds given vector to this vector.

double GCS::GVector3::angleTo ( const GVector3 v  )  const

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

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

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

Calculates the dot product of this * right.

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

void GCS::GVector3::fromString ( const QString &  string  ) 

Sets x, y and z according to values in the string. The format must be the same as provided by toString() (that is, a comma between the values)

double GCS::GVector3::length (  )  const

Calculates the length of the vector.

double GCS::GVector3::lengthsq (  )  const

Calculates the square-length of the vector.

GVector3 & GCS::GVector3::mul ( double  scalar  ) 

Scales the vector by given scalar.

GVector3 & GCS::GVector3::normalize (  ) 

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

Multiplies this vector with given scalar and returns the result.

Note:
This vector is not changed by the operation.

GCS::GVector3::operator double * (  ) 

Casting Operator

GVector3 GCS::GVector3::operator+ ( const GVector3 right  )  const

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

GVector3 & GCS::GVector3::operator+= ( const GVector3 right  ) 

Adds given vector to this vector.

GVector3 GCS::GVector3::operator- ( const GVector3 right  )  const

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

GVector3 & GCS::GVector3::operator-= ( const GVector3 right  ) 

Subtracts given vector from this vector.

GVector3 & GCS::GVector3::operator= ( const GVector3 original  ) 

Copies all members from given vector.

bool GCS::GVector3::operator== ( const GVector3 comp  )  const

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  ) 

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

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

GVector3 & GCS::GVector3::scaleXYZ ( double  x,
double  y,
double  z 
)

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

GVector3 & GCS::GVector3::scaleXYZ ( const GVector3 scale  ) 

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

GVector3 & GCS::GVector3::set ( const GVector3 original  ) 

Copies values from given vector.

GVector3 & GCS::GVector3::set ( double  x,
double  y,
double  z 
)

Sets the vector to given values.

GVector3 & GCS::GVector3::sub ( const GVector3 right  ) 

Mathematically subtracts given vector from this vector.

QString GCS::GVector3::toString (  )  const

Returns:
string representation of the vector in the form x, y, z

GVector3 & GCS::GVector3::turnAroundAxis ( const GVector3 axis,
double  angle_rad 
)

Turns this vector around given vector for given angle;

Parameters:
angle_rad angle in radians


Member Data Documentation

union { ... }

Vector data

double 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 files:
Generated on Thu Nov 16 07:49:36 2006 for G System by  doxygen 1.4.7