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