GClasses

GClasses::G3DVector Class Reference

Represents a 3D vector. More...

#include <G3D.h>

List of all members.

Public Member Functions

 G3DVector ()
 G3DVector (const G3DVector *pThat)
 Copies the values from pThat.
 G3DVector (G3DReal x, G3DReal y, G3DReal z)
 Initializes the values to <x,y,z>
G3DRealvals ()
 Returns the vector as an array of reals.
GDomNodeserialize (GDom *pDoc)
 Marshal this object into a DOM, which can then be converted to a variety of serial formats.
void deserialize (GDomNode *pNode)
 Load this object from a DOM.
bool isEqual (const G3DVector &that) const
 Returns true iff all three elements are equal.
void copy (const G3DVector *pThat)
 Makes a copy of pThat.
void set (G3DReal x, G3DReal y, G3DReal z)
 Sets the values of this vector.
void normalize ()
 Normalizes this vector.
void makeRandom (GRand *pRand)
 Picks a random vector from a spherical distribution.
G3DReal squaredDist (const G3DVector *pThat) const
 returns the squared distance between this and pThat
double squaredMag () const
 returns the squared magnitude of this vector
void add (const G3DVector *pThat)
 adds pThat to this
void add (G3DReal mag, const G3DVector *pThat)
 adds mag * pThat to this
void add (G3DReal dx, G3DReal dy, G3DReal dz)
void subtract (const G3DVector *pThat)
 subtracts pThat from this
void multiply (G3DReal mag)
 multiplies this by mag
void multiply (G3DMatrix *pMatrix, G3DVector *pVector)
 this = pMatrix * pVector
G3DReal dotProduct (const G3DVector *pThat)
 returns the dot product of this and that
void crossProduct (G3DVector *pA, G3DVector *pB)
 this = pA x pB
void triangleNormal (const G3DVector *pPoint1, const G3DVector *pPoint2, const G3DVector *pPoint3)
 Sets this to the normal vector of the triangle specified by three points.
void planeEquation (const G3DVector *pPoint1, const G3DVector *pPoint2, const G3DVector *pPoint3, G3DReal *pOutD)
 Computes the plane equation (ax + by + cz + d = 0) of the specified triangle. this = <a, b, c> and *pOutD = d.
void reflectionVector (G3DVector *pRay, G3DVector *pNormal)
 Sets this to the reflection of pRay on a surface with normal vector pNormal.
void yawAndPitch (G3DReal *pYaw, G3DReal *pPitch) const
 *pYaw and *pPitch are in radians
void fromYawAndPitch (G3DReal dYaw, G3DReal dPitch)
 dYaw and dPitch are in radians

Public Attributes

G3DReal m_vals [3]

Detailed Description

Represents a 3D vector.


Constructor & Destructor Documentation

GClasses::G3DVector::G3DVector ( ) [inline]
GClasses::G3DVector::G3DVector ( const G3DVector pThat) [inline]

Copies the values from pThat.

GClasses::G3DVector::G3DVector ( G3DReal  x,
G3DReal  y,
G3DReal  z 
) [inline]

Initializes the values to <x,y,z>


Member Function Documentation

void GClasses::G3DVector::add ( const G3DVector pThat) [inline]

adds pThat to this

void GClasses::G3DVector::add ( G3DReal  mag,
const G3DVector pThat 
) [inline]

adds mag * pThat to this

void GClasses::G3DVector::add ( G3DReal  dx,
G3DReal  dy,
G3DReal  dz 
) [inline]
void GClasses::G3DVector::copy ( const G3DVector pThat) [inline]

Makes a copy of pThat.

void GClasses::G3DVector::crossProduct ( G3DVector pA,
G3DVector pB 
) [inline]

this = pA x pB

void GClasses::G3DVector::deserialize ( GDomNode pNode)

Load this object from a DOM.

G3DReal GClasses::G3DVector::dotProduct ( const G3DVector pThat) [inline]

returns the dot product of this and that

void GClasses::G3DVector::fromYawAndPitch ( G3DReal  dYaw,
G3DReal  dPitch 
) [inline]

dYaw and dPitch are in radians

bool GClasses::G3DVector::isEqual ( const G3DVector that) const [inline]

Returns true iff all three elements are equal.

void GClasses::G3DVector::makeRandom ( GRand pRand)

Picks a random vector from a spherical distribution.

void GClasses::G3DVector::multiply ( G3DMatrix pMatrix,
G3DVector pVector 
)

this = pMatrix * pVector

void GClasses::G3DVector::multiply ( G3DReal  mag) [inline]

multiplies this by mag

void GClasses::G3DVector::normalize ( ) [inline]

Normalizes this vector.

void GClasses::G3DVector::planeEquation ( const G3DVector pPoint1,
const G3DVector pPoint2,
const G3DVector pPoint3,
G3DReal pOutD 
) [inline]

Computes the plane equation (ax + by + cz + d = 0) of the specified triangle. this = <a, b, c> and *pOutD = d.

void GClasses::G3DVector::reflectionVector ( G3DVector pRay,
G3DVector pNormal 
)

Sets this to the reflection of pRay on a surface with normal vector pNormal.

GDomNode* GClasses::G3DVector::serialize ( GDom pDoc)

Marshal this object into a DOM, which can then be converted to a variety of serial formats.

void GClasses::G3DVector::set ( G3DReal  x,
G3DReal  y,
G3DReal  z 
) [inline]

Sets the values of this vector.

G3DReal GClasses::G3DVector::squaredDist ( const G3DVector pThat) const [inline]

returns the squared distance between this and pThat

double GClasses::G3DVector::squaredMag ( ) const [inline]

returns the squared magnitude of this vector

void GClasses::G3DVector::subtract ( const G3DVector pThat) [inline]

subtracts pThat from this

void GClasses::G3DVector::triangleNormal ( const G3DVector pPoint1,
const G3DVector pPoint2,
const G3DVector pPoint3 
) [inline]

Sets this to the normal vector of the triangle specified by three points.

G3DReal* GClasses::G3DVector::vals ( ) [inline]

Returns the vector as an array of reals.

void GClasses::G3DVector::yawAndPitch ( G3DReal pYaw,
G3DReal pPitch 
) const

*pYaw and *pPitch are in radians


Member Data Documentation