Ptv Class Reference

#include <Ptv.h>

List of all members.

Public Member Functions

 Ptv (unsigned int size_)
 Ptv (unsigned int size_, double *v_)
 Ptv (double x, double y)
 Ptv (double x, double y, double z)
 Ptv (const Ptv &p)
 Ptv ()
void redim (unsigned int size_, double *v_)
void redim (unsigned int size_)
void fill (double *v_)
virtual ~Ptv ()
const unsigned int size () const
const double & operator[] (unsigned int i) const
double & operator[] (unsigned int i)
Ptvoperator= (const Ptv &p)
bool less (const Ptv &p) const

Public Attributes

unsigned int dim
double * v

Static Public Attributes

static double tol = 1.0e-9


Detailed Description

Definition at line 10 of file Ptv.h.


Constructor & Destructor Documentation

Ptv::Ptv ( unsigned int  size_  ) 

Definition at line 41 of file Ptv.cpp.

References dim, and v.

00042 {
00043         dim = size_;
00044         v = new double[dim];
00045         for (unsigned int i=0; i< dim; i++)
00046         {
00047                 v[i] = 0.0;
00048         }
00049 }

Ptv::Ptv ( unsigned int  size_,
double *  v_ 
)

Definition at line 60 of file Ptv.cpp.

References dim, and v.

00061 {
00062         dim = size_;
00063         v = new double[dim];
00064         for (unsigned int i=0; i< dim; i++)
00065         {
00066                 v[i] = v_[i];
00067         }
00068 }

Ptv::Ptv ( double  x,
double  y 
)

Definition at line 22 of file Ptv.cpp.

References dim, and v.

00023 {
00024         dim = 2;
00025         v = new double[2];
00026         v[0] = x;
00027         v[1] = y;
00028 }

Ptv::Ptv ( double  x,
double  y,
double  z 
)

Definition at line 31 of file Ptv.cpp.

References dim, and v.

00032 {
00033         dim = 3;
00034         v = new double[3];
00035         v[0] = x;
00036         v[1] = y;
00037         v[2] = z;
00038 }

Ptv::Ptv ( const Ptv p  ) 

Definition at line 71 of file Ptv.cpp.

References dim, size(), and v.

00072 {
00073         dim = p.size();
00074         v = new double[dim];
00075         for (unsigned int i=0; i< dim; i++)
00076         {
00077                 v[i] = p[i];
00078         }
00079 
00080 }

Ptv::Ptv (  ) 

Definition at line 16 of file Ptv.cpp.

References v.

00016          : dim(0)
00017 {
00018         v = new double[0];
00019 }

Ptv::~Ptv (  )  [virtual]

Definition at line 83 of file Ptv.cpp.

References v.

00084 {
00085         delete [] v;
00086 }


Member Function Documentation

void Ptv::fill ( double *  v_  ) 

Definition at line 120 of file Ptv.cpp.

References dim, and v.

00121 {
00122         for (unsigned int i=0; i< dim; i++)
00123         {
00124                 v[i] = v_[i];
00125         }
00126 }

bool Ptv::less ( const Ptv p  )  const

Definition at line 162 of file Ptv.cpp.

References dim, size(), tol, and v.

Referenced by SyFi::line_contains(), and Ptv_is_less::operator()().

00163 {
00164 
00165         if ( dim <  p.size() ) return true ;
00166         if ( dim >  p.size() ) return false;
00167 
00168         /* 
00169         for (int i=dim-1; i>= 0; i--) {
00170           if ( fabs(v[i] - p[i]) > tol ) {
00171                 if (v[i] < p[i])
00172                   return true;
00173                 else
00174         return false;
00175         }
00176         }
00177         */
00178 
00179         for (int i=dim-1; i>= 0; i--)
00180         {
00181                 if ( v[i] + tol >= p[i] - tol &&  v[i] - tol <= p[i] + tol )
00182                 {
00183                 }
00184                 else if (v[i] + tol  < p[i] - tol  )
00185                 {
00186                         return true;
00187                 }
00188                 else if ( v[i] - tol > p[i] + tol  )
00189                 {
00190                         return false;
00191                 }
00192         }
00193 
00194         return false;
00195 }

Ptv & Ptv::operator= ( const Ptv p  ) 

Definition at line 143 of file Ptv.cpp.

References dim, size(), and v.

00144 {
00145         if ( this != &p)
00146         {
00147                 if ( dim != p.size())
00148                 {
00149                         delete [] v;
00150                         dim = p.size();
00151                         v = new double[dim];
00152                 }
00153                 for (unsigned int i=0; i< dim; i++)
00154                 {
00155                         v[i] = p[i];
00156                 }
00157         }
00158         return *this;
00159 }

double & Ptv::operator[] ( unsigned int  i  ) 

Definition at line 137 of file Ptv.cpp.

References v.

00138 {
00139         return v[i];
00140 }

const double & Ptv::operator[] ( unsigned int  i  )  const

Definition at line 131 of file Ptv.cpp.

References v.

00132 {
00133         return v[i];
00134 }

void Ptv::redim ( unsigned int  size_  ) 

Definition at line 105 of file Ptv.cpp.

References dim, and v.

00106 {
00107         if (dim != size_ )
00108         {
00109                 delete [] v;
00110                 dim = size_;
00111                 v = new double[dim];
00112         }
00113         for (unsigned int i=0; i< dim; i++)
00114         {
00115                 v[i] = 0.0;
00116         }
00117 }

void Ptv::redim ( unsigned int  size_,
double *  v_ 
)

Definition at line 89 of file Ptv.cpp.

References dim, and v.

Referenced by SyFi::add(), SyFi::cross(), and SyFi::sub().

00090 {
00091         if (dim != size_ )
00092         {
00093                 delete [] v;
00094                 dim = size_;
00095                 v = new double[dim];
00096         }
00097 
00098         for (unsigned int i=0; i< dim; i++)
00099         {
00100                 v[i] = v_[i];
00101         }
00102 }

const unsigned int Ptv::size (  )  const


Member Data Documentation

unsigned int Ptv::dim

Definition at line 14 of file Ptv.h.

Referenced by fill(), less(), operator=(), Ptv(), redim(), and size().

double Ptv::tol = 1.0e-9 [static]

double* Ptv::v

Definition at line 15 of file Ptv.h.

Referenced by fill(), less(), operator=(), operator[](), Ptv(), redim(), and ~Ptv().


The documentation for this class was generated from the following files:

Generated on Mon Aug 31 16:17:05 2009 for SyFi by  doxygen 1.5.9