ZeusMath-Library  2.0.4
Arc2D.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch)
3  *****************************************************************************
4  * Project : Zeus Math Library
5  * Module : Arc2D
6  * Package : Zeus.ZeusMath.Geometry
7  * Author : Martin Abbuehl
8  * Date : 27.12.2011
9  * System : Zeus-Framework
10  *****************************************************************************
11  * Licence: *
12  * This library is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU Lesser General Public License as *
14  * published by the Free Software Foundation; either version *
15  * 2.1 of the License, or (at your option) any later version. *
16  * *
17  * This library is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU Lesser General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU Lesser General Public *
23  * License along with this library; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
25  *****************************************************************************/
26 
27 /*****************************************************************************
28  * Changes:
29  * 27.12.2011 bha: created zeus 2.0
30  *****************************************************************************/
31 
32 #ifndef Arc2DH
33 #define Arc2DH
34 
37 #include <zeusmath/System/Angle.h>
38 
39 
40 BEGIN_NAMESPACE_Zeus
41 
42 
43 /******************************************************************************/
46 /******************************************************************************/
48 {
49  public:
51  inline TArc2D() { }
52 
54  TArc2D(const IVector2D& rVecCenter, const Float& rfRadius,
55  const IAngle& rStartAngle, const IAngle& rEndAngle,
56  bool bAnglesAreGivenCounterClockwise);
57 
59  TArc2D(const ICircle2D& rCircle, const IAngle& rStartAngle,
60  const IAngle& rEndAngle, bool bAnglesAreGivenCounterClockwise);
61 
63  inline TArc2D(const TArc2D& rArc) { *this = rArc; }
64 
66  inline TArc2D(const IArc2D& rArc) { *this = rArc; }
67 
69  static bool createFrom3Points(const IVector2D& rVecStartPoint,
70  const IVector2D& rVecEndPoint,
71  const IVector2D& rVecIntermediatePoint,
72  IArc2D& rArc);
73 
75  static bool createFrom2PointsRadiusAndFlags(const IVector2D& rVecStartPoint,
76  const IVector2D& rVecEndPoint,
77  const Float& rfRadius,
78  bool bPointsAreGivenCounterClockwise,
79  bool bShorterArc, IArc2D& rArc,
80  const Float& rfTangentTolerance =
82 
84  static bool createFrom2PointsAndCenter(const IVector2D& rVecStartPoint,
85  const IVector2D& rVecEndPoint,
86  const IVector2D& rVecCenter,
87  bool bPointsAreGivenCounterClockwise,
88  IArc2D& rArc,
89  const Float& rfTangentTolerance =
91 
92  /******************************************************************************/
94  /******************************************************************************/
95  virtual inline ~TArc2D() { }
96 
97  /******************************************************************************/
99  /******************************************************************************/
100  virtual inline ICircle2D& MQUALIFIER getCircle() { return m_Circle; }
101  virtual inline const ICircle2D& MQUALIFIER getCircleConst() const { return m_Circle; }
102 
103  virtual inline void MQUALIFIER setCircle(const ICircle2D& rCircle) { m_Circle = rCircle; }
104 
105  virtual inline const IVector2D& MQUALIFIER getCenter() const { return getCircleConst().getCenter(); }
106  virtual inline void MQUALIFIER setCenter(const IVector2D& rVecCenter) { getCircle().setCenter(rVecCenter); }
107 
108  virtual inline const Float& MQUALIFIER getRadius() const { return getCircleConst().getRadius(); }
109  virtual inline void MQUALIFIER setRadius(const Float& rfRadius) { getCircle().setRadius(rfRadius); }
110 
111  virtual inline const IAngle& MQUALIFIER getStartAngle() const { return m_StartAngle; }
112  virtual inline const IAngle& MQUALIFIER getEndAngle() const { return m_EndAngle; }
113  virtual void MQUALIFIER setStartAngle(const IAngle& rStartAngle);
114  virtual void MQUALIFIER setEndAngle (const IAngle& rEndAngle);
115 
116  virtual void MQUALIFIER setAngles(const IAngle& rStartAngle, const IAngle& rEndAngle,
117  bool bAnglesAreGivenCounterClockwise);
118 
119  virtual void MQUALIFIER switchAngles();
120 
121  virtual void MQUALIFIER getStartPoint(IVector2D& rVecStart) const;
122  virtual void MQUALIFIER getEndPoint(IVector2D& rVecEnd) const;
123  virtual void MQUALIFIER createSupplementArc(IArc2D& rSupplementArc) const;
124  virtual bool MQUALIFIER isShorterThanSupplementArc() const;
125 
126  virtual inline void MQUALIFIER assign(const IArc2D& rArc) { *this = rArc; }
127 
128  virtual inline bool MQUALIFIER isEqual(const IArc2D& rArc) const { return *this == rArc; }
129 
130  virtual bool MQUALIFIER containsAngle(const IAngle& rAngle,
131  bool bIncludeStartAndEndPoints = true) const;
132 
133  virtual bool MQUALIFIER containsPoint2(const IVector2D& rVecPoint,
134  bool bIncludeStartAndEndPoints = true,
135  const Float& rfTolerance = 0) const;
136 
137  virtual void MQUALIFIER moveStartPointOnCircle(const Float& rfDistance, bool bCounterClockwise);
138  virtual void MQUALIFIER moveEndPointOnCircle(const Float& rfDistance, bool bCounterClockwise);
139 
140  /**************************************************************************/
141  /* Static methods to calculate tangent arcs. */
142  /**************************************************************************/
144  static Retval calcArcsTangentTo2StraightLines(const IStraightLine2D& rStraightLine1,
145  const IStraightLine2D& rStraightLine2,
146  const Float& rfRadius,
147  IList<IArc2D>& rLstTangentArcs,
148  const Float& rfTangentTolerance =
150 
152  static Retval calcArcsTangentToStraightLineAndCircle(const IStraightLine2D& rStraightLine,
153  const ICircle2D& rCircle,
154  const Float& rfRadius,
155  IList<IArc2D>& rLstTangentArcs,
156  const Float& rfTangentTolerance =
158 
160  static Retval calcArcsTangentTo2Circles(const ICircle2D& rCircle1,
161  const ICircle2D& rCircle2,
162  const Float& rfRadius,
163  IList<IArc2D>& rLstTangentArcs,
164  const Float& rfTangentTolerance =
166 
168  static Retval calcArcsTangentTo2LineSegments(const ILineSegment2D& rLineSegment1,
169  const ILineSegment2D& rLineSegment2,
170  const Float& rfRadius,
171  IList<IArc2D>& rLstTangentArcs,
172  const Float& rfTangentTolerance =
174 
176  static Retval calcArcsTangentToLineSegmentAndArc(const ILineSegment2D& rLineSegment,
177  const IArc2D& rArc,
178  const Float& rfRadius,
179  IList<IArc2D>& rLstTangentArcs,
180  const Float& rfTangentTolerance =
182 
184  static Retval calcArcsTangentTo2Arcs(const IArc2D& rArc1, const IArc2D& rArc2,
185  const Float& rfRadius,
186  IList<IArc2D>& rLstTangentArcs,
187  const Float& rfTangentTolerance = INTERSECT_TANGENT_TOLERANCE);
188 
189  /******************************************************************************/
191  /******************************************************************************/
192  virtual inline const InterfaceID& MQUALIFIER getInterfaceID() const { return m_InterfaceID; }
193 
194  virtual Float MQUALIFIER getLength() const;
195 
196  virtual Retval MQUALIFIER getPointFromRunningParameter(const Float& rfRunningParameter,
197  IVector2D& rvecPoint) const;
198 
199  virtual Retval MQUALIFIER intersect(const IGeometricObject2D& rObject,
200  IList<IVector2D>& rLstIntersectionPoints,
201  const Float& rfTangentTolerance = INTERSECT_TANGENT_TOLERANCE) const;
202 
203  virtual inline bool MQUALIFIER containsPoint(const IVector2D& rVecPoint,
204  const Float& rfTolerance = 0) const
205  { return containsPoint2(rVecPoint, true, rfTolerance); }
206 
207  virtual void MQUALIFIER calcClosestPointToPoint(const IVector2D& rVecPoint,
208  IVector2D& rVecClosestPoint) const;
209 
210  virtual Float MQUALIFIER calcDistanceToPoint(const IVector2D& rVecPoint) const;
211  virtual Float MQUALIFIER calcDistanceToObject(const IGeometricObject2D& rObject) const;
212 
213  virtual Retval MQUALIFIER getXMinPoint(IVector2D& rVecPoint) const;
214  virtual Retval MQUALIFIER getXMaxPoint(IVector2D& rVecPoint) const;
215  virtual Retval MQUALIFIER getYMinPoint(IVector2D& rVecPoint) const;
216  virtual Retval MQUALIFIER getYMaxPoint(IVector2D& rVecPoint) const;
217 
218  virtual void MQUALIFIER getMinMaxCoordinates(Float& rfXMin, Float& rfXMax,
219  Float& rfYMin, Float& rfYMax) const;
220 
221  /******************************************************************************/
223  /******************************************************************************/
225  const TArc2D& operator=(const IArc2D& rArc);
226 
228  const TArc2D& operator=(const TArc2D& rArc);
229 
230  /******************************************************************************/
232  /******************************************************************************/
233  /******************************************************************************/
235  bool operator==(const IArc2D& rArc) const;
236 
238  inline bool operator!=(const IArc2D& rArc) const { return !(*this == rArc); }
239 
240  private:
242  static void createFrom2PointsCenterAndRadius(const IVector2D& rVecStartPoint,
243  const IVector2D& rVecEndPoint,
244  const IVector2D& rVecCenter,
245  const Float& rfRadius,
246  bool bPointsAreGivenCounterClockwise,
247  IArc2D& rArc);
248 
250  static bool transformTangentCirclesToArcs(const IList<ICircle2D>& rLstTangentCircles,
251  const IGeometricObject2D& rObject1,
252  const IGeometricObject2D& rObject2,
253  IList<IArc2D>& rLstTangentArcs,
254  const Float& rfTangentTolerance =
256 
257  private:
258  // The underlying, defining circle.
259  TCircle2D m_Circle;
260 
261  // The start and end angles.
262  TAngle m_StartAngle;
263  TAngle m_EndAngle;
264 
265  // Static members.
266  static const InterfaceID m_InterfaceID;
267 };
268 
269 
270 END_NAMESPACE_Zeus
271 
272 #endif
273 
TArc2D(const TArc2D &rArc)
Copy constructor: Constructor taking class type object.
Definition: Arc2D.h:63
Definition: Angle.h:52
virtual void MQUALIFIER assign(const IArc2D &rArc)
Definition: Arc2D.h:126
virtual void MQUALIFIER setCircle(const ICircle2D &rCircle)
Definition: Arc2D.h:103
virtual const IVector2D &MQUALIFIER getCenter() const
Definition: Arc2D.h:105
Definition: Circle2D.h:52
virtual bool MQUALIFIER containsPoint(const IVector2D &rVecPoint, const Float &rfTolerance=0) const
Definition: Arc2D.h:203
virtual ICircle2D &MQUALIFIER getCircle()
Definition: Arc2D.h:100
TArc2D(const IArc2D &rArc)
Constructor taking interface type object.
Definition: Arc2D.h:66
Definition: ICircle2D.hpp:52
Definition: IGeometricObject2D.hpp:54
#define INTERSECT_TANGENT_TOLERANCE
Definition: IGeometricObject2D.hpp:44
Definition: IStraightLine2D.hpp:51
#define zeusmath_class
Definition: PlatformDefines.hpp:48
virtual void MQUALIFIER setRadius(const Float &rfRadius)
Definition: Arc2D.h:109
Definition: Arc2D.h:47
virtual const IAngle &MQUALIFIER getEndAngle() const
Definition: Arc2D.h:112
virtual const Float &MQUALIFIER getRadius() const
Definition: Arc2D.h:108
bool operator!=(const IArc2D &rArc) const
Inequality with another arc?
Definition: Arc2D.h:238
virtual const InterfaceID &MQUALIFIER getInterfaceID() const
Definition: Arc2D.h:192
Definition: ILineSegment2D.hpp:51
Definition: IVector2D.hpp:47
virtual const IAngle &MQUALIFIER getStartAngle() const
Definition: Arc2D.h:111
virtual const ICircle2D &MQUALIFIER getCircleConst() const
Definition: Arc2D.h:101
virtual bool MQUALIFIER isEqual(const IArc2D &rArc) const
Definition: Arc2D.h:128
TArc2D()
Default constructor. Creates an arc of length 0 on the unit circle.
Definition: Arc2D.h:51
Definition: IArc2D.hpp:52
virtual ~TArc2D()
Definition: Arc2D.h:95
virtual void MQUALIFIER setCenter(const IVector2D &rVecCenter)
Definition: Arc2D.h:106
Definition: IAngle.hpp:47
bool operator==(const Float &x, const TComplex &z)
Definition: Complex.h:500


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Wed Sep 14 2016 06:45:50