RCircle
Class in Math Module
Header: #include <src/core/math/RCircle.h>
Inherits: RShape
Inherited by: RCircleData
Description
Section titled “Description”Low-level mathematical representation of a circle.
Scriptable: This class is available in script environments.
Shared Pointer Support: Objects can be used in QSharedPointer.
Copyable: Objects are cleaned up automatically by the garbage collector of the script engine.
Stream Operator: Object has a stream operator to present itself as string, for example when using toString() in a script.
Public Functions
Section titled “Public Functions”RCircle() |
|
RCircle(const RVector ¢er, const double radius)Creates a circle from a center point and radius. |
|
RCircle(double cx, double cy, const double radius)Creates a circle from center coordinates and radius. |
|
| virtual | ~RCircle() |
| virtual QSharedPointer< RShape > | clone() const |
| QSharedPointer< RCircle > | cloneToCircle() const |
| bool | contains(const RVector &p) const |
| virtual bool | flipHorizontal()Flips the circle center horizontally (negates X; radius is invariant). |
| virtual bool | flipVertical()Flips the circle center vertically (negates Y; radius is invariant). |
| virtual double | getAngleAt(double distance, RS::From from=RS::FromStart) const |
| virtual QList< RVector > | getArcReferencePoints() const |
| double | getArea() const |
| virtual RBox | getBoundingBox() const |
| RVector | getCenter() const |
| virtual QList< RVector > | getCenterPoints() const |
| double | getCircumference() const |
| double | getDiameter() const |
| virtual double | getDistanceTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const |
| virtual QList< double > | getDoubleProperties() const |
| virtual QList< RVector > | getEndPoints() const |
| virtual double | getLength() const |
| virtual QList< RVector > | getMiddlePoints() const |
| virtual QList< QSharedPointer< RShape > > | getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid) |
| RVector | getPointAtAngle(double a) const |
| virtual QList< RVector > | getPointCloud(double segmentLength) const |
| virtual RVector | getPointOnShape() const |
| virtual QList< RVector > | getPointsWithDistanceToEnd(double distance, int from=RS::FromAny) const |
| double | getRadius() const |
| virtual RShape::Type | getShapeType() const |
| QList< RLine > | getTangents(const RVector &point) const |
| virtual QSharedPointer< RShape > | getTransformed(const QTransform &transform) const |
| virtual QList< RVector > | getVectorProperties() const |
| virtual RVector | getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const |
| virtual bool | isValid() const |
| virtual bool | mirror(const RLine &axis)Mirrors the circle center about axis (radius is invariant). |
| virtual bool | move(const RVector &offset)Moves the circle by offset. |
| virtual bool | rotate(double rotation, const RVector ¢er=RDEFAULT_RVECTOR)Rotates the circle center around c by rotation radians (radius is invariant). |
| virtual bool | scale(const RVector &scaleFactors, const RVector ¢er=RDEFAULT_RVECTOR)Scales the circle by scaleFactors relative to c. |
| void | setArea(double a)Sets the radius to match the given area. |
| void | setCenter(const RVector &vector)Sets the center point of the circle. |
| void | setCircumference(double c)Sets the radius to match the given circumference. |
| void | setDiameter(double d)Sets the radius from a diameter value. |
| void | setRadius(double radius)Sets the radius of the circle. |
| virtual void | setZ(double z)Sets the Z coordinate of the center point. |
| virtual QList< QSharedPointer< RShape > > | splitAt(const QList< RVector > &points) constSplits the circle at the given points, returning a list of RArc segments. |
| RArc | toArc(double startAngle=0.0) const |
Static Public Functions
Section titled “Static Public Functions”| static RCircle | createFrom2Points(const RVector &p1, const RVector &p2)Creates a circle with the given two points as diameter endpoints. |
| static RCircle | createFrom3Points(const RVector &p1, const RVector &p2, const RVector &p3)Creates a circle through three points by finding the intersection of the perpendicular bisectors of the two chords p1–p2 and p2–p3. |
Public Attributes
Section titled “Public Attributes”| RVector | center Getter function for this property: getCenter. |
| double | radius Getter function for this property: getRadius. |
Protected Functions
Section titled “Protected Functions”| virtual void | print(QDebug dbg) constPrints circle properties to dbg for debugging. |
Member Documentation
Section titled “Member Documentation”RCircle
Section titled “RCircle”RCircle::RCircle()All rights reserved.
This file is part of the QCAD project.
QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with QCAD. Creates a circle object with invalid center and 0 radius.
RCircle
Section titled “RCircle”RCircle::RCircle(const RVector ¢er, const double radius)Creates a circle from a center point and radius.
RCircle
Section titled “RCircle”RCircle::RCircle(double cx, double cy, const double radius)Creates a circle from center coordinates and radius.
~RCircle
Section titled “~RCircle”virtual RCircle::~RCircle()virtual
virtual QSharedPointer< RShape > RCircle::clone() constvirtual inline const
Reimplemented from clone.
cloneToCircle
Section titled “cloneToCircle”QSharedPointer< RCircle > RCircle::cloneToCircle() constinline const
contains
Section titled “contains”bool RCircle::contains(const RVector &p) constconst
Returns: True if p is strictly inside the circle (distance to center < radius).
flipHorizontal
Section titled “flipHorizontal”virtual bool RCircle::flipHorizontal()virtual
Flips the circle center horizontally (negates X; radius is invariant).
Reimplemented from flipHorizontal.
Reimplemented in flipHorizontal.
flipVertical
Section titled “flipVertical”virtual bool RCircle::flipVertical()virtual
Flips the circle center vertically (negates Y; radius is invariant).
Reimplemented from flipVertical.
Reimplemented in flipVertical.
getAngleAt
Section titled “getAngleAt”virtual double RCircle::getAngleAt(double distance, RS::From from=RS::FromStart) constvirtual const
Returns: RNANDOUBLE — circles have no defined tangent direction at a parametric distance (they have no start point).
Reimplemented from getAngleAt.
getArcReferencePoints
Section titled “getArcReferencePoints”virtual QList< RVector > RCircle::getArcReferencePoints() constvirtual const
Returns: The four quadrant points (0°, 90°, 180°, 270°) as snappable reference points.
Reimplemented from getArcReferencePoints.
getArea
Section titled “getArea”double RCircle::getArea() constconst
Returns: Area of the circle (π * radius²).
getBoundingBox
Section titled “getBoundingBox”virtual RBox RCircle::getBoundingBox() constvirtual const
Returns: Axis-aligned bounding box (square of side 2*radius centred on center).
Reimplemented from getBoundingBox.
getCenter
Section titled “getCenter”RVector RCircle::getCenter() constconst
Returns: Center point of the circle.
getCenterPoints
Section titled “getCenterPoints”virtual QList< RVector > RCircle::getCenterPoints() constvirtual const
Returns: List containing the center point of the circle.
Reimplemented from getCenterPoints.
getCircumference
Section titled “getCircumference”double RCircle::getCircumference() constconst
Returns: Circumference of the circle (2 * π * radius).
getDiameter
Section titled “getDiameter”double RCircle::getDiameter() constconst
Returns: Diameter (2 * radius).
getDistanceTo
Section titled “getDistanceTo”virtual double RCircle::getDistanceTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) constvirtual const
Returns: Distance from point to the nearest point on the circle. The radius for a point at the center (infinite solutions). limited and strictRange are ignored (circles are unlimited).
Reimplemented from getDistanceTo.
getDoubleProperties
Section titled “getDoubleProperties”virtual QList< double > RCircle::getDoubleProperties() constvirtual const
Returns: List of scalar properties: radius.
Reimplemented from getDoubleProperties.
getEndPoints
Section titled “getEndPoints”virtual QList< RVector > RCircle::getEndPoints() constvirtual const
Returns: Empty list — circles have no endpoint snaps.
Reimplemented from getEndPoints.
getLength
Section titled “getLength”virtual double RCircle::getLength() constvirtual const
Returns: Circumference (same as getCircumference()).
Reimplemented from getLength.
getMiddlePoints
Section titled “getMiddlePoints”virtual QList< RVector > RCircle::getMiddlePoints() constvirtual const
Returns: Empty list — circles have no midpoint snaps.
Reimplemented from getMiddlePoints.
getOffsetShapes
Section titled “getOffsetShapes”virtual QList< QSharedPointer< RShape > > RCircle::getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid)virtual inline
Returns: Parallels to this shape.
Parameters:
distance: Distance of first parallel or concentric arc or circle.number: Number of offset shapes to generate.side: Side, should be RS.LeftHand or RS.RightHand or RS.BothSides.sidePosition: Position indicating what side of the shape the parallels should be.
Reimplemented from getOffsetShapes.
getPointAtAngle
Section titled “getPointAtAngle”RVector RCircle::getPointAtAngle(double a) constconst
Returns: Point on the circle at angle a (radians), preserving the center’s Z coordinate.
getPointCloud
Section titled “getPointCloud”virtual QList< RVector > RCircle::getPointCloud(double segmentLength) constvirtual const
Returns: Dense set of sample points around the full circle. Delegates to RArc::getPointCloud.
Reimplemented from getPointCloud.
getPointOnShape
Section titled “getPointOnShape”virtual RVector RCircle::getPointOnShape() constvirtual const
Returns: The rightmost point of the circle (center + radius along X).
Reimplemented from getPointOnShape.
getPointsWithDistanceToEnd
Section titled “getPointsWithDistanceToEnd”virtual QList< RVector > RCircle::getPointsWithDistanceToEnd(double distance, int from=RS::FromAny) constvirtual const
Returns: Empty list — circles have no meaningful distance-to-end notion.
Reimplemented from getPointsWithDistanceToEnd.
getRadius
Section titled “getRadius”double RCircle::getRadius() constconst
Returns: Radius of the circle.
getShapeType
Section titled “getShapeType”virtual RShape::Type RCircle::getShapeType() constvirtual inline const
Reimplemented from getShapeType.
getTangents
Section titled “getTangents”QList< RLine > RCircle::getTangents(const RVector &point) constconst
Returns: The (up to two) tangent lines from point to this circle. Uses the Thales circle construction: the tangent points are the intersections of this circle with the circle whose diameter is the segment from point to the center. Returns an empty list if point is inside the circle. The condition thalesRadius < radius/2 is equivalent to distance(point, center) < radius (point inside circle).
getTransformed
Section titled “getTransformed”virtual QSharedPointer< RShape > RCircle::getTransformed(const QTransform &transform) constvirtual const
Returns: A new circle obtained by applying the 2D affine transform to the center and deriving the new radius from the transformed rightmost point.
Reimplemented from getTransformed.
getVectorProperties
Section titled “getVectorProperties”virtual QList< RVector > RCircle::getVectorProperties() constvirtual const
Returns: List containing the center point (used for property-based transformations).
Reimplemented from getVectorProperties.
getVectorTo
Section titled “getVectorTo”virtual RVector RCircle::getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) constvirtual const
Returns: Vector from the nearest point on the circle to point. Returns RVector::invalid if point is at the center (infinite solutions). limited and strictRange are ignored (circles are unlimited).
Reimplemented from getVectorTo.
Reimplemented in getVectorTo.
isValid
Section titled “isValid”virtual bool RCircle::isValid() constvirtual inline const
Reimplemented from isValid.
Reimplemented in isValid.
mirror
Section titled “mirror”virtual bool RCircle::mirror(const RLine &axis)virtual
Mirrors the circle center about axis (radius is invariant).
Reimplemented from mirror.
Reimplemented in mirror.
virtual bool RCircle::move(const RVector &offset)virtual
Moves the circle by offset.
Returns false if the offset is invalid or negligibly small. Uses squared magnitude to avoid a sqrt call; tolerance is squared accordingly.
Reimplemented from move.
Reimplemented in move.
rotate
Section titled “rotate”virtual bool RCircle::rotate(double rotation, const RVector ¢er=RDEFAULT_RVECTOR)virtual
Rotates the circle center around c by rotation radians (radius is invariant).
Reimplemented from rotate.
Reimplemented in rotate.
virtual bool RCircle::scale(const RVector &scaleFactors, const RVector ¢er=RDEFAULT_RVECTOR)virtual
Scales the circle by scaleFactors relative to c.
Only scaleFactors.x is used for the radius (uniform XY scaling assumed).
Reimplemented from scale.
Reimplemented in scale.
setArea
Section titled “setArea”void RCircle::setArea(double a)Sets the radius to match the given area.
setCenter
Section titled “setCenter”void RCircle::setCenter(const RVector &vector)Sets the center point of the circle.
setCircumference
Section titled “setCircumference”void RCircle::setCircumference(double c)Sets the radius to match the given circumference.
setDiameter
Section titled “setDiameter”void RCircle::setDiameter(double d)Sets the radius from a diameter value.
setRadius
Section titled “setRadius”void RCircle::setRadius(double radius)Sets the radius of the circle.
virtual void RCircle::setZ(double z)virtual
Sets the Z coordinate of the center point.
Reimplemented from setZ.
Reimplemented in setZ.
splitAt
Section titled “splitAt”virtual QList< QSharedPointer< RShape > > RCircle::splitAt(const QList< RVector > &points) constvirtual const
Splits the circle at the given points, returning a list of RArc segments.
Points are sorted by angle from the first split point. The result is a set of arcs that together cover the full circle.
Reimplemented from splitAt.
RArc RCircle::toArc(double startAngle=0.0) constconst
Returns: An RArc covering the full circle, starting at startAngle.
createFrom2Points
Section titled “createFrom2Points”static RCircle RCircle::createFrom2Points(const RVector &p1, const RVector &p2)static
Creates a circle with the given two points as diameter endpoints.
The center is the midpoint and the radius is half the distance.
createFrom3Points
Section titled “createFrom3Points”static RCircle RCircle::createFrom3Points(const RVector &p1, const RVector &p2, const RVector &p3)static
Creates a circle through three points by finding the intersection of the perpendicular bisectors of the two chords p1–p2 and p2–p3.
Returns an invalid circle if the three points are collinear.
center
Section titled “center”RVector RCircle::centerGetter function for this property: getCenter.
Setter function for this property: setCenter
radius
Section titled “radius”double RCircle::radiusGetter function for this property: getRadius.
Setter function for this property: setRadius
virtual void RCircle::print(QDebug dbg) constvirtual const protected
Prints circle properties to dbg for debugging.
Reimplemented from print.