Al's Programming Resource Homepage  Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

VECTOR Class Reference

#include <vector.h>

List of all members.

Public Methods

 VECTOR (float sx=0, float sy=0, float sz=0)
 VECTOR (const VECTOR &Vector)
 ~VECTOR ()
float GetMagnitude ()
void Normalize ()
void Reset ()
void Set (float sx, float sy, float sz)
void CrossVector (VECTOR vect)
float DotProduct (VECTOR vect)
const bool nearlyEquals (const VECTOR &v, const SCALAR e) const
const VECTOR cross (const VECTOR &v) const
const SCALAR dot (const VECTOR &v) const
const SCALAR length () const
const VECTOR unit () const
void normalize ()
SCALARoperator[] (const long i)
const bool operator== (const VECTOR &v) const
const bool operator!= (const VECTOR &v) const
const VECTOR operator- () const
const VECTOR & operator= (const VECTOR &v)
const VECTOR & operator+= (const VECTOR &v)
const VECTOR & operator-= (const VECTOR &v)
const VECTOR & operator *= (const SCALAR &s)
const VECTOR & operator/= (const SCALAR &s)
const VECTOR operator+ (const VECTOR &v) const
const VECTOR operator- (const VECTOR &v) const
const VECTOR operator * (const SCALAR &s) const
const VECTOR operator/ (SCALAR s) const

Public Attributes

float x
float y
float z

Friends

const VECTOR operator * (const SCALAR &s, const VECTOR &v)


Constructor & Destructor Documentation

VECTOR::VECTOR float    sx = 0,
float    sy = 0,
float    sz = 0
 

Definition at line 6 of file vector.cpp.

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

00007 :
00008     x(sx),
00009     y(sy),
00010     z(sz)
00011 {
00012 }

VECTOR::VECTOR const VECTOR &    Vector
 

Definition at line 14 of file vector.cpp.

References x, y, and z.

00015 {
00016     x = Vector.x;
00017     y = Vector.y;
00018     z = Vector.z;
00019 }

VECTOR::~VECTOR  
 

Definition at line 21 of file vector.cpp.

00022 {
00023 }


Member Function Documentation

const VECTOR VECTOR::cross const VECTOR &    v const [inline]
 

Definition at line 30 of file vector.h.

References VECTOR(), x, y, and z.

00031         {
00032             //Davis, Snider, "Introduction to Vector Analysis", p. 44
00033             return VECTOR( y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x );
00034         }

void VECTOR::CrossVector VECTOR    vect
 

Definition at line 39 of file vector.cpp.

References x, y, and z.

Referenced by QUAT::MultQuat().

00040 {
00041       VECTOR temp = *this;
00042       x = vect.y * temp.z - vect.z * temp.y;
00043       y = vect.z * temp.x - vect.x * temp.z;
00044       z = vect.x * temp.y - vect.y * temp.x;
00045 }

const SCALAR VECTOR::dot const VECTOR &    v const [inline]
 

Definition at line 37 of file vector.h.

References SCALAR, x, y, and z.

Referenced by DotProduct().

00038         {
00039             return x*v.x + y*v.y + z*v.z;
00040         }

float VECTOR::DotProduct VECTOR    vect
 

Definition at line 32 of file vector.cpp.

References dot(), x, y, and z.

Referenced by QUAT::MultQuat().

00033 {
00034       float dot;
00035       dot = vect.x * x + vect.y * y + vect.z * z;
00036       return dot;
00037 }

float VECTOR::GetMagnitude  
 

Definition at line 47 of file vector.cpp.

References x, y, and z.

Referenced by Normalize(), and SelectPolygon().

00048 {
00049     float magnitude = (float)sqrt(x * x + y * y + z * z);
00050     if (magnitude != 0.0f)
00051         return magnitude;
00052     else
00053         return 0.000001;
00054 }

const SCALAR VECTOR::length   const [inline]
 

Definition at line 43 of file vector.h.

References SCALAR.

Referenced by normalize(), and unit().

00044         {
00045             return (SCALAR)sqrt( (double)this->dot(*this) );
00046         }

const bool VECTOR::nearlyEquals const VECTOR &    v,
const SCALAR    e
const [inline]
 

Definition at line 24 of file vector.h.

References SCALAR, x, y, and z.

00025         {
00026             return fabs(x-v.x)<e && fabs(y-v.y)<e && fabs(z-v.z)<e;
00027         }

void VECTOR::normalize   [inline]
 

Definition at line 55 of file vector.h.

References length().

00056         {
00057             (*this) /= length();
00058         }

void VECTOR::Normalize  
 

Definition at line 56 of file vector.cpp.

References GetMagnitude(), x, y, and z.

00057 {
00058     float magnitude = this->GetMagnitude();
00059     x /= magnitude;
00060     y /= magnitude;
00061     z /= magnitude;
00062 }

const VECTOR VECTOR::operator * const SCALAR   s const [inline]
 

Definition at line 149 of file vector.h.

References SCALAR, VECTOR(), x, y, and z.

00150         {
00151             return VECTOR( x*s, y*s, z*s );
00152         }

const VECTOR& VECTOR::operator *= const SCALAR   s [inline]
 

Definition at line 118 of file vector.h.

References SCALAR, x, y, and z.

00119         {
00120             x*=s;
00121             y*=s;
00122             z*=s;
00123             return *this;
00124         }

const bool VECTOR::operator!= const VECTOR &    v const [inline]
 

Definition at line 79 of file vector.h.

00080         {
00081             return !(v == *this);
00082         }

const VECTOR VECTOR::operator+ const VECTOR &    v const [inline]
 

Definition at line 137 of file vector.h.

References VECTOR(), x, y, and z.

00138         {
00139             return VECTOR(x + v.x, y + v.y, z + v.z);
00140         }

const VECTOR& VECTOR::operator+= const VECTOR &    v [inline]
 

Definition at line 100 of file vector.h.

References x, y, and z.

00101         {
00102             x+=v.x;
00103             y+=v.y;
00104             z+=v.z;
00105             return *this;
00106         }

const VECTOR VECTOR::operator- const VECTOR &    v const [inline]
 

Definition at line 143 of file vector.h.

References VECTOR(), x, y, and z.

00144         {
00145             return VECTOR(x - v.x, y - v.y, z - v.z);
00146         }

const VECTOR VECTOR::operator-   const [inline]
 

Definition at line 85 of file vector.h.

References VECTOR(), x, y, and z.

00086         {
00087             return VECTOR( -x, -y, -z );
00088         }

const VECTOR& VECTOR::operator-= const VECTOR &    v [inline]
 

Definition at line 109 of file vector.h.

References x, y, and z.

00110         {
00111             x-=v.x;
00112             y-=v.y;
00113             z-=v.z;
00114             return *this;
00115         }

const VECTOR VECTOR::operator/ SCALAR    s const [inline]
 

Definition at line 161 of file vector.h.

References SCALAR, VECTOR(), x, y, and z.

00162         {
00163             s = 1/s;
00164             return VECTOR( s*x, s*y, s*z );
00165         }

const VECTOR& VECTOR::operator/= const SCALAR   s [inline]
 

Definition at line 127 of file vector.h.

References SCALAR, x, y, and z.

00128         {
00129             const SCALAR r = 1 / s;
00130             x *= r;
00131             y *= r;
00132             z *= r;
00133             return *this;
00134         }

const VECTOR& VECTOR::operator= const VECTOR &    v [inline]
 

Definition at line 91 of file vector.h.

References x, y, and z.

00092         {
00093             x = v.x;
00094             y = v.y;
00095             z = v.z;
00096             return *this;
00097         }

const bool VECTOR::operator== const VECTOR &    v const [inline]
 

Definition at line 74 of file vector.h.

References x, y, and z.

00075         {
00076             return (v.x==x && v.y==y && v.z==z);
00077         }

SCALAR& VECTOR::operator[] const long    i [inline]
 

Definition at line 68 of file vector.h.

References SCALAR, and x.

00069         {
00070             return *((&x) + i);
00071         }

void VECTOR::Reset  
 

Definition at line 25 of file vector.cpp.

References x, y, and z.

Referenced by OBJECT::Reset(), and CAMERA::Reset().

00026 {
00027     x = 0;
00028     y = 0;
00029     z = 0;
00030 }

void VECTOR::Set float    sx,
float    sy,
float    sz
[inline]
 

Definition at line 19 of file vector.h.

References x, y, and z.

Referenced by LIGHT::Reset().

00019 {x = sx, y = sy, z = sz;}

const VECTOR VECTOR::unit   const [inline]
 

Definition at line 49 of file vector.h.

References length().

00050         {
00051             return (*this) / length();
00052         }


