NLMISC::CVectorD Class Reference

#include <vectord.h>


Detailed Description

A 3D vector of double.
Author:
Lionel Berenguier

Nevrax France

Date:
2000

Definition at line 44 of file vectord.h.

Public Member Functions

Misc.
CVector asVector () const
void cartesianToSpheric (double &r, double &theta, double &phi) const
void copyTo (CVector &dest) const
bool isNull () const
 operator CVector () const
bool operator!= (const CVectorD &v) const
CVectorDoperator= (const CVector &v)
bool operator== (const CVectorD &v) const
void serial (IStream &f)
void set (double _x, double _y, double _z)
void sphericToCartesian (double r, double theta, double phi)
Object.
 CVectorD (const CVectorD &v)
 Copy Constructor.

 CVectorD (const CVector &v)
 Constructor with a CVector.

 CVectorD (double _x, double _y, double _z)
 Constructor .

 CVectorD ()
 Constructor wich do nothing.

Advanced Maths.
double norm () const
 Return the norm of the vector.

void normalize ()
 Normalize the vector.

CVectorD normed () const
 Return the vector normalized.

double operator * (const CVectorD &v) const
 Dot product.

CVectorD operator^ (const CVectorD &v) const
double sqrnorm () const
 Return the square of the norm of the vector.

Base Maths.
CVectorD operator * (double f) const
CVectorDoperator *= (double f)
CVectorD operator+ (const CVectorD &v) const
CVectorDoperator+= (const CVectorD &v)
CVectorD operator- () const
CVectorD operator- (const CVectorD &v) const
CVectorDoperator-= (const CVectorD &v)
CVectorD operator/ (double f) const
CVectorDoperator/= (double f)

Data Fields

double x
double y
double z

Static Public Attributes

const CVectorD I
 I vector (1,0,0).

const CVectorD J
 J vector (0,1,0).

const CVectorD K
 K vector (0,0,1).

const CVectorD Null
 Null vector (0,0,0).


Friends

CVectorD operator * (double f, const CVectorD &v0)


Constructor & Destructor Documentation

NLMISC::CVectorD::CVectorD  )  [inline]
 

Constructor wich do nothing.

Definition at line 63 of file vectord.h.

Referenced by operator-().

00063 {}

NLMISC::CVectorD::CVectorD double  _x,
double  _y,
double  _z
[inline]
 

Constructor .

Definition at line 65 of file vectord.h.

References x, y, and z.

00065 : x(_x), y(_y), z(_z) {}

NLMISC::CVectorD::CVectorD const CVector v  )  [inline]
 

Constructor with a CVector.

Definition at line 67 of file vectord.h.

References v, x, y, and z.

00067 : x(v.x), y(v.y), z(v.z) {}

NLMISC::CVectorD::CVectorD const CVectorD v  )  [inline]
 

Copy Constructor.

Definition at line 69 of file vectord.h.

References v, x, y, and z.

00069 : x(v.x), y(v.y), z(v.z) {}


Member Function Documentation

CVector NLMISC::CVectorD::asVector  )  const [inline]
 

Definition at line 191 of file vectord_inline.h.

References x, y, and z.

00192 {
00193         return CVector((float) x, (float) y, (float) z);
00194 }

void NLMISC::CVectorD::cartesianToSpheric double &  r,
double &  theta,
double &  phi
const [inline]
 

Get the sphreic coordinates of the vector. See sphericToCartesian() to know coordinates conventions.

See also:
sphericToCartesian()

Definition at line 152 of file vectord_inline.h.

References NLMISC::clamp(), norm(), normed(), r, and v.

00153 {
00154         CVectorD v;
00155 
00156         r= norm();
00157         v= normed();
00158 
00159         // phi E [-PI/2 et PI/2]
00160         clamp(v.z, -1.0, 1.0);
00161         phi=asin(v.z);
00162 
00163         // theta [-PI,PI]
00164         theta=atan2(v.y,v.x);
00165 }

void NLMISC::CVectorD::copyTo CVector dest  )  const [inline]
 

Definition at line 187 of file vectord_inline.h.

References NLMISC::CVector::set(), x, y, and z.

00188 {
00189         dest.set((float) x, (float) y, (float) z);
00190 }

bool NLMISC::CVectorD::isNull  )  const [inline]
 

Definition at line 148 of file vectord_inline.h.

00149 {
00150         return *this==CVectorD::Null;
00151 }

double NLMISC::CVectorD::norm  )  const [inline]
 

Return the norm of the vector.

Definition at line 115 of file vectord_inline.h.

References x, y, and z.

Referenced by cartesianToSpheric(), NL3D::CAnimationOptimizer::nearlySameVector(), normalize(), and NLPACS::CPrimitiveWorldImage::reaction().

00116 {
00117         return (double)sqrt(x*x + y*y + z*z);
00118 }

void NLMISC::CVectorD::normalize  )  [inline]
 

Normalize the vector.

Definition at line 119 of file vectord_inline.h.

References norm().

