polygon_2d.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hiroki Shimora
00012 
00013  This code is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU Lesser General Public
00015  License as published by the Free Software Foundation; either
00016  version 2.1 of the License, or (at your option) any later version.
00017 
00018  This library is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  Lesser General Public License for more details.
00022 
00023  You should have received a copy of the GNU Lesser General Public
00024  License along with this library; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027  *EndCopyright:
00028  */
00029 
00030 #ifndef RCSC_GEOM_POLYGON2D_H
00031 #define RCSC_GEOM_POLYGON2D_H
00032 
00033 #include <vector>
00034 
00035 namespace rcsc {
00036 
00037 class Vector2D;
00038 class Rect2D;
00039 
00044 class Polygon2D {
00045 private:
00046     std::vector< Vector2D > M_vertex;
00047 
00048 public:
00052     Polygon2D();
00053 
00058     Polygon2D( const std::vector< Vector2D > & v );
00059 
00064     const Polygon2D & assign();
00065 
00071     const Polygon2D & assign( const std::vector< Vector2D > & v );
00072 
00077     void addVertex( const Vector2D & p );
00078 
00083     const std::vector< Vector2D > & vertex() const;
00084 
00089     std::vector< Vector2D > & vertex();
00090 
00098     bool contains( const Vector2D & p,
00099                    bool allow_on_segment = true ) const;
00100 
00105     Rect2D getBoundingBox() const;
00106 
00111     Vector2D xyCenter() const;
00112 
00125     double dist( const Vector2D & p,
00126                  bool check_as_plane = true ) const;
00127 
00132     double area() const;
00133 
00141     double signedArea2() const;
00142 
00147     bool isCounterclockwise() const;
00148 
00153     bool isClockwise() const;
00154 
00161     Polygon2D getScissoredConnectedPolygon( const Rect2D & r ) const;
00162 };
00163 
00164 }
00165 
00166 #endif

librcscに対してThu May 1 15:41:20 2008に生成されました。  doxygen 1.5.0