sector_2d.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hidehisa Akiyama
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 
00031 
00032 #ifndef RCSC_GEOM_SECTOR2D_H
00033 #define RCSC_GEOM_SECTOR2D_H
00034 
00035 #include <rcsc/geom/vector_2d.h>
00036 
00037 namespace rcsc {
00038 
00043 class Sector2D {
00044 private:
00046     Vector2D M_center;
00047 
00049     double M_min_radius;
00051     double M_max_radius;
00052 
00054     AngleDeg M_angle_left_start;
00056     AngleDeg M_angle_right_end;
00057 
00059     Sector2D();
00060 public:
00061 
00070     Sector2D( const Vector2D & c,
00071               const double & min_r,
00072               const double & max_r,
00073               const AngleDeg & start,
00074               const AngleDeg & end );
00075 
00084     const
00085     Sector2D & assign( const Vector2D & c,
00086                        const double & min_r,
00087                        const double & max_r,
00088                        const AngleDeg & start,
00089                        const AngleDeg & end );
00090 
00095     const
00096     Vector2D & center() const
00097       {
00098           return M_center;
00099       }
00100 
00105     const
00106     double & radiusMin() const
00107       {
00108           return M_min_radius;
00109       }
00110 
00115     const
00116     double & radiusMax() const
00117       {
00118           return M_max_radius;
00119       }
00120 
00125     const
00126     AngleDeg & angleLeftStart() const
00127       {
00128           return M_angle_left_start;
00129       }
00130 
00135     const
00136     AngleDeg & angleRightEnd() const
00137       {
00138           return M_angle_right_end;
00139       }
00140 
00146     bool contains( const Vector2D & point ) const
00147       {
00148           Vector2D rel = point - center();
00149           double d2 = rel.r2();
00150           return ( M_min_radius * M_min_radius <= d2
00151                    && d2 <= M_max_radius * M_max_radius
00152                    && rel.th().isWithin( M_angle_left_start,
00153                                          M_angle_right_end ) );
00154       }
00155 
00160     double area() const;
00161 
00167     double getCircumferenceMin() const
00168       {
00169           double div = ( M_angle_right_end - M_angle_left_start ).degree();
00170           if ( div < 0.0 )
00171           {
00172               div += 360.0;
00173           }
00174           return ( 2.0 * M_min_radius * M_PI ) * ( div / 360.0 );
00175       }
00176 
00182     double getCircumferenceMax() const
00183       {
00184           double div = ( M_angle_right_end - M_angle_left_start ).degree();
00185           if ( div < 0.0 )
00186           {
00187               div += 360.0;
00188           }
00189           return ( 2.0 * M_max_radius * M_PI ) * ( div / 360.0 );
00190       }
00191 };
00192 
00193 }
00194 
00195 #endif

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