REllipse
Class in Math Module
Header: #include <src/core/math/REllipse.h>
Inherits: RShape
Inherited by: REllipseData
Description
Section titled “Description”Low-level mathematical representation of an ellipse or ellipse arc.
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”REllipse()Creates an ellipse shape with invalid. |
|
REllipse(const RVector ¢er, const RVector &majorPoint, double ratio, double startParam, double endParam, bool reversed) |
|
| virtual | ~REllipse() |
| double | angleToParam(double a) const |
| RPolyline | approximateWithArcs(int segments) const |
| QList< RSpline > | approximateWithSplines() const |
| virtual QSharedPointer< RShape > | clone() const |
| QSharedPointer< REllipse > | cloneToEllipse() const |
| bool | contains(const RVector &p) const |
| void | correctMajorMinor()Makes sure that the major axis of this ellipse is at least as long as its minor axis by switching the two axes if necessary. |
| double | getAngle() const |
| virtual double | getAngleAt(double distance, RS::From from=RS::FromStart) const |
| virtual double | getAngleAtPoint(const RVector &pos) const |
| double | getAngleLength(bool allowForZeroLength=false) const |
| virtual QList< bool > | getBoolProperties() const |
| virtual RBox | getBoundingBox() const |
| QList< RVector > | getBoxCorners() |
| RVector | getCenter() const |
| virtual QList< RVector > | getCenterPoints() const |
| virtual double | getDirection1() const |
| virtual double | getDirection2() const |
| virtual double | getDistanceFromStart(const RVector &p) const |
| virtual QList< double > | getDoubleProperties() const |
| double | getEndAngle() const |
| double | getEndParam() const |
| virtual RVector | getEndPoint() const |
| virtual QList< RVector > | getEndPoints() const |
| QList< RVector > | getFoci() const |
| virtual double | getLength() const |
| RVector | getMajorPoint() const |
| double | getMajorRadius() const |
| virtual RVector | getMiddlePoint() const |
| virtual QList< RVector > | getMiddlePoints() const |
| RVector | getMinorPoint() const |
| double | getMinorRadius() const |
| virtual QList< QSharedPointer< RShape > > | getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid) |
| double | getParamTo(const RVector &pos) const |
| RVector | getPointAt(double param) const |
| virtual QList< RVector > | getPointCloud(double segmentLength) const |
| virtual RVector | getPointOnShape() const |
| virtual QList< RVector > | getPointsWithDistanceToEnd(double distance, int from=RS::FromAny) const |
| double | getRadiusAt(double param) const |
| double | getRatio() const |
| virtual RShape::Type | getShapeType() const |
| virtual RS::Side | getSideOfPoint(const RVector &point) const |
| double | getSimpsonLength(double f1, double f2) const |
| double | getStartAngle() const |
| double | getStartParam() const |
| virtual RVector | getStartPoint() const |
| double | getSweep() const |
| RVector | getTangentPoint(const RLine &line) const |
| QList< RLine > | getTangents(const RVector &point) const |
| virtual QSharedPointer< RShape > | getTransformed(const QTransform &transform) const |
| virtual RS::Ending | getTrimEnd(const RVector &trimPoint, const RVector &clickPoint) |
| virtual QList< RVector > | getVectorProperties() const |
| virtual RVector | getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const |
| bool | isAngleWithinArc(double a) const |
| bool | isCircular() const |
| virtual bool | isDirected() const |
| bool | isFullEllipse() const |
| bool | isParamWithinArc(double a) const |
| bool | isReversed() const |
| virtual bool | isValid() const |
| virtual bool | mirror(const RLine &axis) |
| virtual bool | move(const RVector &offset) |
| void | moveEndPoint(const RVector &pos, bool changeAngleOnly=false) |
| void | moveStartPoint(const RVector &pos, bool changeAngleOnly=false) |
| virtual bool | reverse() |
| virtual bool | rotate(double rotation, const RVector ¢er=RDEFAULT_RVECTOR) |
| virtual bool | scale(const RVector &scaleFactors, const RVector ¢er=RDEFAULT_RVECTOR) |
| void | setAngle(double a)Sets the rotation angle of this ellipse without changing the major radius. |
| void | setCenter(const RVector &vector) |
| void | setEndAngle(double a) |
| void | setEndParam(double endParam) |
| void | setMajorPoint(const RVector &vector)Sets the major point relative to the center point. |
| void | setMinorPoint(const RVector &p)Sets the minor point relative to the center point. |
| void | setRatio(double radius) |
| void | setReversed(bool reversed) |
| void | setStartAngle(double a) |
| void | setStartParam(double startParam) |
| virtual void | setZ(double z) |
| virtual QList< QSharedPointer< RShape > > | splitAt(const QList< RVector > &points) const |
| bool | switchMajorMinor()Switches the major and the minor axis of this ellipse. |
| virtual bool | trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false) |
| virtual bool | trimEndPoint(double trimDist) |
| virtual bool | trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false) |
| virtual bool | trimStartPoint(double trimDist) |
Static Public Functions
Section titled “Static Public Functions”| static REllipse | createFrom4Points(const RVector &p1, const RVector &p2, const RVector &p3, const RVector &p4) |
| static REllipse | createInscribed(const RVector &p1, const RVector &p2, const RVector &p3, const RVector &p4, const RVector ¢erHint=RVector::invalid)Produces an ellipse inscribed in the quadrilateral defined by the four given ordered vertices (RVector). |
| static REllipseProxy * | getEllipseProxy() |
| static bool | hasProxy() |
| static void | setEllipseProxy(REllipseProxy *p) |
Public Attributes
Section titled “Public Attributes”| RVector | center Getter function for this property: getCenter. |
| double | endParam Getter function for this property: getEndParam. |
| RVector | majorPoint Getter function for this property: getMajorPoint. |
| double | ratio Getter function for this property: getRatio. |
| bool | reversed Getter function for this property: isReversed. |
| double | startParam Getter function for this property: getStartParam. |
Protected Functions
Section titled “Protected Functions”| virtual void | print(QDebug dbg) const |
Static Private Attributes
Section titled “Static Private Attributes”| static REllipseProxy * | ellipseProxy |
Member Documentation
Section titled “Member Documentation”REllipse
Section titled “REllipse”REllipse::REllipse()Creates an ellipse shape with invalid.
REllipse
Section titled “REllipse”REllipse::REllipse(const RVector ¢er, const RVector &majorPoint, double ratio, double startParam, double endParam, bool reversed)~REllipse
Section titled “~REllipse”virtual REllipse::~REllipse()virtual
angleToParam
Section titled “angleToParam”double REllipse::angleToParam(double a) constconst
approximateWithArcs
Section titled “approximateWithArcs”RPolyline REllipse::approximateWithArcs(int segments) constconst
approximateWithSplines
Section titled “approximateWithSplines”QList< RSpline > REllipse::approximateWithSplines() constconst
virtual QSharedPointer< RShape > REllipse::clone() constvirtual inline const
Reimplemented from clone.
cloneToEllipse
Section titled “cloneToEllipse”QSharedPointer< REllipse > REllipse::cloneToEllipse() constinline const
contains
Section titled “contains”bool REllipse::contains(const RVector &p) constconst
correctMajorMinor
Section titled “correctMajorMinor”void REllipse::correctMajorMinor()Makes sure that the major axis of this ellipse is at least as long as its minor axis by switching the two axes if necessary.
getAngle
Section titled “getAngle”double REllipse::getAngle() constconst
Returns: The rotation angle of this ellipse.
getAngleAt
Section titled “getAngleAt”virtual double REllipse::getAngleAt(double distance, RS::From from=RS::FromStart) constvirtual const
Returns: Angle on the entity at the given distance from the start point.
Reimplemented from getAngleAt.
getAngleAtPoint
Section titled “getAngleAtPoint”virtual double REllipse::getAngleAtPoint(const RVector &pos) constvirtual const
Reimplemented from getAngleAtPoint.
getAngleLength
Section titled “getAngleLength”double REllipse::getAngleLength(bool allowForZeroLength=false) constconst
Returns: Angle length in rad.
getBoolProperties
Section titled “getBoolProperties”virtual QList< bool > REllipse::getBoolProperties() constvirtual const
Reimplemented from getBoolProperties.
getBoundingBox
Section titled “getBoundingBox”virtual RBox REllipse::getBoundingBox() constvirtual const
Returns: The bounding box of this shape.
Reimplemented from getBoundingBox.
getBoxCorners
Section titled “getBoxCorners”QList< RVector > REllipse::getBoxCorners()getCenter
Section titled “getCenter”RVector REllipse::getCenter() constconst
getCenterPoints
Section titled “getCenterPoints”virtual QList< RVector > REllipse::getCenterPoints() constvirtual const
Returns: The center point(s) of this shape.
Reimplemented from getCenterPoints.
getDirection1
Section titled “getDirection1”virtual double REllipse::getDirection1() constvirtual const
Reimplemented from getDirection1.
getDirection2
Section titled “getDirection2”virtual double REllipse::getDirection2() constvirtual const
Reimplemented from getDirection2.
getDistanceFromStart
Section titled “getDistanceFromStart”virtual double REllipse::getDistanceFromStart(const RVector &p) constvirtual const
Returns: Arc length distance from the start point of this ellipse (arc) to the given point, measured along the ellipse in the direction of the shape.
Parameters:
p: Point (assumed to be on the shape).
Reimplemented from getDistanceFromStart.
getDoubleProperties
Section titled “getDoubleProperties”virtual QList< double > REllipse::getDoubleProperties() constvirtual const
Reimplemented from getDoubleProperties.
getEndAngle
Section titled “getEndAngle”double REllipse::getEndAngle() constconst
Returns: End angle: the angle from the ellipse arc center to the ellipse arc end point.
getEndParam
Section titled “getEndParam”double REllipse::getEndParam() constconst
Returns: End parameter: the end angle of the circular arc resulting from transforming the ellipse into a circle.
getEndPoint
Section titled “getEndPoint”virtual RVector REllipse::getEndPoint() constvirtual const
Reimplemented from getEndPoint.
getEndPoints
Section titled “getEndPoints”virtual QList< RVector > REllipse::getEndPoints() constvirtual const
Returns: The end point(s) of this shape.
Reimplemented from getEndPoints.
getFoci
Section titled “getFoci”QList< RVector > REllipse::getFoci() constconst
getLength
Section titled “getLength”virtual double REllipse::getLength() constvirtual const
Returns: Approximation for ellipse arc length.
Reimplemented from getLength.
Reimplemented in getLength.
getMajorPoint
Section titled “getMajorPoint”RVector REllipse::getMajorPoint() constconst
Returns: Major point relative to the center point.
getMajorRadius
Section titled “getMajorRadius”double REllipse::getMajorRadius() constconst
Returns: The major radius of this ellipse.
getMiddlePoint
Section titled “getMiddlePoint”virtual RVector REllipse::getMiddlePoint() constvirtual const
Reimplemented from getMiddlePoint.
getMiddlePoints
Section titled “getMiddlePoints”virtual QList< RVector > REllipse::getMiddlePoints() constvirtual const
Returns: Middle point of the ellipse arc (at half its arc length). Empty for full ellipses or if no ellipse proxy is available.
Reimplemented from getMiddlePoints.
getMinorPoint
Section titled “getMinorPoint”RVector REllipse::getMinorPoint() constconst
Returns: Minor point relative to the center point.
getMinorRadius
Section titled “getMinorRadius”double REllipse::getMinorRadius() constconst
Returns: The minor radius of this ellipse.
getOffsetShapes
Section titled “getOffsetShapes”virtual QList< QSharedPointer< RShape > > REllipse::getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid)virtual
Returns: Array of spline shapes representing the parallel curves to this ellipse shape.
Reimplemented from getOffsetShapes.
getParamTo
Section titled “getParamTo”double REllipse::getParamTo(const RVector &pos) constconst
getPointAt
Section titled “getPointAt”RVector REllipse::getPointAt(double param) constconst
Returns: Point on ellipse at given ellipse angle.
getPointCloud
Section titled “getPointCloud”virtual QList< RVector > REllipse::getPointCloud(double segmentLength) constvirtual const
Reimplemented from getPointCloud.
getPointOnShape
Section titled “getPointOnShape”virtual RVector REllipse::getPointOnShape() constvirtual const
Reimplemented from getPointOnShape.
getPointsWithDistanceToEnd
Section titled “getPointsWithDistanceToEnd”virtual QList< RVector > REllipse::getPointsWithDistanceToEnd(double distance, int from=RS::FromAny) constvirtual const
Returns: Point(s) on the ellipse at arc length distance from the start and / or end, controlled by the from bitmask (RS::FromStart, RS::FromEnd, RS::FromAny). Empty if no ellipse proxy is available.
Reimplemented from getPointsWithDistanceToEnd.
getRadiusAt
Section titled “getRadiusAt”double REllipse::getRadiusAt(double param) constconst
Returns: Radius of ellipse at given ellipse angle.
getRatio
Section titled “getRatio”double REllipse::getRatio() constconst
getShapeType
Section titled “getShapeType”virtual RShape::Type REllipse::getShapeType() constvirtual inline const
Reimplemented from getShapeType.
getSideOfPoint
Section titled “getSideOfPoint”virtual RS::Side REllipse::getSideOfPoint(const RVector &point) constvirtual const
Reimplemented from getSideOfPoint.
getSimpsonLength
Section titled “getSimpsonLength”double REllipse::getSimpsonLength(double f1, double f2) constconst
Returns: Length of the ellipse segment from angle a1 to angle a2.
getStartAngle
Section titled “getStartAngle”double REllipse::getStartAngle() constconst
Returns: Start angle: the angle from the ellipse arc center to the ellipse arc start point.
getStartParam
Section titled “getStartParam”double REllipse::getStartParam() constconst
Returns: Start parameter: the start angle of the circular arc resulting from transforming the ellipse into a circle.
getStartPoint
Section titled “getStartPoint”virtual RVector REllipse::getStartPoint() constvirtual const
Reimplemented from getStartPoint.
getSweep
Section titled “getSweep”double REllipse::getSweep() constconst
Returns: Arc sweep in rad. The sweep is the angle covered by this arc. Positive for ccw, negative for cw.
getTangentPoint
Section titled “getTangentPoint”RVector REllipse::getTangentPoint(const RLine &line) constconst
getTangents
Section titled “getTangents”QList< RLine > REllipse::getTangents(const RVector &point) constconst
getTransformed
Section titled “getTransformed”virtual QSharedPointer< RShape > REllipse::getTransformed(const QTransform &transform) constvirtual const
Reimplemented from getTransformed.
getTrimEnd
Section titled “getTrimEnd”virtual RS::Ending REllipse::getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)virtual
Parameters:
trimPoint: Trim start point or end point to this coordinate.clickPoint: Point that was clicked by user.
Reimplemented from getTrimEnd.
getVectorProperties
Section titled “getVectorProperties”virtual QList< RVector > REllipse::getVectorProperties() constvirtual const
Reimplemented from getVectorProperties.
getVectorTo
Section titled “getVectorTo”virtual RVector REllipse::getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) constvirtual const
Returns: Vector from the closest point on this ellipse to the given point or an invalid vector if there is no such point.
Parameters:
limited: True to only consider the ellipse arc from start to end parameter, false to consider the full ellipse.
The closest point is found with a fixed point iteration which exploits the evolute of the ellipse and needs no trigonometric functions, followed by a Newton refinement of the parametric angle. Points in line with one of the two axes and degenerate ellipses are handled separately.
The iteration was contributed as a proof of concept by CVH in the QCAD forum thread “REllipse.getVectorTo(p) exceptions (FS#2564)”, based on the method of Carl Chatfield and a trigonometry free variant of it by Adrian Stephens: https://forum.qcad.org/t/rellipse-getvectorto-p-exceptions-fs-2564/9284 https://blog.chatfield.io/simple-method-for-distance-to-ellipse/ https://github.com/0xfaded/ellipse_demo/issues/1
Reimplemented from getVectorTo.
Reimplemented in getVectorTo.
isAngleWithinArc
Section titled “isAngleWithinArc”bool REllipse::isAngleWithinArc(double a) constinline const
isCircular
Section titled “isCircular”bool REllipse::isCircular() constconst
Returns: True if minor radius and major radius are equal, i.e. ratio is 1.0.
isDirected
Section titled “isDirected”virtual bool REllipse::isDirected() constvirtual inline const
Reimplemented from isDirected.
isFullEllipse
Section titled “isFullEllipse”bool REllipse::isFullEllipse() constconst
isParamWithinArc
Section titled “isParamWithinArc”bool REllipse::isParamWithinArc(double a) constinline const
isReversed
Section titled “isReversed”bool REllipse::isReversed() constconst
isValid
Section titled “isValid”virtual bool REllipse::isValid() constvirtual const
Reimplemented from isValid.
Reimplemented in isValid.
mirror
Section titled “mirror”virtual bool REllipse::mirror(const RLine &axis)virtual
Reimplemented from mirror.
Reimplemented in mirror.
virtual bool REllipse::move(const RVector &offset)virtual
Reimplemented from move.
Reimplemented in move.
moveEndPoint
Section titled “moveEndPoint”void REllipse::moveEndPoint(const RVector &pos, bool changeAngleOnly=false)moveStartPoint
Section titled “moveStartPoint”void REllipse::moveStartPoint(const RVector &pos, bool changeAngleOnly=false)reverse
Section titled “reverse”virtual bool REllipse::reverse()virtual
Reimplemented from reverse.
Reimplemented in reverse.
rotate
Section titled “rotate”virtual bool REllipse::rotate(double rotation, const RVector ¢er=RDEFAULT_RVECTOR)virtual
Reimplemented from rotate.
Reimplemented in rotate.
virtual bool REllipse::scale(const RVector &scaleFactors, const RVector ¢er=RDEFAULT_RVECTOR)virtual
Reimplemented from scale.
Reimplemented in scale.
setAngle
Section titled “setAngle”void REllipse::setAngle(double a)Sets the rotation angle of this ellipse without changing the major radius.
setCenter
Section titled “setCenter”void REllipse::setCenter(const RVector &vector)setEndAngle
Section titled “setEndAngle”void REllipse::setEndAngle(double a)setEndParam
Section titled “setEndParam”void REllipse::setEndParam(double endParam)setMajorPoint
Section titled “setMajorPoint”void REllipse::setMajorPoint(const RVector &vector)Sets the major point relative to the center point.
setMinorPoint
Section titled “setMinorPoint”void REllipse::setMinorPoint(const RVector &p)Sets the minor point relative to the center point.
setRatio
Section titled “setRatio”void REllipse::setRatio(double radius)setReversed
Section titled “setReversed”void REllipse::setReversed(bool reversed)setStartAngle
Section titled “setStartAngle”void REllipse::setStartAngle(double a)setStartParam
Section titled “setStartParam”void REllipse::setStartParam(double startParam)virtual void REllipse::setZ(double z)virtual
Reimplemented from setZ.
Reimplemented in setZ.
splitAt
Section titled “splitAt”virtual QList< QSharedPointer< RShape > > REllipse::splitAt(const QList< RVector > &points) constvirtual const
Returns: Array of shapes which represent the given shape split up at the given points.
Parameters:
points: Array of RVector, assumed to be on shape.
Reimplemented from splitAt.
switchMajorMinor
Section titled “switchMajorMinor”bool REllipse::switchMajorMinor()Switches the major and the minor axis of this ellipse.
The ellipse remains unchanged, only its representation changes: the ratio is inverted and the parameters are adjusted accordingly.
Returns: False for a ratio of zero or a negative (invalid) ratio.
trimEndPoint
Section titled “trimEndPoint”virtual bool REllipse::trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)virtual
Parameters:
trimPoint: Trim start point or end point to this coordinate.clickPoint: Point that was clicked by user.extend: True if the shape is to be extended. Used for polylines to determine that the last segment has to be trimmed even if another segment was clicked.
Reimplemented from trimEndPoint.
trimEndPoint
Section titled “trimEndPoint”virtual bool REllipse::trimEndPoint(double trimDist)virtual inline
Reimplemented from trimEndPoint.
trimStartPoint
Section titled “trimStartPoint”virtual bool REllipse::trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)virtual
Parameters:
trimPoint: Trim start point or end point to this coordinate.clickPoint: Point that was clicked by user.extend: True if the shape is to be extended. Used for polylines to determine that the first segment has to be trimmed even if another segment was clicked.
Reimplemented from trimStartPoint.
trimStartPoint
Section titled “trimStartPoint”virtual bool REllipse::trimStartPoint(double trimDist)virtual inline
Reimplemented from trimStartPoint.
createFrom4Points
Section titled “createFrom4Points”static REllipse REllipse::createFrom4Points(const RVector &p1, const RVector &p2, const RVector &p3, const RVector &p4)static
createInscribed
Section titled “createInscribed”static REllipse REllipse::createInscribed(const RVector &p1, const RVector &p2, const RVector &p3, const RVector &p4, const RVector ¢erHint=RVector::invalid)static
Produces an ellipse inscribed in the quadrilateral defined by the four given ordered vertices (RVector).
Parameters:
centerHint: Hint for the position of the center (e.g. mouse cursor for interactive tools) or invalid for maximum area solution.
Returns: Inscribed ellipse or invalid ellipse.
getEllipseProxy
Section titled “getEllipseProxy”static REllipseProxy * REllipse::getEllipseProxy()static inline
Non-Scriptable: This function is not available in script environments.
hasProxy
Section titled “hasProxy”static bool REllipse::hasProxy()static inline
setEllipseProxy
Section titled “setEllipseProxy”static void REllipse::setEllipseProxy(REllipseProxy *p)static inline
Non-Scriptable: This function is not available in script environments.
center
Section titled “center”RVector REllipse::centerGetter function for this property: getCenter.
Setter function for this property: setCenter
endParam
Section titled “endParam”double REllipse::endParamGetter function for this property: getEndParam.
Setter function for this property: setEndParam
majorPoint
Section titled “majorPoint”RVector REllipse::majorPointGetter function for this property: getMajorPoint.
Setter function for this property: setMajorPoint
double REllipse::ratioGetter function for this property: getRatio.
Setter function for this property: setRatio
reversed
Section titled “reversed”bool REllipse::reversedGetter function for this property: isReversed.
Setter function for this property: setReversed
startParam
Section titled “startParam”double REllipse::startParamGetter function for this property: getStartParam.
Setter function for this property: setStartParam
virtual void REllipse::print(QDebug dbg) constvirtual const protected
Reimplemented from print.
ellipseProxy
Section titled “ellipseProxy”static REllipseProxy * REllipse::ellipseProxy = NULLstatic private
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.