Provided by: librheolef-dev_5.93-2_amd64 bug

NAME

       point - vertex of a mesh

DESCRIPTION

       Defines  geometrical  vertex  as  an  array  of coordinates.  This array is also used as a
       vector of the three dimensional physical space.

IMPLEMENTATION

       template <class T>
       class basic_point {
           public:

       // typedefs:

               typedef size_t size_type;
               typedef T      float_type;

       // allocators:

               explicit basic_point () { _x[0] = T();  _x[1] = T();  _x[2] = T(); }

               explicit basic_point (
                       const T& x0,
                       const T& x1 = 0,
                       const T& x2 = 0)
                               { _x[0] = x0; _x[1] = x1; _x[2] = x2; }

               template <class T1>
               basic_point<T>(const basic_point<T1>& p)
                       { _x[0] = p._x[0]; _x[1] = p._x[1]; _x[2] = p._x[2]; }

               template <class T1>
               basic_point<T>& operator = (const basic_point<T1>& p)
                       { _x[0] = p._x[0]; _x[1] = p._x[1]; _x[2] = p._x[2]; return *this; }

       // accessors:

               T& operator[](int i_coord)              { return _x[i_coord%3]; }
               const T&  operator[](int i_coord) const { return _x[i_coord%3]; }
               T& operator()(int i_coord)              { return _x[i_coord%3]; }
               const T&  operator()(int i_coord) const { return _x[i_coord%3]; }

       // inputs/outputs:

               std::istream& get (std::istream& s, int d = 3)
               {
                   switch (d) {
                   case 1 : _x[1] = _x[2] = 0; return s >> _x[0];
                   case 2 : _x[2] = 0; return s >> _x[0] >> _x[1];
                   default: return s >> _x[0] >> _x[1] >> _x[2];
                   }
               }
               // output
               std::ostream& put (std::ostream& s, int d = 3) const;

       // ccomparators: lexicographic order

               template<int d>
               friend bool lexicographically_less (
                       const basic_point<T>& a, const basic_point<T>& b) {
                   for (size_type i = 0; i < d; i++) {
                     if (a[i] < b[i]) return true;
                     if (a[i] > b[i]) return false;
                   }
                   return false; // equality
               }
       // algebra:

               friend bool operator == (const basic_point<T>& u, const basic_point<T>& v)
                       { return u[0] == v[0] && u[1] == v[1] && u[2] == v[2]; }

               basic_point<T>& operator+= (const basic_point<T>& v)
                       { _x[0] += v[0]; _x[1] += v[1]; _x[2] += v[2]; return *this; }

               basic_point<T>& operator-= (const basic_point<T>& v)
                       { _x[0] -= v[0]; _x[1] -= v[1]; _x[2] -= v[2]; return *this; }

               basic_point<T>& operator*= (const T& a)
                       { _x[0] *= a; _x[1] *= a; _x[2] *= a; return *this; }

               basic_point<T>& operator/= (const T& a)
                       { _x[0] /= a; _x[1] /= a; _x[2] /= a; return *this; }

               friend basic_point<T> operator+ (const basic_point<T>& u, const basic_point<T>& v)
                       { return basic_point<T> (u[0]+v[0], u[1]+v[1], u[2]+v[2]); }

               friend basic_point<T> operator- (const basic_point<T>& u)
                       { return basic_point<T> (-u[0], -u[1], -u[2]); }

               friend basic_point<T> operator- (const basic_point<T>& u, const basic_point<T>& v)
                       { return basic_point<T> (u[0]-v[0], u[1]-v[1], u[2]-v[2]); }

               template <class T1>
               friend basic_point<T> operator* (const T1& a, const basic_point<T>& u)
                       { return basic_point<T> (a*u[0], a*u[1], a*u[2]); }

               friend basic_point<T> operator* (const basic_point<T>& u, T a)
                       { return basic_point<T> (a*u[0], a*u[1], a*u[2]); }

               friend basic_point<T> operator/ (const basic_point<T>& u, const T& a)
                       { return basic_point<T> (u[0]/a, u[1]/a, u[2]/a); }

               friend basic_point<T> operator/ (const basic_point<T>& u, basic_point<T> v)
                       { return basic_point<T> (u[0]/v[0], u[1]/v[1], u[2]/v[2]); }

               friend basic_point<T> vect (const basic_point<T>& v, const basic_point<T>& w)
                       { return basic_point<T> (
                               v[1]*w[2]-v[2]*w[1],
                               v[2]*w[0]-v[0]*w[2],
                               v[0]*w[1]-v[1]*w[0]); }
       // metric:

               // TODO: non-constant metric
               friend T dot (const basic_point<T>& u, const basic_point<T>& v)
                       { return u[0]*v[0]+u[1]*v[1]+u[2]*v[2]; }

               friend T norm2 (const basic_point<T>& u)
                       { return dot(u,u); }

               friend T norm (const basic_point<T>& u)
                       { return ::sqrt(norm2(u)); }

               friend T dist2 (const basic_point<T>& x,  const basic_point<T>& y)
                       { return norm2(x-y); }

               friend T dist (const basic_point<T>& x,  const basic_point<T>& y)
                       { return norm(x-y); }

               friend T dist_infty (const basic_point<T>& x,  const basic_point<T>& y)
                       { return max(_my_abs(x[0]-y[0]),
                                    max(_my_abs(x[1]-y[1]), _my_abs(x[2]-y[2]))); }

       // data:
               T _x[3];
       // internal:
       protected:
               static T _my_abs(const T& x) { return (x > T(0)) ? x : -x; }
       };
       template <class T>
       T vect2d (const basic_point<T>& v, const basic_point<T>& w);

       template <class T>
       T mixt (const basic_point<T>& u, const basic_point<T>& v, const basic_point<T>& w);

       // robust(exact) floating point predicates: return value as (0, > 0, < 0)
       // formally: orient2d(a,b,x) = vect2d(a-x,b-x)
       template <class T>
       T orient2d(const basic_point<T>& a, const basic_point<T>& b,
               const basic_point<T>& x = basic_point<T>());

       // formally: orient3d(a,b,c,x) = mixt3d(a-x,b-x,c-x)
       template <class T>
       T orient3d(const basic_point<T>& a, const basic_point<T>& b,
               const basic_point<T>& c, const basic_point<T>& x = basic_point<T>());