xc
Circle2d.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //Circle2d.h
22 
23 #ifndef CIRCLE2D_H
24 #define CIRCLE2D_H
25 
26 #include "Surface2d.h"
27 #include "../cgal_types.h"
28 #include "utility/utils/misc_utils/matem.h"
29 
30 class Pos2d;
31 class Pos2dArray;
32 class Polygon2d;
33 
35 //
37 class Circle2d : public Surface2d
38  {
39  CGCircle_2 cgcirc;
40 
41  protected:
42  void arc_points(const double &theta_inic,const double &delta_theta,Pos2dArray &ptos) const;
43  public:
44  Circle2d(void) : Surface2d(), cgcirc() {}
45  Circle2d(const Pos2d &centro,const GEOM_FT &rad);
46  Circle2d(const GEOM_FT &rad2,const Pos2d &centro);
47  Circle2d(const Pos2d &p1,const Pos2d &p2,const Pos2d &p3);
48 
49  virtual Surface2d *getCopy(void) const
50  { return new Circle2d(*this); }
51  Pos2d Centro(void) const;
52  virtual Pos2d getCenterOfMass(void) const;
53  Pos2d Point(const double &ang) const;
54  inline GEOM_FT getSquaredRadius(void) const
55  { return cgcirc.squared_radius(); }
56  GEOM_FT getRadius(void) const;
57  inline GEOM_FT getDiameter(void) const
58  { return 2*getRadius(); }
59  virtual double getAngle(const Pos2d &p) const;
60  virtual GEOM_FT getLength(void) const;
62  inline GEOM_FT getPerimeter(void) const
63  { return getLength(); }
64  virtual double getIncludedAngle(void) const;
65  virtual GEOM_FT getArea(void) const;
67  virtual GEOM_FT getVolume(void) const
68  { return 0.0; }
69  virtual GEOM_FT Ix(void) const;
70  virtual GEOM_FT Iy(void) const
71  { return Ix(); }
72  inline virtual GEOM_FT Pxy(void) const
73  { return 0.0; }
74  virtual GEOM_FT Iz(void) const
75  { return 2*Ix(); }
76  virtual GEOM_FT GetMax(unsigned short int i) const;
77  virtual GEOM_FT GetMin(unsigned short int i) const;
78  virtual bool In(const Pos2d &p, const double &tol= 0.0) const;
79  Pos2dArray getPointsOnPerimeter(const size_t &n,const double &theta_inic= 0.0) const;
80  Polygon2d getInscribedPolygon(const size_t &n,const double &theta_inic= 0.0) const;
81 
82  void Transform(const Trf2d &trf2d);
83  Circle2d offset(const GEOM_FT &) const;
84 
85  friend int operator ==(const Circle2d &a,const Circle2d &b)
86  { return ( a.cgcirc == b.cgcirc ); };
87 
88  void Print(std::ostream &os) const;
89  void Plot(Plotter &) const;
90 
91  };
92 
93 Circle2d Circle2dRTT(const GEOM_FT &,const Line2d &,const Line2d &,const bool &left,const bool &far);
94 Pos2d circle_center(const Pos2d &,const Pos2d &,const Pos2d &);
95 
96 #endif
97 
98 
99 
virtual GEOM_FT GetMin(unsigned short int i) const
Return el valor mínimo of the i coordinate of the points of the circle.
Definition: Circle2d.cc:136
Círculo en dos dimensiones.
Definition: Circle2d.h:37
virtual GEOM_FT Iy(void) const
Moment of inertia with respect to the center of mass en local axis.
Definition: Circle2d.h:70
Posición en dos dimensiones.
Definition: Pos2d.h:41
Line in a two-dimensional space.
Definition: Line2d.h:61
virtual double getAngle(const Pos2d &p) const
Return the angle between the line that passes through the center and the p point and the x axis...
Definition: Circle2d.cc:118
virtual double getIncludedAngle(void) const
Return the angle included by the circle (2*pi).
Definition: Circle2d.cc:150
virtual GEOM_FT getVolume(void) const
Return the volume of the object.
Definition: Circle2d.h:67
virtual Pos2d getCenterOfMass(void) const
Return the position of the center of mass.
Definition: Circle2d.cc:98
Base class for two-dimensional transformations.
Definition: Trf2d.h:40
Circle2d offset(const GEOM_FT &) const
Return a circle parallel to this one at the distance being passed as parameter.
Definition: Circle2d.cc:213
virtual GEOM_FT Ix(void) const
Return el moment of inertia del círculo with respect to axis parallel to x que pasa por su centro...
Definition: Circle2d.cc:140
virtual GEOM_FT GetMax(unsigned short int i) const
Return the maximum value of the i coordinate of the points of the circle.
Definition: Circle2d.cc:133
Array of positions in a two-dimensional space.
Definition: Pos2dArray.h:38
Base class for surfaces in a two-dimensional space.
Definition: Surface2d.h:33
void arc_points(const double &theta_inic, const double &delta_theta, Pos2dArray &ptos) const
Return n points equally espaces over the circle perimenter.
Definition: Circle2d.cc:154
Pos2dArray getPointsOnPerimeter(const size_t &n, const double &theta_inic=0.0) const
Return n points equally spaced over the cicumference.
Definition: Circle2d.cc:176
Polígono en dos dimensiones.
Definition: Polygon2d.h:38
GEOM_FT getPerimeter(void) const
Return the perimeter of the object.
Definition: Circle2d.h:62
virtual bool In(const Pos2d &p, const double &tol=0.0) const
Return true if the point is on the circle.
Definition: Circle2d.cc:145
Pos2d Point(const double &ang) const
Return the point of the circle that corresponds to the parameter angle.
Definition: Circle2d.cc:103
void Transform(const Trf2d &trf2d)
Aplica al objeto la transformación que se pasa como parámetro.
Definition: Circle2d.cc:204
GEOM_FT getRadius(void) const
Return the radius of the circle.
Definition: Circle2d.cc:113
Polygon2d getInscribedPolygon(const size_t &n, const double &theta_inic=0.0) const
Return the n-gon inscribed int the circle.
Definition: Circle2d.cc:193
virtual GEOM_FT Pxy(void) const
!
Definition: Circle2d.h:72
virtual GEOM_FT Iz(void) const
Moment of inertia polar with respect to the center of mass en local axis.
Definition: Circle2d.h:74
virtual GEOM_FT getArea(void) const
Return the area of the circle.
Definition: Circle2d.cc:130
virtual GEOM_FT getLength(void) const
Return the length of the círcle.
Definition: Circle2d.cc:127