Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Geom::EllipticalArc Class Reference

Elliptical arc curve. More...

#include <elliptical-arc.h>

Inheritance diagram for Geom::EllipticalArc:
Geom::Curve

Public Member Functions

 EllipticalArc ()
 Creates an arc with all variables set to zero.
 
 EllipticalArc (Point const &ip, Point const &r, Coord rot_angle, bool large_arc, bool sweep, Point const &fp)
 Create a new elliptical arc.
 
 EllipticalArc (Point const &ip, Coord rx, Coord ry, Coord rot_angle, bool large_arc, bool sweep, Point const &fp)
 Create a new elliptical arc, giving the ellipse's rays as separate coordinates.
 
Point initialPoint () const override
 Retrieve the start of the curve.
 
Point finalPoint () const override
 Retrieve the end of the curve.
 
Curveduplicate () const override
 Create an exact copy of this curve.
 
void setInitial (Point const &p) override
 Change the starting point of the curve.
 
void setFinal (Point const &p) override
 Change the ending point of the curve.
 
bool isDegenerate () const override
 Check whether the curve has exactly zero length.
 
bool isLineSegment () const override
 Check whether the curve is a line segment.
 
Rect boundsFast () const override
 Quickly compute the curve's approximate bounding box.
 
Rect boundsExact () const override
 Compute bounds of an elliptical arc.
 
void expandToTransformed (Rect &bbox, Affine const &transform) const override
 Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.
 
OptRect boundsLocal (OptInterval const &i, unsigned int deg) const override
 
std::vector< double > roots (double v, Dim2 d) const override
 Computes time values at which the curve intersects an axis-aligned line.
 
std::vector< double > allNearestTimes (Point const &p, double from=0, double to=1) const override
 Compute time values at which the curve comes closest to a specified point.
 
double nearestTime (Point const &p, double from=0, double to=1) const override
 Compute a time value at which the curve comes closest to a specified point.
 
std::vector< CurveIntersectionintersect (Curve const &other, Coord eps=EPSILON) const override
 Compute intersections with another curve.
 
int degreesOfFreedom () const override
 Return the number of independent parameters required to represent all variations of this curve.
 
Curvederivative () const override
 Create a derivative of this curve.
 
void operator*= (Translate const &tr) override
 
void operator*= (Scale const &s) override
 
void operator*= (Rotate const &r) override
 
void operator*= (Zoom const &z) override
 
void operator*= (Affine const &m) override
 
std::vector< PointpointAndDerivatives (Coord t, unsigned int n) const override
 
D2< SBasistoSBasis () const override
 Convert the curve to a symmetric power basis polynomial.
 
Curveportion (double f, double t) const override
 Create a curve that corresponds to a part of this curve.
 
Curvereverse () const override
 Create a reversed version of this curve.
 
bool isNear (Curve const &other, Coord precision) const override
 Test whether two curves are approximately the same.
 
void feed (PathSink &sink, bool moveto_initial) const override
 Feed the curve to a PathSink.
 
int winding (Point const &p) const override
 Compute the partial winding number of this curve.
 
virtual void operator*= (Translate const &tr)
 
virtual void operator*= (Scale const &s)
 
virtual void operator*= (Rotate const &r)
 
virtual void operator*= (HShear const &hs)
 
virtual void operator*= (VShear const &vs)
 
virtual void operator*= (Zoom const &z)
 
virtual void operator*= (Affine const &m)=0
 
Retrieve basic information
Coord center (Dim2 d) const
 Get a coordinate of the elliptical arc's center.
 
Point center () const
 Get the arc's center.
 
Coord ray (Dim2 d) const
 Get one of the ellipse's rays.
 
Point rays () const
 Get both rays as a point.
 
Angle rotationAngle () const
 Get the defining ellipse's rotation.
 
bool largeArc () const
 Whether the arc is larger than half an ellipse.
 
bool sweep () const
 Whether the arc turns clockwise.
 
Angle initialAngle () const
 
Angle finalAngle () const
 
Modify parameters
void set (Point const &ip, double rx, double ry, double rot_angle, bool large_arc, bool sweep, Point const &fp)
 Change all of the arc's parameters.
 
void set (Point const &ip, Point const &r, Angle rot_angle, bool large_arc, bool sweep, Point const &fp)
 Change all of the arc's parameters.
 
void setEndpoints (Point const &ip, Point const &fp)
 Change the initial and final point in one operation.
 
Evaluate the arc as a function
bool containsAngle (Angle angle) const
 Check whether the arc contains the given angle.
 
Point pointAtAngle (Coord t) const
 Evaluate the arc at the specified angular coordinate.
 
Coord valueAtAngle (Coord t, Dim2 d) const
 Evaluate one of the arc's coordinates at the specified angle.
 
Coord timeAtAngle (Angle a) const
 Compute the curve time value corresponding to the given angular value.
 
Angle angleAt (Coord t) const
 Compute the angular domain value corresponding to the given time value.
 
Coord sweepAngle () const
 Compute the amount by which the angle parameter changes going from start to end.
 
Coord angularExtent () const
 Get the elliptical angle spanned by the arc.
 
AngleInterval angularInterval () const
 Get the angular interval of the arc.
 
