SyFi  0.3
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 24 of file Ptv.h.


Constructor & Destructor Documentation

Ptv::Ptv ( unsigned int  size_)

Definition at line 54 of file Ptv.cpp.

References dim, and v.

{
        dim = size_;
        v = new double[dim];
        for (unsigned int i=0; i< dim; i++)
        {
                v[i] = 0.0;
        }
}
Ptv::Ptv ( unsigned int  size_,
double *  v_ 
)

Definition at line 73 of file Ptv.cpp.

References dim, and v.

{
        dim = size_;
        v = new double[dim];
        for (unsigned int i=0; i< dim; i++)
        {
                v[i] = v_[i];
        }
}
Ptv::Ptv ( double  x,
double  y 
)

Definition at line 35 of file Ptv.cpp.

References dim, v, SyFi::x, and SyFi::y.

{
        dim = 2;
        v = new double[2];
        v[0] = x;
        v[1] = y;
}
Ptv::Ptv ( double  x,
double  y,
double  z 
)

Definition at line 44 of file Ptv.cpp.

References dim, v, SyFi::x, SyFi::y, and SyFi::z.

{
        dim = 3;
        v = new double[3];
        v[0] = x;
        v[1] = y;
        v[2] = z;
}
Ptv::Ptv ( const Ptv p)

Definition at line 84 of file Ptv.cpp.

References dim, size(), and v.

{
        dim = p.size();
        v = new double[dim];
        for (unsigned int i=0; i< dim; i++)
        {
                v[i] = p[i];
        }

}
Ptv::Ptv ( )

Definition at line 30 of file Ptv.cpp.

         : dim(0), v(0)
{
}
Ptv::~Ptv ( ) [virtual]

Definition at line 96 of file Ptv.cpp.

References v.

{
        if (v)
        {
                delete [] v;
                v = 0;
        }
}

Member Function Documentation

void Ptv::fill ( double *  v_)

Definition at line 137 of file Ptv.cpp.

References dim, and v.

{
        for (unsigned int i=0; i< dim; i++)
        {
                v[i] = v_[i];
        }
}
bool Ptv::less ( const Ptv p) const

Definition at line 179 of file Ptv.cpp.

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

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

{

        if ( dim <  p.size() ) return true ;
        if ( dim >  p.size() ) return false;

        /*
        for (int i=dim-1; i>= 0; i--) {
          if ( fabs(v[i] - p[i]) > tol ) {
                if (v[i] < p[i])
                  return true;
                else
        return false;
        }
        }
        */

        for (int i=dim-1; i>= 0; i--)
        {
                if ( v[i] + tol >= p[i] - tol &&  v[i] - tol <= p[i] + tol )
                {
                }
                else if (v[i] + tol  < p[i] - tol  )
                {
                        return true;
                }
                else if ( v[i] - tol > p[i] + tol  )
                {
                        return false;
                }
        }

        return false;
}
Ptv & Ptv::operator= ( const Ptv p)

Definition at line 160 of file Ptv.cpp.

References dim, size(), and v.

{
        if ( this != &p)
        {
                if ( dim != p.size())
                {
                        if (v) delete [] v;
                        dim = p.size();
                        v = new double[dim];
                }
                for (unsigned int i=0; i< dim; i++)
                {
                        v[i] = p[i];
                }
        }
        return *this;
}
const double & Ptv::operator[] ( unsigned int  i) const

Definition at line 148 of file Ptv.cpp.

References v.

{
        return v[i];
}
double & Ptv::operator[] ( unsigned int  i)

Definition at line 154 of file Ptv.cpp.

References v.

{
        return v[i];
}
void Ptv::redim ( unsigned int  size_,
double *  v_ 
)

Definition at line 106 of file Ptv.cpp.

References dim, and v.

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

{
        if (dim != size_ )
        {
                if (v) delete [] v;
                dim = size_;
                v = new double[dim];
        }

        for (unsigned int i=0; i< dim; i++)
        {
                v[i] = v_[i];
        }
}
void Ptv::redim ( unsigned int  size_)

Definition at line 122 of file Ptv.cpp.

References dim, and v.

{
        if (dim != size_ )
        {
                if (v) delete [] v;
                dim = size_;
                v = new double[dim];
        }
        for (unsigned int i=0; i< dim; i++)
        {
                v[i] = 0.0;
        }
}
const unsigned int Ptv::size ( ) const

Member Data Documentation

unsigned int Ptv::dim

Definition at line 28 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 29 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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator