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