Friends And Related Function Documentation

const VECTOR operator * const SCALAR   s,
const VECTOR &    v
[friend]
 

Definition at line 155 of file vector.h.

00156         {
00157             return v * s;
00158         }


Member Data Documentation

float VECTOR::x
 

Definition at line 61 of file vector.h.

Referenced by LIGHT::Apply(), CAMERA::Apply(), AxisAngleToMatrix(), QUAT::AxisAngleToQuat(), CheckClipPlanes(), CheckForCollision(), CheckPointInSphere(), CheckPointInTriangle(), ClassifyPoint(), ClosestPointOnLine(), ClosestPointOnPolygon(), cross(), CrossVector(), CrossVector(), dot(), DotProduct(), DotProduct(), DrawGLScene(), DrawLensFlare(), DrawSkybox(), GetEdgeVector(), GetMagnitude(), GetNorm(), POLYGON::GetNormal(), GetNormal(), GetUnitVector(), OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::GetZUnit(), IntersectRaySphere(), IsZeroVector(), line_plane_collision(), MagnitudeVector(), MATRIX::MatrixFromAxisAngle(), OBJECT::MoveX(), OBJECT::MoveY(), OBJECT::MoveZ(), QUAT::MultQuat(), MultQuat(), nearlyEquals(), Normalize(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator=(), operator==(), operator[](), Reset(), LIGHT::Reset(), SelectPolygon(), Set(), SetGLWorld(), SetLength(), POLYGON::SetNormal(), TangentPlaneNormalOfEllipsoid(), VECTOR(), VERTEX::VERTEX(), and Wedge().

float VECTOR::y
 

Definition at line 62 of file vector.h.

Referenced by LIGHT::Apply(), CAMERA::Apply(), AxisAngleToMatrix(), QUAT::AxisAngleToQuat(), CheckClipPlanes(), CheckForCollision(), CheckPointInSphere(), CheckPointInTriangle(), ClassifyPoint(), ClosestPointOnLine(), ClosestPointOnPolygon(), cross(), CrossVector(), CrossVector(), dot(), DotProduct(), DotProduct(), DrawGLScene(), DrawSkybox(), GetEdgeVector(), GetMagnitude(), GetNorm(), POLYGON::GetNormal(), GetNormal(), GetUnitVector(), OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::GetZUnit(), IntersectRaySphere(), IsZeroVector(), line_plane_collision(), MagnitudeVector(), MATRIX::MatrixFromAxisAngle(), OBJECT::MoveX(), OBJECT::MoveY(), OBJECT::MoveZ(), QUAT::MultQuat(), MultQuat(), nearlyEquals(), Normalize(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator=(), operator==(), Reset(), LIGHT::Reset(), SelectPolygon(), Set(), SetGLWorld(), SetLength(), POLYGON::SetNormal(), TangentPlaneNormalOfEllipsoid(), VECTOR(), VERTEX::VERTEX(), and Wedge().

float VECTOR::z
 

Definition at line 63 of file vector.h.

Referenced by LIGHT::Apply(), CAMERA::Apply(), AxisAngleToMatrix(), QUAT::AxisAngleToQuat(), CheckClipPlanes(), CheckForCollision(), CheckPointInSphere(), CheckPointInTriangle(), ClassifyPoint(), ClosestPointOnLine(), ClosestPointOnPolygon(), cross(), CrossVector(), CrossVector(), dot(), DotProduct(), DotProduct(), DrawGLScene(), DrawSkybox(), GetEdgeVector(), GetMagnitude(), GetNorm(), POLYGON::GetNormal(), GetNormal(), GetUnitVector(), OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::GetZUnit(), IntersectRaySphere(), IsZeroVector(), line_plane_collision(), MagnitudeVector(), MATRIX::MatrixFromAxisAngle(), OBJECT::MoveX(), OBJECT::MoveY(), OBJECT::MoveZ(), QUAT::MultQuat(), MultQuat(), nearlyEquals(), Normalize(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator=(), operator==(), Reset(), LIGHT::Reset(), SelectPolygon(), Set(), SetGLWorld(), SetLength(), POLYGON::SetNormal(), TangentPlaneNormalOfEllipsoid(), VECTOR(), VERTEX::VERTEX(), and Wedge().


The documentation for this class was generated from the following files:
Generated on Fri Dec 23 05:21:00 2005 for Polygon Selection by doxygen1.2.15