Point pointAt (Coord t) const override
 Evaluate the arc in the curve domain, i.e. \([0, 1]\).
 
Coord valueAt (Coord t, Dim2 d) const override
 Evaluate a single coordinate on the arc in the curve domain.
 
Affine unitCircleTransform () const
 Compute a transform that maps the unit circle to the arc's ellipse.
 
Affine inverseUnitCircleTransform () const
 Compute a transform that maps the arc's ellipse to the unit circle.
 
Deal with degenerate ellipses.
bool isChord () const
 Check whether both rays are nonzero.
 
LineSegment chord () const
 Get the line segment connecting the arc's endpoints.
 
- Public Member Functions inherited from Geom::Curve
virtual ~Curve ()
 
virtual Interval timeRange () const
 Get the interval of allowed time values.
 
virtual Point operator() (Coord t) const
 Evaluate the function at the specified time value.
 
virtual std::vector< PointpointAndDerivatives (Coord t, unsigned n) const =0
 Evaluate the curve and its derivatives.
 
virtual OptRect boundsLocal (OptInterval const &i, unsigned deg) const =0
 
OptRect boundsLocal (OptInterval const &a) const
 Compute the bounding box of a part of the curve.
 
void transform (Affine const &m)
 Transform this curve by an affine transformation.
 
virtual Curvetransformed (Affine const &m) const
 Create a curve transformed by an affine transformation.
 
Curveportion (Interval const &i) const
 A version of that accepts an Interval.
 
Coord nearestTime (Point const &p, Interval const &i) const
 A version that takes an Interval.
 
std::vector< CoordallNearestTimes (Point const &p, Interval const &i)
 A version that takes an Interval.
 
virtual Coord length (Coord tolerance=0.01) const
 Compute the arc length of this curve.
 
virtual std::vector< CurveIntersectionintersectSelf (Coord eps=EPSILON) const
 Compute intersections of this curve with itself.
 
virtual Point unitTangentAt (Coord t, unsigned n=3) const
 Compute a vector tangent to the curve.
 
bool operator== (Curve const &c) const
 Test equality of two curves.
 

Protected Member Functions

bool _equalTo (Curve const &c) const override
 

Private Member Functions

void _updateCenterAndAngles ()
 
std::vector< ShapeIntersection_filterIntersections (std::vector< ShapeIntersection > &&xs, bool is_first) const
 Convert the passed intersections to curve time parametrization and filter out any invalid intersections.
 
bool _validateIntersection (ShapeIntersection &xing, bool is_first) const
 Convert the passed intersection to curve time and check whether the intersection is numerically sane.
 
std::vector< ShapeIntersection_intersectSameEllipse (EllipticalArc const *other) const
 Check if two arcs on the same ellipse intersect/overlap.
 

Private Attributes

Point _initial_point
 
Point _final_point
 
Ellipse _ellipse
 
AngleInterval _angles
 
bool _large_arc
 

Related Symbols

(Note that these are not member symbols.)

bool arc_from_sbasis (EllipticalArc &ea, D2< SBasis > const &in, double tolerance=EPSILON, unsigned num_samples=20)
 Fit an elliptical arc to an SBasis fragment.
 
std::ostream & operator<< (std::ostream &out, EllipticalArc const &ea)
 Debug output for elliptical arcs.
 

Detailed Description

Elliptical arc curve.

Elliptical arc is a curve taking the shape of a section of an ellipse.

The arc function has two forms: the regular one, mapping the unit interval to points on 2D plane (the linear domain), and a second form that maps some interval \(A \subseteq [0,2\pi)\) to the same points (the angular domain). The interval \(A\) determines which part of the ellipse forms the arc. The arc is said to contain an angle if its angular domain includes that angle (and therefore it is defined for that angle).

The angular domain considers each ellipse to be a rotated, scaled and translated unit circle: 0 corresponds to \((1,0)\) on the unit circle, \(\pi/2\) corresponds to \((0,1)\), \(\pi\) to \((-1,0)\) and \(3\pi/2\) to \((0,-1)\). After the angle is mapped to a point from a unit circle, the point is transformed using a matrix of this form

\[ M = \left[ \begin{array}{ccc} r_X \cos(\theta) & -r_Y \sin(\theta) & 0 \\ r_X \sin(\theta) & r_Y \cos(\theta) & 0 \\ c_X & c_Y & 1 \end{array} \right] \]

where \(r_X, r_Y\) are the X and Y rays of the ellipse, \(\theta\) is its angle of rotation, and \(c_X, c_Y\) the coordinates of the ellipse's center - thus mapping the angle to some point on the ellipse. Note that for example the point at angluar coordinate 0, the center and the point at angular coordinate \(\pi/4\) do not necessarily create an angle of \(\pi/4\) radians; it is only the case if both axes of the ellipse are of the same length (i.e. it is a circle).

An illustration of the angular domain

Each arc is defined by five variables: The initial and final point, the ellipse's rays, and the ellipse's rotation. Each set of those parameters corresponds to four different arcs, with two of them larger than half an ellipse and two of them turning clockwise while traveling from initial to final point. The two flags disambiguate between them: "large arc flag" selects the bigger arc, while the "sweep flag" selects the arc going in the direction of positive angles. Angles always increase when going from the +X axis in the direction of the +Y axis, so if Y grows downwards, this means clockwise.