Referenced by NLPACS::CPrimitiveWorldImage::evalCollisionOCoverOC(), NLPACS::CPrimitiveWorldImage::evalCollisionPoverOC(), NLPACS::CPrimitiveWorldImage::evalCollisionSoverOC(), normed(), and NLAIAGENT::IVector::unit().

00120 {
00121         double  n=norm();
00122         if(n)
00123                 *this/=n;
00124 }

CVectorD NLMISC::CVectorD::normed  )  const [inline]
 

Return the vector normalized.

Definition at line 125 of file vectord_inline.h.

References normalize().

Referenced by cartesianToSpheric().

00126 {
00127         CVectorD        ret;
00128         ret= *this;
00129         ret.normalize();
00130         return ret;
00131 }

double NLMISC::CVectorD::operator * const CVectorD v  )  const [inline]
 

Dot product.

Definition at line 97 of file vectord_inline.h.

References v, x, y, and z.

00098 {
00099         return x*v.x + y*v.y + z*v.z;
00100 }

CVectorD NLMISC::CVectorD::operator * double  f  )  const [inline]
 

Definition at line 75 of file vectord_inline.h.

References x, y, and z.

00076 {
00077         CVectorD        ret(x*f, y*f, z*f);
00078         return ret;
00079 }

CVectorD & NLMISC::CVectorD::operator *= double  f  )  [inline]
 

Definition at line 54 of file vectord_inline.h.

References x, y, and z.

00055 {
00056         x*=f;
00057         y*=f;
00058         z*=f;
00059         return *this;
00060 }

NLMISC::CVectorD::operator CVector  )  const [inline]
 

Definition at line 179 of file vectord_inline.h.

References x, y, and z.

00180 {
00181         return CVector((float)x, (float)y, (float)z);
00182 }

bool NLMISC::CVectorD::operator!= const CVectorD v  )  const [inline]
 

Definition at line 144 of file vectord_inline.h.

References v.

00145 {
00146         return !(*this==v);
00147 }

CVectorD NLMISC::CVectorD::operator+ const CVectorD v  )  const [inline]
 

Definition at line 65 of file vectord_inline.h.

References v, x, y, and z.

00066 {
00067         CVectorD        ret(x+v.x, y+v.y, z+v.z);
00068         return ret;
00069 }

CVectorD & NLMISC::CVectorD::operator+= const CVectorD v  )  [inline]
 

Definition at line 40 of file vectord_inline.h.

References v, x, y, and z.

00041 {
00042         x+=v.x;
00043         y+=v.y;
00044         z+=v.z;
00045         return *this;
00046 }

CVectorD NLMISC::CVectorD::operator-  )  const [inline]
 

Definition at line 84 of file vectord_inline.h.

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

00085 {
00086         return CVectorD(-x,-y,-z);
00087 }

CVectorD NLMISC::CVectorD::operator- const CVectorD v  )  const [inline]
 

Definition at line 70 of file vectord_inline.h.

References v, x, y, and z.

00071 {
00072         CVectorD        ret(x-v.x, y-v.y, z-v.z);
00073         return ret;
00074 }

CVectorD & NLMISC::CVectorD::operator-= const CVectorD v  )  [inline]
 

Definition at line 47 of file vectord_inline.h.

References v, x, y, and z.

00048 {
00049         x-=v.x;
00050         y-=v.y;
00051         z-=v.z;
00052         return *this;
00053 }

CVectorD NLMISC::CVectorD::operator/ double  f  )  const [inline]
 

Definition at line 80 of file vectord_inline.h.

00081 {
00082         return *this*(1.0f/f);
00083 }

CVectorD & NLMISC::CVectorD::operator/= double  f  )  [inline]
 

Definition at line 61 of file vectord_inline.h.

00062 {
00063         return *this*= (1.0f/f);
00064 }

CVectorD & NLMISC::CVectorD::operator= const CVector v  )  [inline]
 

Definition at line 172 of file vectord_inline.h.

References v, x, y, and z.

00173 {
00174         x=v.x;
00175         y=v.y;
00176         z=v.z;
00177         return *this;
00178 }

bool NLMISC::CVectorD::operator== const CVectorD v  )  const [inline]
 

Definition at line 140 of file vectord_inline.h.

References v, x, y, and z.

00141 {
00142         return x==v.x && y==v.y && z==v.z;
00143 }

CVectorD NLMISC::CVectorD::operator^ const CVectorD v  )  const [inline]
 

Cross product. compute the cross product *this ^ v.

Definition at line 101 of file vectord_inline.h.

References v, x, x, y, y, z, and z.

00102 {
00103         CVectorD        ret;
00104 
00105         ret.x= y*v.z - z*v.y;
00106         ret.y= z*v.x - x*v.z;
00107         ret.z= x*v.y - y*v.x;
00108 
00109         return ret;
00110 }

void NLMISC::CVectorD::serial IStream f  )  [inline]
 

Definition at line 183 of file vectord_inline.h.

References NLMISC::IStream::serial(), x, y, and z.

00184 {
00185         f.serial(x,y,z);
00186 }

void NLMISC::CVectorD::set double  _x,
double  _y,
double  _z
[inline]
 

Definition at line 136 of file vectord_inline.h.

References x, y, and z.

Referenced by NL3D::CBezierPatch::evalDouble(), NLPACS::CPrimitiveWorldImage::reaction(), and NLPACS::CGlobalRetriever::testCollisionWithCollisionChains().

00137 {
00138         x=_x; y=_y; z=_z;
00139 }

void NLMISC::CVectorD::sphericToCartesian double  r,
double  theta,
double  phi
[inline]
 

Setup the vector with spheric coordinates. sphericToCartesian(1,0,0) build the I vector ((1,0,0)). the formula is:
x= r*cos(theta)*cos(phi)
y= r*sin(theta)*cos(phi)
z= r*sin(phi)

See also:
cartesianToSpheric()

Definition at line 166 of file vectord_inline.h.

References r, x, y, and z.

00167 {
00168         x= r*cos(theta)*cos(phi);
00169         y= r*sin(theta)*cos(phi);
00170         z= r*sin(phi);
00171 }

double NLMISC::CVectorD::sqrnorm  )  const [inline]
 

Return the square of the norm of the vector.

Definition at line 111 of file vectord_inline.h.

References x, y, and z.

00112 {
00113         return (double)(x*x + y*y + z*z);
00114 }


Friends And Related Function Documentation

CVectorD operator * double  f,
const CVectorD v0
[friend]
 

Definition at line 88 of file vectord_inline.h.

00089 {
00090         CVectorD        ret(v.x*f, v.y*f, v.z*f);
00091         return ret;
00092 }


Field Documentation

const CVectorD NLMISC::CVectorD::I [static]
 

I vector (1,0,0).

const CVectorD NLMISC::CVectorD::J [static]
 

J vector (0,1,0).

const CVectorD NLMISC::CVectorD::K [static]
 

K vector (0,0,1).

const CVectorD NLMISC::CVectorD::Null [static]
 

Null vector (0,0,0).

double NLMISC::CVectorD::x
 

Definition at line 47 of file vectord.h.

Referenced by NL3D::CLodCharacterShape::addAnim(), NLPACS::CPrimitiveWorldImage::evalCollisionOCoverOC(), NLPACS::CPrimitiveWorldImage::evalCollisionPoverOC(), NLPACS::CPrimitiveWorldImage::evalCollisionPoverS(), NLPACS::CPrimitiveWorldImage::evalCollisionSoverOC(), NLPACS::CRetrieverInstance::getLocalPosition(), NL3D::mulAddD(), operator^(), NLPACS::CPrimitiveWorldImage::precalcBB(), NLPACS::CPrimitiveWorldImage::precalcPos(), NLPACS::CRetrieverInstance::retrievePosition(), NLPACS::CGlobalRetriever::retrievePosition(), NLPACS::CPrimitiveWorldImage::CPosition::setGlobalPosKeepZ(), NLAIAGENT::IVector::squareLength(), and NLAIAGENT::IVector::x().

double NLMISC::CVectorD::y
 

Definition at line 47 of file vectord.h.

Referenced by NL3D::CLodCharacterShape::addAnim(), NLPACS::CPrimitiveWorldImage::evalCollisionOCoverOC(), NLPACS::CPrimitiveWorldImage::evalCollisionPoverOC(), NLPACS::CPrimitiveWorldImage::evalCollisionPoverS(), NLPACS::CPrimitiveWorldImage::evalCollisionSoverOC(), NLPACS::CRetrieverInstance::getLocalPosition(), NL3D::mulAddD(), operator^(), NLPACS::CPrimitiveWorldImage::precalcBB(), NLPACS::CPrimitiveWorldImage::precalcPos(), NLPACS::CRetrieverInstance::retrievePosition(), NLPACS::CGlobalRetriever::retrievePosition(), NLPACS::CPrimitiveWorldImage::CPosition::setGlobalPosKeepZ(), NLAIAGENT::IVector::squareLength(), and NLAIAGENT::IVector::y().

double NLMISC::CVectorD::z
 

Definition at line 47 of file vectord.h.

Referenced by NL3D::CLodCharacterShape::addAnim(), NLPACS::CPrimitiveWorldImage::evalCollisionOCoverOC(), NLPACS::CPrimitiveWorldImage::evalCollisionPoverOC(), NLPACS::CPrimitiveWorldImage::evalCollisionPoverS(), NLPACS::CPrimitiveWorldImage::evalCollisionSoverOC(), NLPACS::CRetrieverInstance::getLocalPosition(), NL3D::mulAddD(), operator^(), NLPACS::CRetrieverInstance::retrievePosition(), NLPACS::CGlobalRetriever::retrievePosition(), NLAIAGENT::IVector::squareLength(), and NLAIAGENT::IVector::z().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:42:49 2004 for NeL by doxygen 1.3.6