00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "OSDLPoint3D.h"
00028
00029
00030
00031
00032 using std::string ;
00033 using std::list ;
00034
00035 using namespace OSDL::Video ;
00036 using namespace OSDL::Video::TwoDimensional ;
00037
00038
00039 const Point3D Point3D::Origin( static_cast<Coordinate>( 0 ), 0, 0 ) ;
00040
00041
00042
00043 Point3D::Point3D( Coordinate x, Coordinate y, Coordinate z )
00044 {
00045
00046 _coord[0] = x ;
00047 _coord[1] = y ;
00048 _coord[2] = z ;
00049
00050 }
00051
00052
00053
00054 Point3D::Point3D( const Point3D & source ) :
00055 Point()
00056 {
00057
00058 _coord[0] = source._coord[0] ;
00059 _coord[1] = source._coord[1] ;
00060 _coord[2] = source._coord[2] ;
00061
00062 }
00063
00064
00065
00066 Point3D::Point3D( const Ceylan::Maths::Linear::Vector3 & source )
00067 {
00068
00069 _coord[0] = static_cast<Coordinate>( source.getElementAt( 0 ) ) ;
00070 _coord[1] = static_cast<Coordinate>( source.getElementAt( 1 ) ) ;
00071 _coord[2] = static_cast<Coordinate>( source.getElementAt( 2 ) ) ;
00072
00073 }
00074
00075
00076
00077 Point3D::Point3D( FloatingPointCoordinate x, FloatingPointCoordinate y,
00078 FloatingPointCoordinate z )
00079 {
00080
00081 _coord[0] = static_cast<Coordinate>( x ) ;
00082 _coord[1] = static_cast<Coordinate>( y ) ;
00083 _coord[2] = static_cast<Coordinate>( z ) ;
00084
00085 }
00086
00087
00088
00089 Point3D::~Point3D() throw()
00090 {
00091
00092 }
00093
00094
00095
00096 void Point3D::setFrom( const Point3D & source )
00097 {
00098
00099 _coord[0] = source._coord[0] ;
00100 _coord[1] = source._coord[1] ;
00101 _coord[2] = source._coord[2] ;
00102
00103 }
00104
00105
00106
00107 void Point3D::setFrom( const Ceylan::Maths::Linear::Vector3 & source )
00108 {
00109
00110 _coord[0] = static_cast<Coordinate>( source.getElementAt( 0 ) ) ;
00111 _coord[1] = static_cast<Coordinate>( source.getElementAt( 1 ) ) ;
00112 _coord[2] = static_cast<Coordinate>( source.getElementAt( 2 ) ) ;
00113
00114 }
00115
00116
00117
00118 const string Point3D::toString( Ceylan::VerbosityLevels level ) const
00119 {
00120
00121 return ( string( " ( " )
00122 + _coord[0]
00123 + string( " ; " )
00124 + _coord[1]
00125 + string( " ; " )
00126 + _coord[2]
00127 + string( " )" ) ) ;
00128
00129 }
00130
00131
00132
00133 void Point3D::translate( Offset x, Offset y, Offset z )
00134 {
00135
00136 _coord[0] += x ;
00137 _coord[1] += y ;
00138 _coord[2] += z ;
00139
00140 }
00141
00142
00143
00144 void Point3D::flip()
00145 {
00146
00147 _coord[0] = - _coord[0] ;
00148 _coord[1] = - _coord[1] ;
00149 _coord[2] = - _coord[2] ;
00150
00151 }
00152
00153
00154
00155 void Point3D::flipX()
00156 {
00157
00158 _coord[0] = - _coord[0] ;
00159
00160 }
00161
00162
00163
00164 void Point3D::flipY()
00165 {
00166
00167 _coord[1] = - _coord[1] ;
00168
00169 }
00170
00171
00172
00173 void Point3D::flipZ()
00174 {
00175
00176 _coord[2] = - _coord[2] ;
00177
00178 }
00179
00180
00181
00182 void Point3D::Translate( list<Point3D *> & pointList,
00183 Offset x, Offset y, Offset z )
00184 {
00185
00186 for ( list<Point3D *>::iterator it = pointList.begin();
00187 it != pointList.end(); it++ )
00188 (*it)->translate( x, y, z ) ;
00189
00190 }
00191
00192
00193
00194 std::ostream & operator << ( std::ostream & os, const Point3D & p )
00195 {
00196
00197 return os << p.toString() ;
00198
00199 }
00200