Main Page   Class Hierarchy   Compound List   File List   Compound Members  

point_nd.h

00001 /*============================================================================
00002         File: point_nd.h
00003      Purpose: 
00004     Revision: $Id: point_nd.h,v 1.2 2002/05/13 21:07:45 philosophil Exp $
00005   Created by: Philippe Lavoie          (26 January, 1996)
00006  Modified by: Martin Schuerch
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-1999 Philippe Lavoie
00010  
00011           This library is free software; you can redistribute it and/or
00012           modify it under the terms of the GNU Library General Public
00013           License as published by the Free Software Foundation; either
00014           version 2 of the License, or (at your option) any later version.
00015  
00016           This library is distributed in the hope that it will be useful,
00017           but WITHOUT ANY WARRANTY; without even the implied warranty of
00018           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019           Library General Public License for more details.
00020  
00021           You should have received a copy of the GNU Library General Public
00022           License along with this library; if not, write to the Free
00023           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 =============================================================================*/
00025 #ifndef _Matrix_pointnD_h_
00026 #define _Matrix_pointnD_h_
00027 
00028 #include "matrix_global.h"
00029 #include <memory.h>
00030 
00031 
00032 namespace PLib {
00033 
00045   template <class T, int N>
00046   struct Point_nD {
00047     //only the specialications make sense, because this class should only be used for
00048     // (float,2), (float,3) (double,2) (double,3)
00049   };
00050 
00051 
00052   template <>
00053   struct Point_nD<float,3> {
00054     typedef float T;
00055     T data[3] ;
00056     Point_nD()  { x() = y() = z() = 0 ;}
00057     Point_nD(T a)  { x() = y() = z() = a ;}
00058     Point_nD(T X, T Y, T Z)  {x()=X ; y()=Y ; z()=Z ;}
00059     Point_nD(const Point_nD& a) { memcpy((void*)data,(void*)a.data,3*sizeof(T));}
00060 
00061     inline T& x() { return data[0] ; }
00062     inline T& y() { return data[1] ; }
00063     inline T& z() { return data[2] ; }
00064     inline T x() const { return data[0] ; }
00065     inline T y() const { return data[1] ; }
00066     inline T z() const { return data[2] ; }
00067  
00068     Point_nD& operator=(const Point_nD& v) { x()=v.x() ; y()=v.y() ; z()=v.z() ;  return *this ;} ;
00069     Point_nD& operator+=(const Point_nD& v) {x()+=v.x() ; y()+= v.y() ; z()+=v.z() ;  return *this;} ;
00070     Point_nD& operator-=(const Point_nD& v) {x()-=v.x() ; y()-= v.y() ; z()-=v.z() ;  return *this;} ;
00071     Point_nD& operator*=(T v) {x()*=v ; y()*= v ; z()*= v;  return *this;} ;
00072     Point_nD& operator/=(T v) {x()/=v ; y()/= v ; z()/= v ; return *this;} ;
00073 
00074     Point_nD unitLength() const {  T d = norm(); Point_nD<T,3> u(x()/d,y()/d,z()/d); return u; }
00075     T norm2() const { return  data[0]*data[0] + data[1]*data[1] + data[2]*data[2]; }
00076     T norm() const { return sqrt( data[0]*data[0] + data[1]*data[1] + data[2]*data[2] ); }
00077   };
00078 
00079 
00080   template <>
00081   struct Point_nD<double,3> {
00082     typedef double T;
00083     T data[3] ;
00084     Point_nD()  { x() = y() = z() = 0 ;}
00085     Point_nD(T a)  { x() = y() = z() = a ;}
00086     Point_nD(T X, T Y, T Z)  {x()=X ; y()=Y ; z()=Z ;}
00087     Point_nD(const Point_nD& a) { memcpy((void*)data,(void*)a.data,3*sizeof(T));}
00088 
00089     inline T& x() { return data[0] ; }
00090     inline T& y() { return data[1] ; }
00091     inline T& z() { return data[2] ; }
00092     inline T x() const { return data[0] ; }
00093     inline T y() const { return data[1] ; }
00094     inline T z() const { return data[2] ; }
00095  
00096     Point_nD& operator=(const Point_nD& v) { x()=v.x() ; y()=v.y() ; z()=v.z() ;  return *this ;} ;
00097     Point_nD& operator+=(const Point_nD& v) {x()+=v.x() ; y()+= v.y() ; z()+=v.z() ;  return *this;} ;
00098     Point_nD& operator-=(const Point_nD& v) {x()-=v.x() ; y()-= v.y() ; z()-=v.z() ;  return *this;} ;
00099     Point_nD& operator*=(T v) {x()*=v ; y()*= v ; z()*= v;  return *this;} ;
00100     Point_nD& operator/=(T v) {x()/=v ; y()/= v ; z()/= v ; return *this;} ;
00101 
00102     Point_nD unitLength() const {  T d = norm(); Point_nD<T,3> u(x()/d,y()/d,z()/d); return u; }
00103     T norm2() const { return  data[0]*data[0] + data[1]*data[1] + data[2]*data[2]; }
00104     T norm() const { return sqrt( data[0]*data[0] + data[1]*data[1] + data[2]*data[2] ); }
00105   };
00106 
00107 
00108   template <>
00109   struct Point_nD<float,2> { 
00110     typedef float T;
00111     T data[2] ;
00112     Point_nD()  { x() = y() = 0 ;}
00113     Point_nD(T a)  { x() = y() = a ;}
00114     Point_nD(T X, T Y)  {x()=X ; y()=Y ; }
00115     Point_nD(const Point_nD<T,2>& a)  { memcpy((void*)data,(void*)a.data,2*sizeof(T));}
00116 
00117     inline T& x() { return data[0] ; }
00118     inline T& y() { return data[1] ; }
00119     inline T& z() { return dumbVar ; }
00120     inline T x() const { return data[0] ; }
00121     inline T y() const { return data[1] ; }
00122     inline T z() const { return T() ; }
00123  
00124     Point_nD& operator=(const Point_nD& v) { x()=v.x() ; y()=v.y() ; return *this ;} ;
00125     Point_nD& operator+=(const Point_nD& v) {x()+=v.x() ; y()+= v.y() ; return *this;} ;
00126     Point_nD& operator-=(const Point_nD& v) {x()-=v.x() ; y()-= v.y() ;   return *this;} ;
00127     Point_nD& operator*=(T v) {x()*=v ; y()*= v ; return *this;} ;
00128     Point_nD& operator/=(T v) {x()/=v ; y()/= v ; return *this;} ;
00129  
00130     Point_nD unitLength() const { T d = norm(); Point_nD<T,2> u(x()/d,y()/d); return u;}
00131     T norm2() const { return  data[0]*data[0] + data[1]*data[1]; }
00132     T norm() const { return sqrt( data[0]*data[0] + data[1]*data[1] ); }
00133 
00134   protected:
00135     static T dumbVar ; 
00136   };
00137 
00138 
00139   template <>
00140   struct Point_nD<double,2> { 
00141     typedef double T;
00142     T data[2] ;
00143     Point_nD()  { x() = y() = 0 ;}
00144     Point_nD(T a)  { x() = y() = a ;}
00145     Point_nD(T X, T Y)  {x()=X ; y()=Y ; }
00146     Point_nD(const Point_nD<T,2>& a)  { memcpy((void*)data,(void*)a.data,2*sizeof(T));}
00147 
00148     inline T& x() { return data[0] ; }
00149     inline T& y() { return data[1] ; }
00150     inline T& z() { return dumbVar ; }
00151     inline T x() const { return data[0] ; }
00152     inline T y() const { return data[1] ; }
00153     inline T z() const { return T() ; }
00154  
00155     Point_nD& operator=(const Point_nD& v) { x()=v.x() ; y()=v.y() ; return *this ;} ;
00156     Point_nD& operator+=(const Point_nD& v) {x()+=v.x() ; y()+= v.y() ; return *this;} ;
00157     Point_nD& operator-=(const Point_nD& v) {x()-=v.x() ; y()-= v.y() ;   return *this;} ;
00158     Point_nD& operator*=(T v) {x()*=v ; y()*= v ; return *this;} ;
00159     Point_nD& operator/=(T v) {x()/=v ; y()/= v ; return *this;} ;
00160  
00161     Point_nD unitLength() const { T d = norm(); Point_nD<T,2> u(x()/d,y()/d); return u;}
00162     T norm2() const { return  data[0]*data[0] + data[1]*data[1]; }
00163     T norm() const { return sqrt( data[0]*data[0] + data[1]*data[1] ); }
00164 
00165   protected:
00166     static T dumbVar ; 
00167   };
00168 
00169 
00170 
00171   template <class T>
00172   inline int operator<(const Point_nD<T,3>& a, const Point_nD<T,3>& b) { 
00173     return a.x()<b.x() || a.y()<b.y() || a.z()<b.z() ;}
00174 
00175   template <class T>
00176   inline int operator>(const Point_nD<T,3>& a, const Point_nD<T,3>& b) { 
00177     return a.x()>b.x() || a.y()>b.y() || a.z()>b.z() ;}
00178 
00179   template <class T>
00180   inline int operator<=(const Point_nD<T,3>& a, const Point_nD<T,3>& b) { 
00181     return a.x()<=b.x() || a.y()<=b.y() || a.z()<=b.z() ;}
00182 
00183   template <class T>
00184   inline int operator>=(const Point_nD<T,3>& a, const Point_nD<T,3>& b) { 
00185     return a.x()>=b.x() || a.y()>=b.y() || a.z()>=b.z() ;}
00186 
00187 
00188 
00189   template <class T>
00190   inline int operator<(const Point_nD<T,2>& a, const Point_nD<T,2>& b) { 
00191     return a.x()<b.x() || a.y()<b.y() ;}
00192 
00193   template <class T>
00194   inline int operator>(const Point_nD<T,2>& a, const Point_nD<T,2>& b) { 
00195     return a.x()>b.x() || a.y()>b.y() ;}
00196 
00197   template <class T>
00198   inline int operator<=(const Point_nD<T,2>& a, const Point_nD<T,2>& b) { 
00199     return a.x()<=b.x() || a.y()<=b.y()  ;}
00200 
00201   template <class T>
00202   inline int operator>=(const Point_nD<T,2>& a, const Point_nD<T,2>& b) { 
00203     return a.x()>=b.x() || a.y()>=b.y() ;}
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00211 
00212   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00213         Routine: operator* --- multiplies a point in 3D with a float
00214      Multiplies a point in 3D with a float
00215           Input: a --> the floating point value
00216                  b --> the point in 3D
00217          Output: $ab$
00218    Restrictions:
00219      author Philippe Lavoie (24 January 1997)
00220     Modified by:
00221    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00222   template <class T>
00223   inline Point_nD<T,3> operator*(const T a,const Point_nD<T,3>& b) {
00224     Point_nD<T,3> mul(b.x()*a,b.y()*a,b.z()*a) ;
00225     return mul ;
00226   }
00227 
00228   inline Point_nD<float,3> operator*(const double a,const Point_nD<float,3>& b) {
00229     Point_nD<float,3> mul(b.x()*a,b.y()*a,b.z()*a) ;
00230     return mul ;
00231   }
00232 
00233   template <class T>
00234   inline Point_nD<T,2> operator*(const T a,const Point_nD<T,2>& b) {
00235     Point_nD<T,2> mul(b.x()*a,b.y()*a) ;
00236     return mul ;
00237   }
00238 
00239   inline Point_nD<float,2> operator*(const double a,const Point_nD<float,2>& b) {
00240     Point_nD<float,2> mul(b.x()*a,b.y()*a) ;
00241     return mul ;
00242   }
00243 
00244   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00245         Routine: operator* --- multiplies a point in 3D with a float
00246      Multiplies a point in 3D with a float
00247           Input: a --> the floating point value
00248                  b --> the point in 3D
00249          Output: $ab$
00250    Restrictions:
00251      author Philippe Lavoie (24 January 1997)
00252     Modified by:
00253    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00254   template <class T>
00255   inline Point_nD<T,3> operator*(const Point_nD<T,3>& b,const T a) {
00256     Point_nD<T,3> mul(b.x()*a,b.y()*a,b.z()*a) ;
00257     return mul ;
00258   }
00259 
00260   inline Point_nD<float,3> operator*(const Point_nD<float,3>& b,const double a) {
00261     Point_nD<float,3> mul(b.x()*a,b.y()*a,b.z()*a) ;
00262     return mul ;
00263   }
00264 
00265   template <class T>
00266   inline Point_nD<T,2> operator*(const Point_nD<T,2>& b,const T a) {
00267     Point_nD<T,2> mul(b.x()*a,b.y()*a) ;
00268     return mul ;
00269   }
00270 
00271   inline Point_nD<float,2> operator*(const Point_nD<float,2>& b,const double a) {
00272     Point_nD<float,2> mul(b.x()*a,b.y()*a) ;
00273     return mul ;
00274   }
00275 
00276   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00277         Routine: operator/ --- Divide a point in 3D by a float
00278      Divide a point in 3D by a float.
00279           Input: a --> the point in 3D
00280                  b --> the floating point value to divide with
00281          Output: $a/b$
00282    Restrictions:
00283      author Philippe Lavoie (24 January 1997)
00284     Modified by:
00285    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00286   template <class T>
00287   inline Point_nD<T,3> operator/(const Point_nD<T,3>& a,const T b) {
00288     Point_nD<T,3> div(a.x()/b,a.y()/b,a.z()/b) ;
00289     return div ;
00290   }
00291 
00292   inline Point_nD<float,3> operator/(const Point_nD<float,3>& a,const double b) {
00293     Point_nD<float,3> div(a.x()/b,a.y()/b,a.z()/b) ;
00294     return div ;
00295   }
00296 
00297   template <class T>
00298   inline Point_nD<T,2> operator/(const Point_nD<T,2>& a,const T b) {
00299     Point_nD<T,2> div(a.x()/b,a.y()/b) ;
00300     return div ;
00301   }
00302 
00303   inline Point_nD<float,2> operator/(const Point_nD<float,2>& a,const double b) {
00304     Point_nD<float,2> div(a.x()/b,a.y()/b) ;
00305     return div ;
00306   }
00307 
00320   template <class T>
00321   inline T dot(const Point_nD<T,3>& a,const Point_nD<T,3>& b) {
00322     return a.x()*b.x() + a.y()*b.y() + a.z()*b.z() ;
00323   }
00324 
00337   template <class T>
00338   inline T dot(const Point_nD<T,2>& a,const Point_nD<T,2>& b) {
00339     return a.x()*b.x() + a.y()*b.y() ;
00340   }
00341 
00342   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00343         Routine: operator* --- the dot product of two points in 3D
00344      The dot product of two points in 3D
00345           Input: a --> the first point in 3D
00346                  b --> the second point in 3D
00347          Output: $a.b$
00348    Restrictions:
00349      author Philippe Lavoie (24 January 1997)
00350     Modified by:
00351    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00352   template <class T>
00353   inline T operator*(const Point_nD<T,3>& a,const Point_nD<T,3>& b) {
00354     return a.x()*b.x() + a.y()*b.y() + a.z()*b.z() ;
00355   }
00356 
00357   template <class T>
00358   inline T operator*(const Point_nD<T,2>& a,const Point_nD<T,2>& b) {
00359     return a.x()*b.x() + a.y()*b.y() ;
00360   }
00361 
00362 
00363 
00364   // Point3D definitions
00365 
00366   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00367         Routine: operator+ --- the addition operator with points in 3D
00368      The addition operator with points in 3D
00369           Input: a --> the first point in 3D
00370                  b --> the second point in 3D
00371          Output: $a+b$
00372    Restrictions:
00373      author Philippe Lavoie (24 January 1997)
00374     Modified by:
00375    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00376   template <class T, int D>
00377   inline Point_nD<T,D> operator+(const Point_nD<T,D>& a,const Point_nD<T,D>& b) {
00378     Point_nD<T,D> sum(a) ;
00379     sum += b ;
00380     return sum ;
00381   }
00382 
00383 
00384   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00385         Routine: operator- --- the subtraction operator with points in 3D
00386      The subtraction operator with points in 3D
00387           Input: a --> the first point in 3D
00388                  b --> the second point in 3D
00389          Output: $a-b$
00390    Restrictions:
00391      author Philippe Lavoie (24 January 1997)
00392     Modified by:
00393    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00394   template <class T, int D>
00395   inline Point_nD<T,D> operator-(const Point_nD<T,D>& a,const Point_nD<T,D>& b) {
00396     Point_nD<T,D> diff(a) ;
00397     diff -= b ;
00398     return diff ;
00399   }
00400 
00401 
00402   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00403         Routine: operator== --- the equality operator with a float
00404      Finds if all the elements of the point in 3D are equal to $b$
00405           Input: a --> the point in 3D
00406                  b --> the floating point value
00407          Output: 1 if equal, 0 otherwise
00408    Restrictions:
00409      author Philippe Lavoie (24 January 1997)
00410     Modified by:
00411    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00412   template <class T>
00413   inline int operator==(const Point_nD<T,3>&a, float b) {
00414     if(a.x() == b && a.y() == b && a.z()==b)
00415       return 1 ;
00416     return 0 ;
00417   }
00418 
00419   template <class T>
00420   inline int operator==(const Point_nD<T,2>&a, float b) {
00421     if(a.x() == b && a.y() == b )
00422       return 1 ;
00423     return 0 ;
00424   }
00425 
00426   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00427         Routine: operator!= --- the inequality operator between points in 3D
00428      The inequality operator between points in 3D.
00429           Input: a --> the first point in 3D
00430                  b --> the second point in 3D
00431          Output: 1 if they are different, 0 otherwise
00432    Restrictions:
00433      author Philippe Lavoie (24 January 1997)
00434     Modified by:
00435    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00436   template <class T>
00437   inline int operator!=(const Point_nD<T,3>& a, const Point_nD<T,3>& b){
00438     if(a.x() == b.x() && a.y() == b.y() && a.z() == b.z())
00439       return 0 ;
00440     else
00441       return 1 ;
00442   }
00443 
00444   template <class T>
00445   inline int operator!=(const Point_nD<T,2>& a, const Point_nD<T,2>& b){
00446     if(a.x() == b.x() && a.y() == b.y() )
00447       return 0 ;
00448     else
00449       return 1 ;
00450   }
00451 
00452   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00453         Routine: operator== --- the equality operator between points in 3D
00454      The equality operator between points in 3D.
00455           Input: a --> the first point in 3D
00456                  b --> the second point in 3D
00457          Output: 1 if they are equal, 0 otherwise
00458    Restrictions:
00459      author Philippe Lavoie (24 January 1997)
00460     Modified by:
00461    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00462   template <class T>
00463   inline int operator==(const Point_nD<T,3>& a, const Point_nD<T,3>& b){
00464     if(a.x() == b.x() && a.y() == b.y() && a.z() == b.z())
00465       return 1 ;
00466     else
00467       return 0 ;
00468   }
00469 
00470   template <class T>
00471   inline int operator==(const Point_nD<T,2>& a, const Point_nD<T,2>& b){
00472     if(a.x() == b.x() && a.y() == b.y() )
00473       return 1 ;
00474     else
00475       return 0 ;
00476   }
00477 
00478 
00479 
00480   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00481         Routine: norm2 --- the sum of the square of all the elements of a point
00482      The sum of the square of all the elements of a point or
00483                  the length squared of the vector in 3D.
00484           Input: a --> the point
00485          Output: $a_x^2+a_y^2+a_z^2$
00486    Restrictions:
00487      author Philippe Lavoie (24 January 1997)
00488     Modified by:
00489    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00490   template <class T,int N>
00491   inline double norm2(const Point_nD<T,N>& a){
00492     double temp = 0 ;
00493     for(int i=N-1;i>=0;--i)
00494       temp += a.data[i]*a.data[i] ;
00495     return temp ;
00496   }
00497 
00498   template <class T,int N> 
00499   inline double norm(const Point_nD<T,N>& a) { return sqrt(norm2<T,N>(a)); }
00500 
00501 
00502 
00503   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00504         Routine: angle --- Finds the angle between two points in 3D
00505      Finds the angle between two points in 3D
00506           Input: a --> the first point in 3D
00507                  b --> the second point in 3D
00508          Output: The angle in radian between the two points
00509    Restrictions:
00510      author Philippe Lavoie (24 January 1997)
00511     Modified by:
00512    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00513   template <class T, int D>
00514   inline T angle(const Point_nD<T,D>& a,const Point_nD<T,D>& b) {
00515     if(b==0 || a==0 )
00516       return 0 ;
00517     return acos(dot(a,b)/norm(a)/norm(b)) ;
00518   }
00519 
00520 
00521   template <class T>
00522   inline Point_nD<T,3> crossProduct(const Point_nD<T,3>& a, const Point_nD<T,3>& b){
00523     Point_nD<T,3> prod ;
00524     prod.x() = a.y()*b.z() - a.z()*b.y() ;
00525     prod.y() = a.z()*b.x() - a.x()*b.z() ;
00526     prod.z() = a.x()*b.y() - a.y()*b.x() ;
00527     return prod ;
00528   }
00529 
00530 
00531   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00532         Routine: operator<< ---  the output operator of a point in 3D 
00533                                  to an ostream
00534      The output operator of a point in 3D to an ostream .
00535           Input:  os --> the ostream
00536                point --> the point to output
00537          Output: the ostream with the point 
00538    Restrictions:
00539      author Philippe Lavoie (24 January 1997)
00540     Modified by:
00541    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00542   template <class T>
00543   inline ostream& operator<<(ostream& os,const Point_nD<T,3>& point)
00544   {
00545     os << " " << point.x() << " " << point.y() << " " << point.z() << " " ;
00546     return os;  
00547   }
00548 
00549   template <class T>
00550   inline ostream& operator<<(ostream& os,const Point_nD<T,2>& point)
00551   {
00552     os << " " << point.x() << " " << point.y() << " " ;
00553     return os;  
00554   }
00555 
00556   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00557         Routine: operator>> --- the input operator from an istream
00558      Initialize a point in 3D from the input stream.
00559           Input:  os --> the input stream
00560                point <-- the point to initialize
00561          Output: the istream without the point
00562    Restrictions:
00563      author Philippe Lavoie (24 January 1997)
00564     Modified by:
00565    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00566   template <class T>
00567   inline istream& operator>>(istream& os, Point_nD<T,3>& point){
00568     float x,y,z ;
00569     os >> x >> y >> z ;
00570     point.x() = x ;
00571     point.y() = y ; 
00572     point.z() = z ;
00573     return os ;
00574   }
00575 
00576   template <class T>
00577   inline istream& operator>>(istream& os, Point_nD<T,2>& point){
00578     float x,y ;
00579     os >> x >> y  ;
00580     point.x() = x ;
00581     point.y() = y ; 
00582     return os ;
00583   }
00584 
00585 
00586   template <class T> T minimum(T a, T b);
00587   template <class T> T maximum(T a, T b);
00588 
00589   inline Point_nD<float,3> minimum(Point_nD<float,3> a, Point_nD<float,3>  b){
00590     Point_nD<float,3> m ;
00591     m.x() = minimum(a.x(),b.x()) ;
00592     m.y() = minimum(a.y(),b.y()) ;
00593     m.z() = minimum(a.z(),b.z()) ;
00594     return m ; 
00595   }
00596 
00597   inline Point_nD<double,3> minimum(Point_nD<double,3> a, Point_nD<double,3>  b){
00598     Point_nD<double,3> m ;
00599     m.x() = minimum(a.x(),b.x()) ;
00600     m.y() = minimum(a.y(),b.y()) ;
00601     m.z() = minimum(a.z(),b.z()) ;
00602     return m ; 
00603   }
00604 
00605 
00606   inline Point_nD<float,2> minimum(Point_nD<float,2> a, Point_nD<float,2>  b){
00607     Point_nD<float,2> m ;
00608     m.x() = minimum(a.x(),b.x()) ;
00609     m.y() = minimum(a.y(),b.y()) ;
00610     return m ; 
00611   }
00612 
00613 
00614   inline Point_nD<double,2> minimum(Point_nD<double,2> a, Point_nD<double,2>  b){
00615     Point_nD<double,2> m ;
00616     m.x() = minimum(a.x(),b.x()) ;
00617     m.y() = minimum(a.y(),b.y()) ;
00618     return m ; 
00619   }
00620 
00621   inline Point_nD<float,3> maximum(Point_nD<float,3> a,Point_nD<float,3>  b){
00622     Point_nD<float,3> m ;
00623     m.x() = maximum(a.x(),b.x()) ;
00624     m.y() = maximum(a.y(),b.y()) ;
00625     m.z() = maximum(a.z(),b.z()) ;
00626     return m ; 
00627   }
00628 
00629   inline Point_nD<double,3> maximum(Point_nD<double,3> a,Point_nD<double,3>  b){
00630     Point_nD<double,3> m ;
00631     m.x() = maximum(a.x(),b.x()) ;
00632     m.y() = maximum(a.y(),b.y()) ;
00633     m.z() = maximum(a.z(),b.z()) ;
00634     return m ; 
00635   }
00636 
00637 
00638   inline Point_nD<float,2> maximum(Point_nD<float,2> a,Point_nD<float,2>  b){
00639     Point_nD<float,2> m ;
00640     m.x() = maximum(a.x(),b.x()) ;
00641     m.y() = maximum(a.y(),b.y()) ;
00642     return m ; 
00643   }
00644 
00645   inline Point_nD<double,2> maximum(Point_nD<double,2> a,Point_nD<double,2>  b){
00646     Point_nD<double,2> m ;
00647     m.x() = maximum(a.x(),b.x()) ;
00648     m.y() = maximum(a.y(),b.y()) ;
00649     return m ; 
00650   }
00651 
00652 
00653   template <class T>
00654   inline Point_nD<T,3> minimumByRef(const Point_nD<T,3> &a,const Point_nD<T,3>  &b){
00655     Point_nD<T,3> m ;
00656     m.x() = minimum(a.x(),b.x()) ;
00657     m.y() = minimum(a.y(),b.y()) ;
00658     m.z() = minimum(a.z(),b.z()) ;
00659     return m ; 
00660   }
00661 
00662 
00663   template <class T>
00664   inline Point_nD<T,2> minimumByRef(const Point_nD<T,2> &a,const Point_nD<T,2>  &b){
00665     Point_nD<T,2> m ;
00666     m.x() = minimum(a.x(),b.x()) ;
00667     m.y() = minimum(a.y(),b.y()) ;
00668     return m ; 
00669   }
00670 
00671 
00672   template <class T>
00673   inline Point_nD<T,3> maximumByRef(const Point_nD<T,3> &a,const Point_nD<T,3>  &b){
00674     Point_nD<T,3> m ;
00675     m.x() = maximum(a.x(),b.x()) ;
00676     m.y() = maximum(a.y(),b.y()) ;
00677     m.z() = maximum(a.z(),b.z()) ;
00678     return m ; 
00679   }
00680 
00681   typedef Point_nD<float,3> Point3Df ;
00682   typedef Point_nD<double,3> Point3Dd ;
00683 
00684   typedef Point_nD<float,2> Point2Df ;
00685   typedef Point_nD<double,2> Point2Dd ;
00686 
00687 
00688 
00689 } // end namespace
00690 
00691 typedef PLib::Point_nD<float,3> PlPoint3Df ;
00692 typedef PLib::Point_nD<double,3> PlPoint3Dd ;
00693 
00694 typedef PLib::Point_nD<float,2> PlPoint2Df ;
00695 typedef PLib::Point_nD<double,2> PlPoint2Dd ;
00696 
00697 
00698 
00699 #endif

Generated on Tue Jun 24 13:26:58 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002