NLMISC::CVector2d Class Reference

#include <vector_2d.h>


Detailed Description

A 2D vector of double.
Author:
Lionel Berenguier

Nevrax France

Date:
2001

Definition at line 48 of file vector_2d.h.

Public Member Functions

Object.
 CVector2d (const CVector2f &v)
 Constructor with a CVector2f.

 CVector2d (const CVector2d &v)
 Copy Constructor.

 CVector2d (double _x, double _y)
 Constructor .

 CVector2d ()
 Constructor wich do nothing.

Misc.
bool isNull () const
void maxof (const CVector2d &a, const CVector2d &b)
 Set all vector x/y/z as maximum of a/b x/y/z (respectively).

void minof (const CVector2d &a, const CVector2d &b)
 Set all vector x/y/z as minimum of a/b x/y/z (respectively).

bool operator!= (const CVector2d &v) const
bool operator== (const CVector2d &v) const
void serial (NLMISC::IStream &f)
 serial.

void set (double _x, double _y)
Advanced Maths.
double norm () const
 Return the norm of the vector.

void normalize ()
 Normalize the vector.

CVector2d normed () const
 Return the vector normalized.

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

double sqrnorm () const
 Return the square of the norm of the vector.

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

Data Fields

double x
double y

Friends

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


Constructor & Destructor Documentation

NLMISC::CVector2d::CVector2d  )  [inline]
 

Constructor wich do nothing.

Definition at line 59 of file vector_2d.h.

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

00059 {}

NLMISC::CVector2d::CVector2d double  _x,
double  _y
[inline]
 

Constructor .

Definition at line 61 of file vector_2d.h.

References x, and y.

00061 : x(_x), y(_y) {}

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

Copy Constructor.

Definition at line 63 of file vector_2d.h.

References v, x, and y.

00063 : x(v.x), y(v.y) {}

NLMISC::CVector2d::CVector2d const CVector2f v  )  [inline]
 

Constructor with a CVector2f.

Definition at line 65 of file vector_2d.h.

References v, x, and y.

00065 : x(v.x), y(v.y) {}


Member Function Documentation

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

Definition at line 111 of file vector_2d.h.

References x, and y.

00111 {return x==0.0f && y==0.0f;}

void NLMISC::CVector2d::maxof const CVector2d a,
const CVector2d b
[inline]
 

Set all vector x/y/z as maximum of a/b x/y/z (respectively).

Definition at line 119 of file vector_2d.h.

References x, x, y, and y.

00120         {
00121                 x= std::max(a.x, b.x);
00122                 y= std::max(a.y, b.y);
00123         }

void NLMISC::CVector2d::minof const CVector2d a,
const CVector2d b
[inline]
 

Set all vector x/y/z as minimum of a/b x/y/z (respectively).

Definition at line 113 of file vector_2d.h.

References min, x, x, y, and y.

00114         {
00115                 x= std::min(a.x, b.x);
00116                 y= std::min(a.y, b.y);
00117         }

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

Return the norm of the vector.

Definition at line 87 of file vector_2d.h.

References sqrnorm().

Referenced by normalize().

00087 {return (double)sqrt(sqrnorm());}

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

Normalize the vector.

Definition at line 91 of file vector_2d.h.

References norm().

00092         {
00093                 double  f= norm();
00094                 if(f>0)
00095                         *this/=f;
00096         }

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

Return the vector normalized.

Definition at line 98 of file vector_2d.h.

References v.

00099         {
00100                 CVector2d       v= *this;
00101                 v.normalize();
00102                 return v;
00103         }

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

Dot product.

Definition at line 85 of file vector_2d.h.

References v, x, and y.

00085 {return x*v.x + y*v.y;}

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

Definition at line 77 of file vector_2d.h.

References CVector2d(), x, and y.

00077 {return CVector2d(x*f, y*f);}

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

Definition at line 73 of file vector_2d.h.

References x, and y.

00073 {x*=f; y*=f; return *this;}

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

Definition at line 110 of file vector_2d.h.

References v.

00110 {return !(*this==v);}

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

Definition at line 75 of file vector_2d.h.

References CVector2d(), v, x, and y.

00075 {return CVector2d(x+v.x, y+v.y);}

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

Definition at line 71 of file vector_2d.h.

References v, x, and y.

00071 {x+=v.x; y+=v.y; return *this;}

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

Definition at line 79 of file vector_2d.h.

References CVector2d(), x, and y.

00079 {return CVector2d(-x, -y);}

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

Definition at line 76 of file vector_2d.h.

References CVector2d(), v, x, and y.

00076 {return CVector2d(x-v.x, y-v.y);}

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

Definition at line 72 of file vector_2d.h.

References v, x, and y.

00072 {x-=v.x; y-=v.y; return *this;}

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

Definition at line 78 of file vector_2d.h.

References CVector2d(), x, and y.

00078 {return CVector2d(x/f, y/f);}

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

Definition at line 74 of file vector_2d.h.

References x, and y.

00074 {x/=f; y/=f; return *this;}

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

Definition at line 109 of file vector_2d.h.

References v, x, and y.

00109 {return x==v.x && y==v.y;}

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

serial.

Definition at line 125 of file vector_2d.h.

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

00125 {f.serial(x,y);}

void NLMISC::CVector2d::set double  _x,
double  _y
[inline]
 

Definition at line 108 of file vector_2d.h.

References x, and y.

00108 {x= _x; y=_y;}

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

Return the square of the norm of the vector.

Definition at line 89 of file vector_2d.h.

References x, and y.

Referenced by norm(), and NLPACS::CEdgeCollide::testEdgeMove().

00089 {return x*x + y*y;}


Friends And Related Function Documentation

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

Definition at line 134 of file vector_2d.h.

00135 {
00136         return v*f;
00137 }


Field Documentation

double NLMISC::CVector2d::x
 

Definition at line 53 of file vector_2d.h.

Referenced by maxof(), minof(), and NLPACS::CEdgeCollide::testEdgeMove().

double NLMISC::CVector2d::y
 

Definition at line 53 of file vector_2d.h.

Referenced by maxof(), minof(), and NLPACS::CEdgeCollide::testEdgeMove().


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 13:41:47 2004 for NeL by doxygen 1.3.6