00001
00009 #ifndef _POINT_BASSO_H_
00010 #define _POINT_BASSO_H_
00011
00012 #include <iostream>
00013
00014
00015 #include "gmm.h"
00016
00017
00018 #include "basso.h"
00019
00020
00021 namespace basso {
00022
00023
00030 class Point : public nArray {
00031
00032 public:
00033
00037 Point() : nArray(3,0.0) { }
00038
00040 Point( Numeric x, Numeric y, Numeric z ) : nArray(3) { (*this)[0]=x; (*this)[1]=y; (*this)[2]=z; }
00041
00043 Point( Numeric x, Numeric y ) : nArray(3) { (*this)[0]=x; (*this)[1]=y; (*this)[2]=0.0; }
00044
00046 Point( Numeric x ) : nArray(3) { (*this)[0]=x; (*this)[1]=0.0; (*this)[2]=0.0; }
00047
00049 Point( const nArray &v ) : nArray(3)
00050 {
00051 int i=0;
00052 for ( ; i<( 3?vect_size(v)>3:vect_size(v) ); ++i )
00053 x(i)=v[i];
00054 for ( ; i<3; ++i )
00055 x(i)=0.0;
00056 }
00057
00058 ~Point() {}
00059
00063 Numeric &x( int i ) { return (*this)[i]; }
00065 Numeric x( int i ) const { return (*this)[i]; }
00067 Numeric &x() { return (*this)[0]; }
00069 Numeric x() const { return (*this)[0]; }
00071 Numeric &y() { return (*this)[1]; }
00073 Numeric y() const { return (*this)[1]; }
00075 Numeric &z() { return (*this)[2]; }
00077 Numeric z() const { return (*this)[2]; }
00078
00080 Numeric Distance() const;
00081
00083 Numeric Distance( const Point &p ) const;
00084
00085 Point &operator = ( const nArray &v );
00086
00087
00088
00089
00090 protected:
00091
00092 };
00093
00094 Point &Point::operator = ( const nArray &v )
00095 {
00096 for ( int i=0; i< ( 3?vect_size(v)>3:vect_size(v) ); ++i )
00097 x(i)=v[i];
00098 return *this;
00099 }
00100
00101
00102 Numeric Point::Distance( const Point &p ) const
00103 {
00104 return sqrt( pow(p.x()-x(),2) + pow(p.y()-y(),2) + pow(p.z()-z(),2) );
00105 }
00106
00107 Numeric Point::Distance( ) const
00108 {
00109 return sqrt( pow(x(),2) + pow(y(),2) + pow(z(),2) );
00110 }
00111
00113 std::ostream &operator << ( std::ostream &out, const Point &p )
00114 {
00115 out << "(" << p.x() << "," << p.y() << "," << p.z() << ")";
00116 return out;
00117 }
00118
00119
00120 }
00121
00122 #endif