Open Source 2D CAD
Go to the documentation of this file.
20 #ifndef RARC_H
21 #define RARC_H
23 #include "../core_global.h"
25 #include "RDirected.h"
26 #include "RShape.h"
27 #include "RVector.h"
29 class RBox;
30 class RPolyline;
41 class QCADCORE_EXPORT RArc: public RShape, public RDirected {
42 public:
43  RArc();
44  RArc(double cx, double cy, double radius, double startAngle,
45  double endAngle, bool reversed = false);
46  RArc(const RVector& center, double radius, double startAngle,
47  double endAngle, bool reversed = false);
48  virtual ~RArc();
50  virtual RArc* clone() const {
51  return new RArc(*this);
52  }
54  virtual void to2D();
56  bool isValid() const;
57  bool isFullCircle(double tolerance = RS::AngleTolerance) const;
59  static RArc createFrom3Points(const RVector& startPoint,
60  const RVector& point,
61  const RVector& endPoint);
62  static RArc createFrom2PBulge(const RVector& startPoint,
63  const RVector& endPoint,
64  double bulge);
65  static RArc createTangential(const RVector& startPoint,
66  const RVector& pos,
67  double direction,
68  double radius);
69  static QList<RArc> createBiarc(const RVector& startPoint, double startDirection,
70  const RVector& endPoint, double endDirection, bool secondTry = false);
72  virtual RBox getBoundingBox() const;
74  virtual QList<RVector> getEndPoints() const;
75  virtual QList<RVector> getMiddlePoints() const;
76  virtual QList<RVector> getCenterPoints() const;
77  virtual QList<RVector> getPointsWithDistanceToEnd(
78  double distance, RS::From from = RS::FromAny) const;
80  virtual RVector getVectorTo(const RVector& point,
81  bool limited = true, double strictRange = RMAXDOUBLE) const;
83  RVector getCenter() const;
84  void setCenter(const RVector& vector);
85  double getRadius() const;
86  void setRadius(double radius);
87  double getStartAngle() const;
88  void setStartAngle(double startAngle);
89  double getEndAngle() const;
90  void setEndAngle(double endAngle);
91  bool isReversed() const;
92  void setReversed(bool reversed);
93  double getAngleLength(bool allowForZeroLength = false) const;
94  bool isAngleWithinArc(double a) {
95  return RMath::isAngleBetween(a, startAngle, endAngle, reversed);
96  }
98  double getDiameter() const;
99  void setDiameter(double d);
100  void setLength(double l);
101  double getArea() const;
102  void setArea(double a);
103  double getChordArea() const;
105  virtual double getDirection1() const;
106  virtual double getDirection2() const;
108  virtual RS::Side getSideOfPoint(const RVector& point) const;
110  double getSweep() const;
111  void setSweep(double s);
112  double getLength() const;
114  virtual RVector getStartPoint() const;
115  virtual RVector getEndPoint() const;
116  RVector getPointAtAngle(double a) const;
117  virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
118  RVector getMiddlePoint() const;
120  void moveStartPoint(const RVector& pos);
121  void moveEndPoint(const RVector& pos);
122  void moveMiddlePoint(const RVector& pos);
123  double getBulge() const;
125  virtual bool move(const RVector& offset);
126  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
127  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
128  virtual bool mirror(const RLine& axis);
129  virtual bool reverse();
130  virtual bool stretch(const RPolyline& area, const RVector& offset);
132  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
134  virtual RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint);
135  virtual bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid);
136  virtual bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid);
137  virtual double getDistanceFromStart(const RVector& p) const;
139  RPolyline approximateWithLines(double segmentLength);
140  RPolyline approximateWithLinesTan(double segmentLength);
142  QList<RLine> getTangents(const RVector& point) const;
144 protected:
145  virtual void print(QDebug dbg) const;
147 public:
157  double radius;
162  double startAngle;
167  double endAngle;
172  bool reversed;
173 };
178 Q_DECLARE_METATYPE(QSharedPointer<RArc>)
179 Q_DECLARE_METATYPE(QSharedPointer<RArc>*)
181 #endif
static const double AngleTolerance
Definition: RS.h:550
virtual bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid)=0
Represents a box e.g.
Definition: RBox.h:43
Entity ending.
Definition: RS.h:149
RVector center
Getter function for this property: getCenter.
Definition: RArc.h:152
virtual RVector getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const =0
virtual void to2D()=0
Flattens this shape to the X/Y plane.
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
virtual QList< RVector > getEndPoints() const =0
double radius
Getter function for this property: getRadius.
Definition: RArc.h:157
Low-level mathematical representation of an arc.
Definition: RArc.h:41
bool reversed
Getter function for this property: isReversed.
Definition: RArc.h:172
virtual double getDirection1() const =0
virtual RVector getEndPoint() const =0
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)=0
Definition: core_global.h:10
virtual double getLength() const =0
virtual RBox getBoundingBox() const =0
bool isAngleWithinArc(double a)
Definition: RArc.h:94
Start or end.
Definition: RS.h:200
Side used for side of a point relativ to an entity (right hand or left hand side) ...
Definition: RS.h:139
virtual double getDistanceFromStart(const RVector &p) const
Definition: RDirected.h:72
virtual bool move(const RVector &offset)=0
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:151
virtual bool stretch(const RBox &area, const RVector &offset)
Definition: RShape.cpp:1664
static bool isAngleBetween(double a, double a1, double a2, bool reversed)
Tests if angle a is between a1 and a2.
Definition: RMath.cpp:569
virtual QList< RVector > getPointsWithDistanceToEnd(double distance, RS::From from=RS::FromAny) const =0
virtual QList< RVector > getMiddlePoints() const =0
Definition: RMath.h:63
virtual bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid)=0
Definition: RS.h:198
virtual bool mirror(const RLine &axis)=0
Low-level mathematical representation of a line.
Definition: RLine.h:42
double startAngle
Getter function for this property: getStartAngle.
Definition: RArc.h:162
virtual RS::Side getSideOfPoint(const RVector &point) const =0
virtual RVector getStartPoint() const =0
virtual RArc * clone() const
Definition: RArc.h:50
virtual bool reverse()=0
virtual QSharedPointer< RShape > getTransformed(const QTransform &transform) const =0
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RDirected.h:36
double endAngle
Getter function for this property: getEndAngle.
Definition: RArc.h:167
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:197
virtual double getDirection2() const =0
virtual bool scale(double scaleFactor, const RVector &center=RVector())
Definition: RShape.cpp:1675
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:50
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual QList< RVector > getCenterPoints() const =0
virtual void print(QDebug dbg) const
Definition: RShape.cpp:1679
static const RVector invalid
invalid vector
Definition: RVector.h:307
virtual RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)=0
Definition: RVector.h:37