Skip to content

RCircle

Class in Math Module
Header: #include <src/core/math/RCircle.h>
Inherits: RShape
Inherited by: RCircleData

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.

RCircle()
RCircle(const RVector &center, 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 &center=RDEFAULT_RVECTOR)
Rotates the circle center around c by rotation radians (radius is invariant).
virtual bool scale(const RVector &scaleFactors, const RVector &center=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) const
Splits the circle at the given points, returning a list of RArc segments.
RArc toArc(double startAngle=0.0) const
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.
RVector center
Getter function for this property: getCenter.
double radius
Getter function for this property: getRadius.
virtual void print(QDebug dbg) const
Prints circle properties to dbg for debugging.

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::RCircle(const RVector &center, const double radius)

Creates a circle from a center point and radius.

RCircle::RCircle(double cx, double cy, const double radius)

Creates a circle from center coordinates and radius.

virtual RCircle::~RCircle()

virtual

virtual QSharedPointer< RShape > RCircle::clone() const

virtual inline const

Reimplemented from clone.

QSharedPointer< RCircle > RCircle::cloneToCircle() const

inline const

bool RCircle::contains(const RVector &p) const

const

Returns: True if p is strictly inside the circle (distance to center < radius).

virtual bool RCircle::flipHorizontal()

virtual

Flips the circle center horizontally (negates X; radius is invariant).

Reimplemented from flipHorizontal.

Reimplemented in flipHorizontal.

virtual bool RCircle::flipVertical()

virtual

Flips the circle center vertically (negates Y; radius is invariant).

Reimplemented from flipVertical.

Reimplemented in flipVertical.

virtual double RCircle::getAngleAt(double distance, RS::From from=RS::FromStart) const

virtual const

Returns: RNANDOUBLE — circles have no defined tangent direction at a parametric distance (they have no start point).

Reimplemented from getAngleAt.

virtual QList< RVector > RCircle::getArcReferencePoints() const

virtual const

Returns: The four quadrant points (0°, 90°, 180°, 270°) as snappable reference points.

Reimplemented from getArcReferencePoints.

double RCircle::getArea() const

const

Returns: Area of the circle (π * radius²).

virtual RBox RCircle::getBoundingBox() const

virtual const

Returns: Axis-aligned bounding box (square of side 2*radius centred on center).

Reimplemented from getBoundingBox.

RVector RCircle::getCenter() const

const

Returns: Center point of the circle.

virtual QList< RVector > RCircle::getCenterPoints() const

virtual const

Returns: List containing the center point of the circle.

Reimplemented from getCenterPoints.

double RCircle::getCircumference() const

const

Returns: Circumference of the circle (2 * π * radius).

double RCircle::getDiameter() const

const

Returns: Diameter (2 * radius).

virtual double RCircle::getDistanceTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const

virtual 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.

virtual QList< double > RCircle::getDoubleProperties() const

virtual const

Returns: List of scalar properties: radius.

Reimplemented from getDoubleProperties.

virtual QList< RVector > RCircle::getEndPoints() const

virtual const

Returns: Empty list — circles have no endpoint snaps.

Reimplemented from getEndPoints.

virtual double RCircle::getLength() const

virtual const

Returns: Circumference (same as getCircumference()).

Reimplemented from getLength.

virtual QList< RVector > RCircle::getMiddlePoints() const

virtual const

Returns: Empty list — circles have no midpoint snaps.

Reimplemented from getMiddlePoints.

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.

RVector RCircle::getPointAtAngle(double a) const

const

Returns: Point on the circle at angle a (radians), preserving the center’s Z coordinate.

virtual QList< RVector > RCircle::getPointCloud(double segmentLength) const

virtual const

Returns: Dense set of sample points around the full circle. Delegates to RArc::getPointCloud.

Reimplemented from getPointCloud.

virtual RVector RCircle::getPointOnShape() const

virtual const

Returns: The rightmost point of the circle (center + radius along X).

Reimplemented from getPointOnShape.

virtual QList< RVector > RCircle::getPointsWithDistanceToEnd(double distance, int from=RS::FromAny) const

virtual const

Returns: Empty list — circles have no meaningful distance-to-end notion.

Reimplemented from getPointsWithDistanceToEnd.

double RCircle::getRadius() const

const

Returns: Radius of the circle.

virtual RShape::Type RCircle::getShapeType() const

virtual inline const

Reimplemented from getShapeType.

QList< RLine > RCircle::getTangents(const RVector &point) const

const

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).

virtual QSharedPointer< RShape > RCircle::getTransformed(const QTransform &transform) const

virtual 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.

virtual QList< RVector > RCircle::getVectorProperties() const

virtual const

Returns: List containing the center point (used for property-based transformations).

Reimplemented from getVectorProperties.

virtual RVector RCircle::getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const

virtual 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.

virtual bool RCircle::isValid() const

virtual inline const

Reimplemented from isValid.

Reimplemented in isValid.

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.

virtual bool RCircle::rotate(double rotation, const RVector &center=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 &center=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.

void RCircle::setArea(double a)

Sets the radius to match the given area.

void RCircle::setCenter(const RVector &vector)

Sets the center point of the circle.

void RCircle::setCircumference(double c)

Sets the radius to match the given circumference.

void RCircle::setDiameter(double d)

Sets the radius from a diameter value.

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.

virtual QList< QSharedPointer< RShape > > RCircle::splitAt(const QList< RVector > &points) const

virtual 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) const

const

Returns: An RArc covering the full circle, starting at startAngle.

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.

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.

RVector RCircle::center

Getter function for this property: getCenter.

Setter function for this property: setCenter

double RCircle::radius

Getter function for this property: getRadius.

Setter function for this property: setRadius

virtual void RCircle::print(QDebug dbg) const

virtual const protected

Prints circle properties to dbg for debugging.

Reimplemented from print.