Meaning of arc flags (Y grows downwards)

Definition at line 52 of file elliptical-arc.h.

Constructor & Destructor Documentation

◆ EllipticalArc() [1/3]

Geom::EllipticalArc::EllipticalArc ( )
inline

Creates an arc with all variables set to zero.

Definition at line 56 of file elliptical-arc.h.

Referenced by duplicate(), and portion().

◆ EllipticalArc() [2/3]

Geom::EllipticalArc::EllipticalArc ( Point const &  ip,
Point const &  r,
Coord  rot_angle,
bool  large_arc,
bool  sweep,
Point const &  fp 
)
inline

Create a new elliptical arc.

Parameters
ipInitial point of the arc
rRays of the ellipse as a point
rotAngle of rotation of the X axis of the ellipse in radians
largeIf true, the large arc is chosen (always >= 180 degrees), otherwise the smaller arc is chosen
sweepIf true, the clockwise arc is chosen, otherwise the counter-clockwise arc is chosen
fpFinal point of the arc

Definition at line 70 of file elliptical-arc.h.

References _updateCenterAndAngles().

◆ EllipticalArc() [3/3]

Geom::EllipticalArc::EllipticalArc ( Point const &  ip,
Coord  rx,
Coord  ry,
Coord  rot_angle,
bool  large_arc,
bool  sweep,
Point const &  fp 
)
inline

Create a new elliptical arc, giving the ellipse's rays as separate coordinates.

Definition at line 84 of file elliptical-arc.h.

References _updateCenterAndAngles().

Member Function Documentation

◆ _equalTo()

bool Geom::EllipticalArc::_equalTo ( Curve const &  c) const
overrideprotectedvirtual

Implements Geom::Curve.

Definition at line 885 of file elliptical-arc.cpp.

References _final_point, _initial_point, _large_arc, c, rays(), rotationAngle(), and sweep().

◆ _filterIntersections()

std::vector< ShapeIntersection > Geom::EllipticalArc::_filterIntersections ( std::vector< ShapeIntersection > &&  xs,
bool  is_first 
) const
private

Convert the passed intersections to curve time parametrization and filter out any invalid intersections.

Definition at line 604 of file elliptical-arc.cpp.

References _validateIntersection(), and result.

Referenced by intersect().

◆ _intersectSameEllipse()

std::vector< ShapeIntersection > Geom::EllipticalArc::_intersectSameEllipse ( EllipticalArc const *  other) const
private

Check if two arcs on the same ellipse intersect/overlap.

Parameters
otherAnother elliptical arc on the same ellipse as this one.
Returns
If the arcs overlap, the returned vector contains synthesized intersections at the start and end of the overlap. If the arcs do not overlap, an empty vector is returned.

A closure to create an "intersection" at the prescribed angle.

Definition at line 686 of file elliptical-arc.cpp.

References _angles, _ellipse, angularInterval(), Geom::AngleInterval::contains(), Geom::AngleInterval::finalAngle(), Geom::AngleInterval::initialAngle(), Geom::Ellipse::pointAt(), result, and timeAtAngle().

Referenced by intersect().

◆ _updateCenterAndAngles()

◆ _validateIntersection()

bool Geom::EllipticalArc::_validateIntersection ( ShapeIntersection xing,
bool  is_first 
) const
private

Convert the passed intersection to curve time and check whether the intersection is numerically sane.

Parameters
xingThe intersection to convert to curve time and to validate.
is_firstIf true, this arc is the first of the intersected curves; if false, it's second.
Returns
Whether the intersection is valid.

Note that the intersection is guaranteed to be converted only if the return value is true.

Definition at line 626 of file elliptical-arc.cpp.

References _ellipse, Geom::are_near_rel(), Geom::GenericInterval< C >::contains(), Geom::Intersection< TimeA, TimeB >::first, Geom::Intersection< TimeA, TimeB >::point(), Geom::Ellipse::pointAt(), pointAt(), Geom::Intersection< TimeA, TimeB >::second, and timeAtAngle().

Referenced by _filterIntersections().

◆ allNearestTimes()

std::vector< double > Geom::EllipticalArc::allNearestTimes ( Point const &  p,
double  from = 0,
double  to = 1 
) const
overridevirtual

Compute time values at which the curve comes closest to a specified point.

Parameters
pQuery point
aMinimum time value to consider
bMaximum time value to consider; \(a < b\)
Returns
Vector of points closest and equally far away from the query point

Reimplemented from Geom::Curve.

Definition at line 373 of file elliptical-arc.cpp.

References Geom::are_near(), center(), Geom::distanceSq(), Geom::BezierCurveN< degree >::nearestTime(), Geom::BezierCurve::pointAt(), pointAt(), pointAtAngle(), ray(), result, roots(), rotationAngle(), Geom::sincos(), Geom::solve_reals(), timeAtAngle(), Geom::X, and Geom::Y.

Referenced by nearestTime().

◆ angleAt()

Angle Geom::EllipticalArc::angleAt ( Coord  t) const
inline

Compute the angular domain value corresponding to the given time value.

Definition at line 204 of file elliptical-arc.h.

References _angles, and Geom::AngleInterval::angleAt().

Referenced by pointAndDerivatives(), pointAt(), portion(), and valueAt().

◆ angularExtent()

Coord Geom::EllipticalArc::angularExtent ( ) const
inline

Get the elliptical angle spanned by the arc.

This is basically the absolute value of sweepAngle().

Definition at line 213 of file elliptical-arc.h.

References _angles, and Geom::AngleInterval::extent().

Referenced by portion().

◆ angularInterval()

AngleInterval Geom::EllipticalArc::angularInterval ( ) const
inline

Get the angular interval of the arc.

Definition at line 216 of file elliptical-arc.h.

References _angles.

Referenced by _intersectSameEllipse().

◆ boundsExact()

Rect Geom::EllipticalArc::boundsExact ( ) const
overridevirtual

Compute bounds of an elliptical arc.

The bounds computation works as follows. The extreme X and Y points are either the endpoints or local minima / maxima of the ellipse. We already have endpoints, and we compute the local extremes. The local extremes correspond to two angles separated by \(\pi\). Once we compute these angles, we check whether they belong to the arc, and if they do, we evaluate the ellipse at these angles. The bounding box of the arc is equal to the bounding box of the endpoints and the local extrema that belong to the arc.

Implements Geom::Curve.

Definition at line 106 of file elliptical-arc.cpp.

References _angles, _ellipse, _final_point, _initial_point, Geom::Ellipse::boundsExact(), Geom::AngleInterval::contains(), isChord(), Geom::AngleInterval::isFull(), result, unitCircleTransform(), Geom::X, and Geom::Y.

Referenced by boundsFast().

◆ boundsFast()

Rect Geom::EllipticalArc::boundsFast ( ) const
inlineoverridevirtual

Quickly compute the curve's approximate bounding box.

The resulting rectangle is guaranteed to contain all points belonging to the curve, but it might not be the smallest such rectangle. This method is usually fast.

Returns
A rectangle that contains all points belonging to the curve.

Implements Geom::Curve.

Definition at line 269 of file elliptical-arc.h.

References boundsExact().

◆ boundsLocal()

OptRect Geom::EllipticalArc::boundsLocal ( OptInterval const &  i,
unsigned int  deg 
) const
inlineoverride

Definition at line 275 of file elliptical-arc.h.

References Geom::SBasisCurve::boundsLocal(), and toSBasis().

◆ center() [1/2]

Point Geom::EllipticalArc::center ( ) const
inline

Get the arc's center.

Returns
The arc's center, situated on the intersection of the ellipse's rays

Definition at line 107 of file elliptical-arc.h.

References _ellipse, and Geom::Ellipse::center().

Referenced by allNearestTimes(), nearestTime(), roots(), and toSBasis().

◆ center() [2/2]

Coord Geom::EllipticalArc::center ( Dim2  d) const
inline

Get a coordinate of the elliptical arc's center.

Parameters
dThe dimension to retrieve
Returns
The selected coordinate of the center

Definition at line 103 of file elliptical-arc.h.

References _ellipse, and Geom::Ellipse::center().

◆ chord()

LineSegment Geom::EllipticalArc::chord ( ) const
inline

Get the line segment connecting the arc's endpoints.

Returns
A linear segment with initial and final point corresponding to those of the arc.

Definition at line 250 of file elliptical-arc.h.

References _final_point, and _initial_point.

Referenced by derivative(), isNear(), pointAndDerivatives(), pointAt(), roots(), toSBasis(), and valueAt().

◆ containsAngle()

bool Geom::EllipticalArc::containsAngle ( Angle  angle) const
inline

Check whether the arc contains the given angle.

Parameters
tThe angle to check
Returns
True if the arc contains the angle, false otherwise

Definition at line 187 of file elliptical-arc.h.

References _angles, and Geom::AngleInterval::contains().

◆ degreesOfFreedom()

int Geom::EllipticalArc::degreesOfFreedom ( ) const
inlineoverridevirtual

Return the number of independent parameters required to represent all variations of this curve.

For example, for Bezier curves it returns the curve's order multiplied by 2.

Reimplemented from Geom::Curve.

Definition at line 289 of file elliptical-arc.h.

◆ derivative()

Curve * Geom::EllipticalArc::derivative ( ) const
overridevirtual

Create a derivative of this curve.

It's best to think of the derivative in physical terms: if the curve describes the position of some object on the plane from time \(t=0\) to \(t=1\) as said in the introduction, then the curve's derivative describes that object's speed at the same times. The second derivative refers to its acceleration, the third to jerk, etc.

Returns
New curve \(\mathbf{D} = \mathbf{C}'\).

Implements Geom::Curve.

Definition at line 261 of file elliptical-arc.cpp.

References _ellipse, chord(), Geom::BezierCurveN< degree >::derivative(), duplicate(), isChord(), result, and Geom::Ellipse::setCenter().

◆ duplicate()

Curve * Geom::EllipticalArc::duplicate ( ) const
inlineoverridevirtual

Create an exact copy of this curve.

Returns
Pointer to a newly allocated curve, identical to the original

Implements Geom::Curve.

Definition at line 256 of file elliptical-arc.h.

References EllipticalArc().

Referenced by derivative(), pointAndDerivatives(), portion(), reverse(), and TEST().

◆ expandToTransformed()

void Geom::EllipticalArc::expandToTransformed ( Rect bbox,
Affine const &  transform 
) const
overridevirtual

Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.

Parameters
bbox[in,out]bbox The rectangle to expand; it is assumed to already contain (initialPoint() * transform).
transformThe transform to apply to the curve before taking its bounding box.

Implements Geom::Curve.

Definition at line 142 of file elliptical-arc.cpp.

References _angles, _final_point, Geom::AngleInterval::contains(), Geom::contains(), Geom::GenericRect< C >::expandTo(), isChord(), Geom::AngleInterval::isFull(), Geom::Curve::transform(), Geom::GenericRect< C >::unionWith(), unitCircleTransform(), Geom::X, and Geom::Y.

◆ feed()

void Geom::EllipticalArc::feed ( PathSink sink,
bool  moveto_initial 
) const
overridevirtual

◆ finalAngle()

Angle Geom::EllipticalArc::finalAngle ( ) const
inline

Definition at line 134 of file elliptical-arc.h.

References _angles, and Geom::AngleInterval::finalAngle().

Referenced by Geom::CairoPathSink::arcTo(), and winding().

◆ finalPoint()

Point Geom::EllipticalArc::finalPoint ( ) const
inlineoverridevirtual

Retrieve the end of the curve.

Returns
The point corresponding to \(\mathbf{C}(1)\).

Implements Geom::Curve.

Definition at line 255 of file elliptical-arc.h.

References _final_point.

Referenced by _updateCenterAndAngles(), operator<<(), pointAt(), TEST(), and toSBasis().

◆ initialAngle()

Angle Geom::EllipticalArc::initialAngle ( ) const
inline

Definition at line 133 of file elliptical-arc.h.

References _angles, and Geom::AngleInterval::initialAngle().

Referenced by Geom::CairoPathSink::arcTo(), toSBasis(), and winding().

◆ initialPoint()

Point Geom::EllipticalArc::initialPoint ( ) const
inlineoverridevirtual

Retrieve the start of the curve.

Returns
The point corresponding to \(\mathbf{C}(0)\).

Implements Geom::Curve.

Definition at line 254 of file elliptical-arc.h.

References _initial_point.

Referenced by _updateCenterAndAngles(), operator<<(), pointAt(), TEST(), and toSBasis().

◆ intersect()

std::vector< CurveIntersection > Geom::EllipticalArc::intersect ( Curve const &  other,
Coord  eps = EPSILON 
) const
overridevirtual

◆ inverseUnitCircleTransform()

Affine Geom::EllipticalArc::inverseUnitCircleTransform ( ) const
inline

Compute a transform that maps the arc's ellipse to the unit circle.

Definition at line 234 of file elliptical-arc.h.

References _ellipse, Geom::Ellipse::inverseUnitCircleTransform(), and result.

◆ isChord()

bool Geom::EllipticalArc::isChord ( ) const
inline

Check whether both rays are nonzero.

If they are not, the arc is represented as a line segment instead.

Definition at line 244 of file elliptical-arc.h.

References ray(), Geom::X, and Geom::Y.

Referenced by _updateCenterAndAngles(), boundsExact(), derivative(), expandToTransformed(), isLineSegment(), isNear(), operator*=(), pointAndDerivatives(), pointAt(), roots(), toSBasis(), and valueAt().

◆ isDegenerate()

bool Geom::EllipticalArc::isDegenerate ( ) const
inlineoverridevirtual

Check whether the curve has exactly zero length.

Returns
True if the curve's initial point is exactly the same as its final point, and it contains no other points (its value set contains only one element).

Implements Geom::Curve.

Definition at line 265 of file elliptical-arc.h.

References _final_point, and _initial_point.

◆ isLineSegment()

bool Geom::EllipticalArc::isLineSegment ( ) const
inlineoverridevirtual

Check whether the curve is a line segment.

Reimplemented from Geom::Curve.

Definition at line 268 of file elliptical-arc.h.

References isChord().

Referenced by intersect().

◆ isNear()

bool Geom::EllipticalArc::isNear ( Curve const &  c,
Coord  precision 
) const
overridevirtual

Test whether two curves are approximately the same.

Implements Geom::Curve.

Definition at line 901 of file elliptical-arc.cpp.

References _ellipse, _final_point, _initial_point, Geom::are_near(), c, chord(), isChord(), isNear(), and sweep().

Referenced by isNear().

◆ largeArc()

bool Geom::EllipticalArc::largeArc ( ) const
inline

Whether the arc is larger than half an ellipse.

Returns
True if the arc is larger than \(\pi\), false otherwise

Definition at line 126 of file elliptical-arc.h.

References _large_arc.

Referenced by operator<<(), and winding().

◆ nearestTime()

double Geom::EllipticalArc::nearestTime ( Point const &  p,
double  a = 0,
double  b = 1 
) const
inlineoverridevirtual

Compute a time value at which the curve comes closest to a specified point.

The first value with the smallest distance is returned if there are multiple such points.

Parameters
pQuery point
aMinimum time value to consider
bMaximum time value to consider; \(a < b\)
Returns
\(q \in [a, b]: ||\mathbf{C}(q) - \mathbf{p}|| = \inf(\{r \in \mathbb{R} : ||\mathbf{C}(r) - \mathbf{p}||\})\)

Reimplemented from Geom::Curve.

Definition at line 281 of file elliptical-arc.h.

References allNearestTimes(), Geom::are_near(), center(), ray(), Geom::X, and Geom::Y.

◆ operator*=() [1/12]

◆ operator*=() [2/12]

virtual void Geom::Curve::operator*= ( Affine const &  m)
virtual

Implements Geom::Curve.

◆ operator*=() [3/12]

virtual void Geom::Curve::operator*= ( HShear const &  hs)
inlinevirtual

Reimplemented from Geom::Curve.

Definition at line 200 of file curve.h.

◆ operator*=() [4/12]

virtual void Geom::Curve::operator*= ( Rotate const &  r)
inlinevirtual

Reimplemented from Geom::Curve.

Definition at line 199 of file curve.h.

◆ operator*=() [5/12]

void Geom::EllipticalArc::operator*= ( Rotate const &  r)
overridevirtual

Reimplemented from Geom::Curve.

Definition at line 846 of file elliptical-arc.cpp.

References _ellipse, _final_point, and _initial_point.

◆ operator*=() [6/12]

virtual void Geom::Curve::operator*= ( Scale const &  s)
inlinevirtual

Reimplemented from Geom::Curve.

Definition at line 198 of file curve.h.

◆ operator*=() [7/12]

void Geom::EllipticalArc::operator*= ( Scale const &  s)
overridevirtual

Reimplemented from Geom::Curve.

Definition at line 839 of file elliptical-arc.cpp.

References _ellipse, _final_point, and _initial_point.

◆ operator*=() [8/12]

virtual void Geom::Curve::operator*= ( Translate const &  tr)
inlinevirtual

Reimplemented from Geom::Curve.

Definition at line 197 of file curve.h.

◆ operator*=() [9/12]

void Geom::EllipticalArc::operator*= ( Translate const &  tr)
overridevirtual

Reimplemented from Geom::Curve.

Definition at line 832 of file elliptical-arc.cpp.

References _ellipse, _final_point, and _initial_point.

◆ operator*=() [10/12]

virtual void Geom::Curve::operator*= ( VShear const &  vs)
inlinevirtual

Reimplemented from Geom::Curve.

Definition at line 201 of file curve.h.

◆ operator*=() [11/12]

virtual void Geom::Curve::operator*= ( Zoom const &  z)
inlinevirtual

Reimplemented from Geom::Curve.

Definition at line 202 of file curve.h.

◆ operator*=() [12/12]

void Geom::EllipticalArc::operator*= ( Zoom const &  z)
overridevirtual

Reimplemented from Geom::Curve.

Definition at line 853 of file elliptical-arc.cpp.

References _ellipse, _final_point, and _initial_point.

◆ pointAndDerivatives()

std::vector< Point > Geom::EllipticalArc::pointAndDerivatives ( Coord  t,
unsigned int  n 
) const
override

◆ pointAt()

Point Geom::EllipticalArc::pointAt ( Coord  t) const
overridevirtual

Evaluate the arc in the curve domain, i.e. \([0, 1]\).

Reimplemented from Geom::Curve.

Definition at line 313 of file elliptical-arc.cpp.

References _ellipse, angleAt(), chord(), finalPoint(), initialPoint(), isChord(), Geom::Ellipse::pointAt(), and Geom::BezierCurve::pointAt().

Referenced by _validateIntersection(), allNearestTimes(), portion(), TEST(), and TEST().

◆ pointAtAngle()

Point Geom::EllipticalArc::pointAtAngle ( Coord  t) const

Evaluate the arc at the specified angular coordinate.

Parameters
tAngle
Returns
Point corresponding to the given angle

Definition at line 173 of file elliptical-arc.cpp.

References _ellipse, and Geom::Ellipse::pointAt().

Referenced by allNearestTimes(), pointAndDerivatives(), TEST(), and winding().

◆ portion()

Curve * Geom::EllipticalArc::portion ( double  a,
double  b 
) const
overridevirtual

Create a curve that corresponds to a part of this curve.

For \(a > b\), the returned portion will be reversed with respect to the original. The returned curve will always be of the same type.

Parameters
aBeginning of the interval specifying the portion of the curve
bEnd of the interval
Returns
New curve \(\mathbf{D}\) such that:
  • \(\mathbf{D}(0) = \mathbf{C}(a)\)
  • \(\mathbf{D}(1) = \mathbf{C}(b)\)
  • \(\mathbf{D}[ [0, 1] ] = \mathbf{C}[ [a?b] ]\), where \([a?b] = [\min(a, b), \max(a, b)]\)

Implements Geom::Curve.

Definition at line 333 of file elliptical-arc.cpp.

References _angles, _final_point, _initial_point, _large_arc, angleAt(), angularExtent(), duplicate(), EllipticalArc(), pointAt(), reverse(), Geom::AngleInterval::setAngles(), Geom::AngleInterval::setSweep(), and sweep().

◆ ray()

Coord Geom::EllipticalArc::ray ( Dim2  d) const
inline

Get one of the ellipse's rays.

Parameters
dDimension to retrieve
Returns
The selected ray of the ellipse

Definition at line 112 of file elliptical-arc.h.

References _ellipse, and Geom::Ellipse::ray().

Referenced by _updateCenterAndAngles(), allNearestTimes(), feed(), isChord(), nearestTime(), operator<<(), roots(), toSBasis(), and winding().

◆ rays()

Point Geom::EllipticalArc::rays ( ) const
inline

Get both rays as a point.

Returns
Point with X equal to the X ray and Y to Y ray

Definition at line 116 of file elliptical-arc.h.

References _ellipse, and Geom::Ellipse::rays().

Referenced by _equalTo(), and _updateCenterAndAngles().

◆ reverse()

Curve * Geom::EllipticalArc::reverse ( ) const
overridevirtual

Create a reversed version of this curve.

The result corresponds to portion(1, 0), but this method might be faster.

Returns
Pointer to a new curve \(\mathbf{D}\) such that \(\forall_{x \in [0, 1]} \mathbf{D}(x) = \mathbf{C}(1-x)\)

Reimplemented from Geom::Curve.

Definition at line 363 of file elliptical-arc.cpp.

References _angles, _final_point, _initial_point, duplicate(), and Geom::AngleInterval::reverse().

Referenced by portion().

◆ roots()

std::vector< Coord > Geom::EllipticalArc::roots ( double  v,
Dim2  d 
) const
overridevirtual

Computes time values at which the curve intersects an axis-aligned line.

Parameters
vThe coordinate of the line
dWhich axis the coordinate is on. X means a vertical line, Y a horizontal line.

Implements Geom::Curve.

Definition at line 184 of file elliptical-arc.cpp.

References c, center(), chord(), Geom::GenericInterval< C >::contains(), delta, isChord(), ray(), Geom::BezierCurve::roots(), rotationAngle(), Geom::sincos(), timeAtAngle(), Geom::X, and Geom::Y.

Referenced by allNearestTimes().

◆ rotationAngle()

Angle Geom::EllipticalArc::rotationAngle ( ) const
inline

Get the defining ellipse's rotation.

Returns
Angle between the +X ray of the ellipse and the +X axis

Definition at line 120 of file elliptical-arc.h.

References _ellipse, and Geom::Ellipse::rotationAngle().

Referenced by _equalTo(), _updateCenterAndAngles(), allNearestTimes(), feed(), operator<<(), roots(), toSBasis(), and winding().

◆ set() [1/2]

void Geom::EllipticalArc::set ( Point const &  ip,
double  rx,
double  ry,
double  rot_angle,
bool  large_arc,
bool  sweep,
Point const &  fp 
)
inline

◆ set() [2/2]

void Geom::EllipticalArc::set ( Point const &  ip,
Point const &  r,
Angle  rot_angle,
bool  large_arc,
bool  sweep,
Point const &  fp 
)
inline

◆ setEndpoints()

void Geom::EllipticalArc::setEndpoints ( Point const &  ip,
Point const &  fp 
)
inline

Change the initial and final point in one operation.

This method exists because modifying any of the endpoints causes rather costly recalculations of the center and extreme angles.

Parameters
ipNew initial point
fpNew final point

Definition at line 175 of file elliptical-arc.h.

References _final_point, _initial_point, and _updateCenterAndAngles().

◆ setFinal()

void Geom::EllipticalArc::setFinal ( Point const &  v)
inlineoverridevirtual

Change the ending point of the curve.

After calling this method, it is guaranteed that \(\mathbf{C}(0) = \mathbf{p}\), and the curve is still continuous. The precise new shape of the curve varies with curve type.

Parameters
pNew ending point of the curve

Implements Geom::Curve.

Definition at line 261 of file elliptical-arc.h.

References _final_point, and _updateCenterAndAngles().

◆ setInitial()

void Geom::EllipticalArc::setInitial ( Point const &  v)
inlineoverridevirtual

Change the starting point of the curve.

After calling this method, it is guaranteed that \(\mathbf{C}(0) = \mathbf{p}\), and the curve is still continuous. The precise new shape of the curve varies with curve type.

Parameters
pNew starting point of the curve

Implements Geom::Curve.

Definition at line 257 of file elliptical-arc.h.

References _initial_point, and _updateCenterAndAngles().

◆ sweep()

bool Geom::EllipticalArc::sweep ( ) const
inline

Whether the arc turns clockwise.

Returns
True if the arc makes a clockwise turn when going from initial to final point, false otherwise

Definition at line 131 of file elliptical-arc.h.

References _angles, and Geom::AngleInterval::sweep().

Referenced by _equalTo(), _updateCenterAndAngles(), feed(), isNear(), operator*=(), operator<<(), pointAndDerivatives(), portion(), set(), set(), and winding().

◆ sweepAngle()

Coord Geom::EllipticalArc::sweepAngle ( ) const
inline

Compute the amount by which the angle parameter changes going from start to end.

This has range \((-2\pi, 2\pi)\) and thus cannot be represented as instance of the class Angle. Add this to the initial angle to obtain the final angle.

Definition at line 209 of file elliptical-arc.h.

References _angles, and Geom::AngleInterval::sweepAngle().

Referenced by toSBasis().

◆ timeAtAngle()

Coord Geom::EllipticalArc::timeAtAngle ( Angle  a) const
inline

Compute the curve time value corresponding to the given angular value.

Definition at line 201 of file elliptical-arc.h.

References _angles, and Geom::AngleInterval::timeAtAngle().

Referenced by _intersectSameEllipse(), _validateIntersection(), allNearestTimes(), and roots().

◆ toSBasis()

D2< SBasis > Geom::EllipticalArc::toSBasis ( ) const
overridevirtual

Convert the curve to a symmetric power basis polynomial.

Symmetric power basis polynomials (S-basis for short) are numerical representations of curves with excellent numerical properties. Most high level operations provided by 2Geom are implemented in terms of S-basis operations, so every curve has to provide a method to convert it to an S-basis polynomial on two variables. See SBasis class reference for more information.

Implements Geom::Curve.

Definition at line 800 of file elliptical-arc.cpp.

References center(), chord(), Geom::cos(), finalPoint(), initialAngle(), initialPoint(), isChord(), Geom::Angle::radians(), ray(), rotationAngle(), Geom::sin(), Geom::sincos(), sweepAngle(), Geom::BezierCurve::toSBasis(), Geom::X, and Geom::Y.

Referenced by boundsLocal(), and Inkscape::LivePathEffect::path_from_piecewise_fix_cusps().

◆ unitCircleTransform()

Affine Geom::EllipticalArc::unitCircleTransform ( ) const
inline

Compute a transform that maps the unit circle to the arc's ellipse.

Each ellipse can be interpreted as a translated, scaled and rotate unit circle. This function returns the transform that maps the unit circle to the arc's ellipse.

Returns
Transform from unit circle to the arc's ellipse

Definition at line 228 of file elliptical-arc.h.

References _ellipse, result, and Geom::Ellipse::unitCircleTransform().

Referenced by Geom::CairoPathSink::arcTo(), boundsExact(), and expandToTransformed().

◆ valueAt()

Coord Geom::EllipticalArc::valueAt ( Coord  t,
Dim2  d 
) const
overridevirtual

Evaluate a single coordinate on the arc in the curve domain.

Reimplemented from Geom::Curve.

Definition at line 327 of file elliptical-arc.cpp.

References angleAt(), chord(), isChord(), Geom::BezierCurve::valueAt(), and valueAtAngle().

◆ valueAtAngle()

Coord Geom::EllipticalArc::valueAtAngle ( Coord  t,
Dim2  d 
) const

Evaluate one of the arc's coordinates at the specified angle.

Parameters
tAngle
dThe dimension to retrieve
Returns
Selected coordinate of the arc at the specified angle

Definition at line 179 of file elliptical-arc.cpp.

References _ellipse, and Geom::Ellipse::valueAt().

Referenced by valueAt().

◆ winding()

int Geom::EllipticalArc::winding ( Point const &  p) const
overridevirtual

Compute the partial winding number of this curve.

The partial winding number is equal to the difference between the number of roots at which the curve goes in the +Y direction and the number of roots at which the curve goes in the -Y direction. This method is mainly useful for implementing path winding calculation. It will ignore roots which are local maxima on the Y axis.

Parameters
pPoint where the winding number should be determined
Returns
Winding number contribution at p

Reimplemented from Geom::Curve.

Definition at line 928 of file elliptical-arc.cpp.

References _angles, _ellipse, _final_point, _initial_point, Geom::AngleInterval::contains(), Geom::Ellipse::contains(), Geom::cross(), finalAngle(), initialAngle(), Geom::AngleInterval::isFull(), largeArc(), Geom::Interval::lowerContains(), pointAtAngle(), ray(), rotationAngle(), Geom::sincos(), sweep(), Geom::X, and Geom::Y.

Friends And Related Symbol Documentation

◆ arc_from_sbasis()

bool arc_from_sbasis ( EllipticalArc ea,
D2< SBasis > const &  in,
double  tolerance = EPSILON,
unsigned  num_samples = 20 
)
related

Fit an elliptical arc to an SBasis fragment.

Definition at line 323 of file elliptical-arc-from-sbasis.cpp.

References Geom::arc_from_sbasis(), and Geom::make_elliptical_arc().

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
EllipticalArc const &  ea 
)
related

Debug output for elliptical arcs.

Definition at line 1023 of file elliptical-arc.cpp.

References finalPoint(), Geom::format_coord_nice(), initialPoint(), largeArc(), Geom::operator<<(), ray(), rotationAngle(), sweep(), Geom::X, and Geom::Y.

Member Data Documentation

◆ _angles

◆ _ellipse

◆ _final_point

◆ _initial_point

◆ _large_arc

bool Geom::EllipticalArc::_large_arc
private

Definition at line 319 of file elliptical-arc.h.

Referenced by _equalTo(), _updateCenterAndAngles(), feed(), largeArc(), portion(), set(), and set().


The documentation for this class was generated from the following files: