Vector3D Class Reference

Define all 3 vector operations we need. More...

#include <vector3d.h>

List of all members.

Public Member Functions

 Vector3D ()
 Vector3D (double p)
 Vector3D (double px, double py, double pz)
 Vector3D (const Vector3D &v)
Vector3D operator+ (const Vector3D &V) const
Vector3D operator- (const Vector3D &V) const
Vector3D operator * (const Vector3D &V) const
Vector3D operator/ (const Vector3D &V) const
Vector3D operator+ (const double &V) const
Vector3D operator- (const double &V) const
Vector3D operator * (const double &V) const
Vector3D operator/ (const double &V) const
Vector3D operator+ () const
Vector3D operator- () const
BOOL operator== (const Vector3D &V)
BOOL operator!= (const Vector3D &V)
Vector3Doperator+= (const Vector3D &V)
Vector3Doperator-= (const Vector3D &V)
Vector3Doperator *= (const Vector3D &V)
double xcomp () const
double ycomp () const
double zcomp () const
double Length () const
double SumSquares () const
double Dot (const Vector3D &p) const
double SumMult (const Vector3D &p) const
double SqrDist (const Vector3D &p) const
double DistanceTo (const Vector3D &p) const
Vector3D Mix (const Vector3D &mix, double t) const
void FaceForward (const Vector3D &p)
double Normalise ()
Vector3D NormaliseI ()
Vector3D Cross (const Vector3D &q) const

Static Public Member Functions

static Vector3D Half (const Vector3D &, const Vector3D &)
static Vector3D TorusUV (double srad, double trad, double u, double v)

Public Attributes

double x
double y
double z


Detailed Description

Define all 3 vector operations we need.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/08/94

Definition at line 120 of file vector3d.h.


Constructor & Destructor Documentation

Vector3D::Vector3D  )  [inline]
 

Definition at line 123 of file vector3d.h.

00123 { x=y=z=0; }

Vector3D::Vector3D double  p  )  [inline]
 

Definition at line 124 of file vector3d.h.

00124 { x=y=z=p; }

Vector3D::Vector3D double  px,
double  py,
double  pz
[inline]
 

Definition at line 125 of file vector3d.h.

00125 { x=px; y=py; z=pz; }

Vector3D::Vector3D const Vector3D v  )  [inline]
 

Definition at line 126 of file vector3d.h.

00126 { x=v.x; y=v.y; z=v.z; }


Member Function Documentation

Vector3D Vector3D::Cross const Vector3D q  )  const
 

Definition at line 167 of file vector3d.cpp.

00168 { 
00169    Vector3D r;
00170    r.x = y*q.z - z*q.y;
00171    r.y = z*q.x - x*q.z;
00172    r.z = x*q.y - y*q.x;
00173    return r;
00174 }

double Vector3D::DistanceTo const Vector3D p  )  const [inline]
 

Definition at line 157 of file vector3d.h.

00157 { return sqrt(SqrDist(p)); }

double Vector3D::Dot const Vector3D p  )  const [inline]
 

Definition at line 154 of file vector3d.h.

00154 { return ( x*p.x + y*p.y + z*p.z ); }

void Vector3D::FaceForward const Vector3D p  ) 
 

Definition at line 110 of file vector3d.cpp.

00111 {
00112     if (Dot(q)<0.0) return;
00113     x = -x;
00114     y = -y;
00115     z = -z;
00116 }

Vector3D Vector3D::Half const Vector3D ,
const Vector3D
[static]
 

Definition at line 161 of file vector3d.cpp.

00162 { 
00163     return ((p+q).NormaliseI());
00164 }

double Vector3D::Length  )  const [inline]
 

Definition at line 152 of file vector3d.h.

00152 { return ( sqrt(x*x + y*y + z*z) ); }

Vector3D Vector3D::Mix const Vector3D mix,
double  t
const [inline]
 

Definition at line 210 of file vector3d.h.

00211 {
00212     Vector3D v;
00213     v.x = (1.0-t)*x + t*mix.x;
00214     v.y = (1.0-t)*y + t*mix.y;
00215     v.z = (1.0-t)*z + t*mix.z;
00216     return v;
00217 }

double Vector3D::Normalise  ) 
 

Definition at line 119 of file vector3d.cpp.

00120 {
00121     double l,m;
00122     l = sqrt(x*x + y*y + z*z);
00123     if (l!=0) 
00124     {   
00125         m=1.0/l;
00126         x*=m; 
00127         y*=m; 
00128         z*=m;
00129     }
00130     else
00131     {   
00132         x=1.0;
00133         y=0;
00134         z=0;
00135     };
00136 
00137     return l;
00138 }

Vector3D Vector3D::NormaliseI  ) 
 

Definition at line 140 of file vector3d.cpp.

00141 {
00142     double l,m;
00143     l = sqrt(x*x + y*y + z*z);
00144     if (l!=0) 
00145     {   
00146         m=1.0/l;
00147         x*=m; 
00148         y*=m; 
00149         z*=m;
00150     }
00151     else
00152     {   
00153         x=0;
00154         y=0;
00155         z=0;
00156     };
00157 
00158     return *this;
00159 }

Vector3D Vector3D::operator * const double &  V  )  const [inline]
 

Definition at line 135 of file vector3d.h.

00135 { return Vector3D(x*V, y*V, z*V); }

Vector3D Vector3D::operator * const Vector3D V  )  const [inline]
 

Definition at line 130 of file vector3d.h.

00130 { return Vector3D(x*V.x, y*V.y, z*V.z); }

Vector3D & Vector3D::operator *= const Vector3D V  )  [inline]
 

Definition at line 202 of file vector3d.h.

00203 {
00204     x *= p.x;
00205     y *= p.y;
00206     z *= p.z;
00207     return *this;
00208 }

BOOL Vector3D::operator!= const Vector3D V  )  [inline]
 

Definition at line 142 of file vector3d.h.

00142 { return x!=V.x || y!=V.y || z!=V.z; }

Vector3D Vector3D::operator+  )  const [inline]
 

Definition at line 138 of file vector3d.h.

00138 { return Vector3D(+x, +y, +z); }

Vector3D Vector3D::operator+ const double &  V  )  const [inline]
 

Definition at line 133 of file vector3d.h.

00133 { return Vector3D(x+V, y+V, z+V); }

Vector3D Vector3D::operator+ const Vector3D V  )  const [inline]
 

Definition at line 128 of file vector3d.h.

00128 { return Vector3D(x+V.x, y+V.y, z+V.z); }

Vector3D & Vector3D::operator+= const Vector3D V  )  [inline]
 

Definition at line 186 of file vector3d.h.

00187 {
00188     x += p.x;
00189     y += p.y;
00190     z += p.z;
00191     return *this;
00192 }

Vector3D Vector3D::operator-  )  const [inline]
 

Definition at line 139 of file vector3d.h.

00139 { return Vector3D(-x, -y, -z); }

Vector3D Vector3D::operator- const double &  V  )  const [inline]
 

Definition at line 134 of file vector3d.h.

00134 { return Vector3D(x-V, y-V, z-V); }

Vector3D Vector3D::operator- const Vector3D V  )  const [inline]
 

Definition at line 129 of file vector3d.h.

00129 { return Vector3D(x-V.x, y-V.y, z-V.z); }

Vector3D & Vector3D::operator-= const Vector3D V  )  [inline]
 

Definition at line 194 of file vector3d.h.

00195 {
00196     x -= p.x;
00197     y -= p.y;
00198     z -= p.z;
00199     return *this;
00200 }

Vector3D Vector3D::operator/ const double &  V  )  const [inline]
 

Definition at line 136 of file vector3d.h.

00136 { return Vector3D(x/V, y/V, z/V); }

Vector3D Vector3D::operator/ const Vector3D V  )  const [inline]
 

Definition at line 131 of file vector3d.h.

00131 { return Vector3D(x/V.x, y/V.y, z/V.z); }

BOOL Vector3D::operator== const Vector3D V  )  [inline]
 

Definition at line 141 of file vector3d.h.

00141 { return x==V.x && y==V.y && z==V.z; }

double Vector3D::SqrDist const Vector3D p  )  const [inline]
 

Definition at line 156 of file vector3d.h.

00156 { return (p.x-x)*(p.x-x) + (p.y-y)*(p.y-y) + (p.z-z)*(p.z-z); }

double Vector3D::SumMult const Vector3D p  )  const [inline]
 

Definition at line 155 of file vector3d.h.

00155 { return ( x*p.x + y*p.y + z*p.z); }

double Vector3D::SumSquares  )  const [inline]
 

Definition at line 153 of file vector3d.h.

00153 { return ( x*x + y*y + z*z ); }

Vector3D Vector3D::TorusUV double  srad,
double  trad,
double  u,
double  v
[static]
 

Definition at line 177 of file vector3d.cpp.

00178 {
00179     Vector3D p;
00180     double theta,phi;
00181 
00182     theta = XS_2PI*u;
00183       phi = XS_2PI*v;
00184 
00185     p.x = srad + trad*cos(theta);
00186     p.y =        trad*sin(theta);
00187 
00188     p.z = p.x*sin(phi);
00189     p.x = p.x*cos(phi);
00190 
00191     // translate into the positive octant
00192     p.x += srad+trad;
00193     p.y += trad;
00194     p.z += srad+trad;
00195 
00196     return p;
00197 }

double Vector3D::xcomp  )  const [inline]
 

Definition at line 148 of file vector3d.h.

00148 { return x; }

double Vector3D::ycomp  )  const [inline]
 

Definition at line 149 of file vector3d.h.

00149 { return y; }

double Vector3D::zcomp  )  const [inline]
 

Definition at line 150 of file vector3d.h.

00150 { return z; }


Member Data Documentation

double Vector3D::x
 

Definition at line 174 of file vector3d.h.

double Vector3D::y
 

Definition at line 175 of file vector3d.h.

double Vector3D::z
 

Definition at line 176 of file vector3d.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:02:55 2007 for Camelot by  doxygen 1.4.4