| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeCoord2D.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00026 #ifndef  __TERRALIB_INTERNAL_COORD2D_H
    00027 #define  __TERRALIB_INTERNAL_COORD2D_H
    00028
    00029 #include <math.h>
    00030 #include "TeDefines.h"
    00031 #include "TePrecision.h"
    00032
    00033 #include <vector>
    00034
    00035 using namespace std;
    00036
    00038 class TL_DLL TeCoord2D
    00039 {
    00040 public:
    00041
    00042            double     x_;
    00043            double     y_;
    00044
    00046            TeCoord2D ( const double& x = 0., const double& y = 0. ):
    00047                       x_ ( x ), y_ ( y ) {}
    00048
    00050            TeCoord2D (const TeCoord2D& cd)
    00051                       {x_ = cd.x_; y_ = cd.y_;}
    00052
    00054            TeCoord2D& operator= ( const TeCoord2D& cd )
    00055            {
    00056                       if ( this != &cd )
    00057                       {
    00058                                  x_ = cd.x_; y_ = cd.y_;
    00059                       }
    00060                       return *this;
    00061            }
    00062
    00064            ~TeCoord2D () { }
    00065
    00067            const double&         x () const
    00068            {          return x_; }
    00069
    00071            void x ( const double& valX )
    00072            {          x_ = valX; }
    00073
    00075            const double&         y ()                  const
    00076            {          return y_; }
    00077
    00079            void y(const double& valY)
    00080            {          y_ = valY; }
    00081
    00083            void setXY(const double& xVal, const double& yVal )
    00084            {          x_= xVal; y_= yVal; }
    00085
    00087            void       operator+=(const TeCoord2D& cd)  {x_ += cd.x_; y_ += cd.y_;}
    00088
    00090            bool  operator<= (const TeCoord2D& cd) const
    00091                       {return (( y_ - cd.y_ <= TePrecision::instance().precision() ) &&
    00092                                ( x_ - cd.x_ <= TePrecision::instance().precision() ) );}
    00093
    00095            bool operator== (const TeCoord2D& cd) const
    00096            {return (  ( fabs (y_ - cd.y_) < TePrecision::instance().precision() )
    00097                                  && ( fabs (x_ - cd.x_) < TePrecision::instance().precision() ) ); }
    00098
    00100            bool       operator!= (const TeCoord2D& cd) const
    00101                       {return ( ( fabs (y_ - cd.y_) >= TePrecision::instance().precision() )
    00102                              || ( fabs (x_ - cd.x_) >= TePrecision::instance().precision() ) );}
    00103
    00105            bool       operator< (const TeCoord2D& cd) const
    00106                       {return ( y_ - cd.y_ < TePrecision::instance().precision()
    00107                              && x_ - cd.x_ < TePrecision::instance().precision() );}
    00108
    00110            bool       tooBig ()
    00111                       {return ( y_ > TeMAXFLOAT/10.|| x_ > TeMAXFLOAT/10.);}
    00112
    00114            void       scale ( const double xscale, const double yscale )
    00115            { x_ = x_* xscale; y_ = y_ * yscale; }
    00116
    00117
    00119            TeCoord2D halfWayHoriz ( TeCoord2D& rhs )
    00120            {
    00121                       TeCoord2D mid (( rhs.x() + x() ) / 2., y() );
    00122                       return mid;
    00123            }
    00124
    00126            TeCoord2D halfWayVert  ( TeCoord2D& rhs )
    00127            {
    00128                       TeCoord2D mid ( x(), ( y() + rhs.y() ) / 2. );
    00129                       return mid;
    00130            }
    00131
    00133            void objectId(const string& /* id */ )
    00134            {          return;  }
    00135 };
    00136
    00138 struct TL_DLL TeCoordPair
    00139 {
    00140            TeCoord2D pt1;
    00141            TeCoord2D pt2;
    00142
    00144            TeCoordPair():
    00145                       pt1(TeCoord2D(0.0,0.0)),
    00146                       pt2(TeCoord2D(0.0,0.0))
    00147            {}
    00148
    00150            TeCoordPair(const TeCoord2D& p1, const TeCoord2D& p2):
    00151                       pt1(p1),
    00152                       pt2(p2)
    00153                       {}
    00154
    00155   // overload
    00156   bool operator==( const TeCoordPair& external ) const
    00157   {
    00158     return ( ( pt1 == external.pt1 ) && ( pt2 == external.pt2 ) );
    00159   }
    00160 };
    00161
    00163 typedef vector<TeCoordPair> TeCoordPairVect;
    00164
    00165 #endif
    00166

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines