Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Geom::Curve Class Referenceabstract

Abstract continuous curve on a plane defined on [0,1]. More...

#include <curve.h>

Inheritance diagram for Geom::Curve:
Geom::BezierCurve Geom::EllipticalArc Geom::SBasisCurve Geom::BezierCurveN< 1 > Geom::BezierCurveN< degree > Geom::BezierCurveN< 0 > Geom::Path::ClosingSegment Geom::Path::StitchSegment

Public Member Functions

virtual ~Curve ()
 
Evaluate the curve
virtual Point initialPoint () const =0
 Retrieve the start of the curve.
 
virtual Point finalPoint () const =0
 Retrieve the end of the curve.
 
virtual bool isDegenerate () const =0
 Check whether the curve has exactly zero length.
 
virtual bool isLineSegment () const
 Check whether the curve is a line segment.
 
virtual Interval timeRange () const
 Get the interval of allowed time values.
 
virtual Point pointAt (Coord t) const
 Evaluate the curve at a specified time value.
 
virtual Coord valueAt (Coord t, Dim2 d) const
 Evaluate one of the coordinates at the specified time value.
 
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.
 
Change the curve's endpoints
virtual void setInitial (Point const &v)=0
 Change the starting point of the curve.
 
virtual void setFinal (Point const &v)=0
 Change the ending point of the curve.
 
Compute the bounding box
virtual Rect boundsFast () const =0
 Quickly compute the curve's approximate bounding box.
 
virtual Rect boundsExact () const =0
 Compute the curve's exact bounding box.
 
virtual void expandToTransformed (Rect &bbox, Affine const &transform) const =0
 Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.
 
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.
 
Create new curves based on this one
virtual Curveduplicate () const =0
 Create an exact copy of this curve.
 
void transform (Affine const &m)
 Transform this curve by an affine transformation.
 
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
 
virtual Curvetransformed (Affine const &m) const
 Create a curve transformed by an affine transformation.
 
virtual Curveportion (Coord a, Coord b) const =0
 Create a curve that corresponds to a part of this curve.
 
Curveportion (Interval const &i) const
 A version of that accepts an Interval.
 
virtual Curvereverse () const
 Create a reversed version of this curve.
 
virtual Curvederivative () const =0
 Create a derivative of this curve.
 
Advanced operations
virtual Coord nearestTime (Point const &p, Coord a=0, Coord b=1) const
 Compute a time value at which the curve comes closest to a specified point.
 
Coord nearestTime (Point const &p, Interval const &i) const
 A version that takes an Interval.
 
virtual std::vector< CoordallNearestTimes (Point const &p, Coord from=0, Coord to=1) const
 Compute time values at which the curve comes closest to a specified point.
 
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< Coordroots (Coord v, Dim2 d) const =0
 Computes time values at which the curve intersects an axis-aligned line.
 
virtual int winding (Point const &p) const
 Compute the partial winding number of this curve.
 
virtual std::vector< CurveIntersectionintersect (Curve const &other, Coord eps=EPSILON) const
 Compute intersections with another 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.
 
virtual D2< SBasistoSBasis () const =0
 Convert the curve to a symmetric power basis polynomial.
 
Miscellaneous
virtual int degreesOfFreedom () const
 Return the number of independent parameters required to represent all variations of this curve.
 
bool operator== (Curve const &c) const
 Test equality of two curves.
 
virtual bool isNear (Curve const &c, Coord precision) const =0
 Test whether two curves are approximately the same.
 
virtual void feed (PathSink &sink, bool moveto_initial) const
 Feed the curve to a PathSink.
 

Protected Member Functions

virtual bool _equalTo (Curve const &c) const =0
 

Detailed Description

Abstract continuous curve on a plane defined on [0,1].

Formally, a curve in 2Geom is defined as a function \(\mathbf{C}: [0, 1] \to \mathbb{R}^2\) (a function that maps the unit interval to points on a 2D plane). Its image (the set of points the curve passes through) will be denoted \(\mathcal{C} = \mathbf{C}[ [0, 1] ]\). All curve types available in 2Geom are continuous and differentiable on their interior, e.g. \((0, 1)\). Sometimes the curve's image (value set) is referred to as the curve itself for simplicity, but keep in mind that it's not strictly correct.

It is common to think of the parameter as time. The curve can then be interpreted as describing the position of some moving object from time \(t=0\) to \(t=1\). Because of this, the parameter is frequently called the time value.

Some methods return pointers to newly allocated curves. They are expected to be freed by the caller when no longer used. Default implementations are provided for some methods.

Definition at line 76 of file curve.h.

Constructor & Destructor Documentation

◆ ~Curve()

virtual Geom::Curve::~Curve ( )
inlinevirtual

Definition at line 80 of file curve.h.

Member Function Documentation

◆ _equalTo()

virtual bool Geom::Curve::_equalTo ( Curve const &  c) const
protectedpure virtual

◆ allNearestTimes() [1/2]

std::vector< Coord > Geom::Curve::allNearestTimes ( Point const &  p,
Coord  from = 0,
Coord  to = 1 
) const
virtual

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 in Geom::SBasisCurve, and Geom::EllipticalArc.

Definition at line 51 of file curve.cpp.

References Geom::all_nearest_times(), and toSBasis().

Referenced by allNearestTimes().

◆ allNearestTimes() [2/2]

std::vector< Coord > Geom::Curve::allNearestTimes ( Point const &  p,
Interval const &  i 
)
inline

A version that takes an Interval.

Definition at line 270 of file curve.h.

References allNearestTimes(), Geom::GenericInterval< C >::max(), and Geom::GenericInterval< C >::min().

◆ boundsExact()

virtual Rect Geom::Curve::boundsExact ( ) const
pure virtual

Compute the curve's exact bounding box.

This method can be dramatically slower than boundsFast() depending on the curve type.

Returns
The smallest possible rectangle containing all of the curve's points.

Implemented in Geom::BezierCurve, Geom::EllipticalArc, and Geom::SBasisCurve.

Referenced by Geom::Path::boundsExact().

◆ boundsFast()

virtual Rect Geom::Curve::boundsFast ( ) const
pure virtual

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.

Implemented in Geom::BezierCurve, Geom::EllipticalArc, and Geom::SBasisCurve.

Referenced by Geom::Path::boundsFast().

◆ boundsLocal() [1/2]

OptRect Geom::Curve::boundsLocal ( OptInterval const &  a) const
inline

Compute the bounding box of a part of the curve.

Since this method returns the smallest possible bounding rectangle of the specified portion, it can also be rather slow.

Parameters
aAn interval specifying a part of the curve, or nothing. If \([0, 1] \subseteq a\), then the bounding box for the entire curve is calculated.
Returns
The smallest possible rectangle containing all points in \(\mathbf{C}[a]\), or nothing if the supplied interval is empty.

Definition at line 180 of file curve.h.

References boundsLocal().

Referenced by boundsLocal().

◆ boundsLocal() [2/2]

virtual OptRect Geom::Curve::boundsLocal ( OptInterval const &  i,
unsigned  deg 
) const
pure virtual

Implemented in Geom::BezierCurve, and Geom::SBasisCurve.

Referenced by Geom::pair_intersect().

◆ degreesOfFreedom()

virtual int Geom::Curve::degreesOfFreedom ( ) const
inlinevirtual

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 in Geom::BezierCurve, Geom::EllipticalArc, and Geom::SBasisCurve.

Definition at line 333 of file curve.h.

◆ derivative()

virtual Curve * Geom::Curve::derivative ( ) const
pure virtual

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}'\).

Implemented in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurve, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::EllipticalArc, and Geom::SBasisCurve.

Referenced by Geom::curve_mono_splits(), and intersectSelf().

◆ duplicate()

virtual Curve * Geom::Curve::duplicate ( ) const
pure virtual

Create an exact copy of this curve.

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

Implemented in Geom::BezierCurve, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::EllipticalArc, Geom::Path::ClosingSegment, Geom::Path::StitchSegment, and Geom::SBasisCurve.

Referenced by Inkscape::LivePathEffect::LPERoughen::doEffect(), Geom::new_clone(), and transformed().

◆ expandToTransformed()

virtual void Geom::Curve::expandToTransformed ( Rect bbox,
Affine const &  transform 
) const
pure virtual

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.

Implemented in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurve, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::EllipticalArc, and Geom::SBasisCurve.

◆ feed()

◆ finalPoint()

virtual Point Geom::Curve::finalPoint ( ) const
pure virtual

Retrieve the end of the curve.

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

Implemented in Geom::BezierCurve, Geom::EllipticalArc, and Geom::SBasisCurve.

Referenced by Inkscape::UI::Tools::PenTool::_bsplineSpiroOff(), Inkscape::UI::Tools::PenTool::_bsplineSpiroOn(), Inkscape::UI::Tools::PencilTool::_fitAndSplit(), Inkscape::UI::Tools::PencilTool::_interpolate(), Inkscape::UI::Tools::PencilTool::_sketchInterpolate(), Inkscape::UI::Tools::PenTool::_undoLastPoint(), Inkscape::UI::Tools::CalligraphicTool::accumulate(), Inkscape::LivePathEffect::LPERoughen::addNodesAndJitter(), Inkscape::LivePathEffect::LPEMeasureSegments::doBeforeEffect(), Inkscape::LivePathEffect::LPEBSpline::doBSplineFromWidget(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::doEffect(), Inkscape::LivePathEffect::LPERoughen::doEffect(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_path(), Inkscape::LivePathEffect::LPEDashedStroke::doEffect_path(), Inkscape::LivePathEffect::LPEFilletChamfer::doEffect_path(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doEffect_path(), Inkscape::LivePathEffect::LPEShowHandles::generateHelperPath(), Inkscape::LivePathEffect::LPESimplify::generateHelperPathAndSmooth(), Inkscape::half_outline(), Geom::BezierCurveN< degree >::intersect(), Geom::EllipticalArc::intersect(), Inkscape::LivePathEffect::LPERoughen::jitter(), Inkscape::LivePathEffect::FilletChamferKnotHolderEntity::knot_get(), SPCurve::nodes_in_path(), Inkscape::LivePathEffect::size_nondegenerate(), Inkscape::LivePathEffect::sp_bspline_do_effect(), and Inkscape::LivePathEffect::LPESlice::splititem().

◆ initialPoint()

virtual Point Geom::Curve::initialPoint ( ) const
pure virtual

Retrieve the start of the curve.

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

Implemented in Geom::BezierCurve, Geom::EllipticalArc, and Geom::SBasisCurve.

Referenced by Inkscape::UI::Tools::PenTool::_bsplineSpiroEndAnchorOff(), Inkscape::UI::Tools::PenTool::_bsplineSpiroEndAnchorOn(), Inkscape::UI::Tools::PenTool::_bsplineSpiroMotion(), Inkscape::UI::Tools::PenTool::_lastpointToCurve(), Inkscape::UI::Tools::PenTool::_undoLastPoint(), Inkscape::UI::Tools::CalligraphicTool::accumulate(), Inkscape::LivePathEffect::LPERoughen::addNodesAndJitter(), Inkscape::LivePathEffect::LPEFilletChamfer::doBeforeEffect(), Inkscape::LivePathEffect::LPEMeasureSegments::doBeforeEffect(), Inkscape::LivePathEffect::LPEBSpline::doBSplineFromWidget(), Inkscape::LivePathEffect::LPEAttachPath::doEffect(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::doEffect(), Inkscape::LivePathEffect::LPERoughen::doEffect(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_path(), Inkscape::LivePathEffect::LPEDashedStroke::doEffect_path(), Inkscape::LivePathEffect::LPEFilletChamfer::doEffect_path(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doEffect_path(), Inkscape::LivePathEffect::LPETransform2Pts::doOnApply(), Geom::PathSink::feed(), feed(), Inkscape::LivePathEffect::LPEShowHandles::generateHelperPath(), Inkscape::LivePathEffect::LPESimplify::generateHelperPathAndSmooth(), Inkscape::half_outline(), Geom::BezierCurveN< degree >::intersect(), Geom::EllipticalArc::intersect(), Inkscape::LivePathEffect::LPERoughen::jitter(), Inkscape::LivePathEffect::FilletChamferKnotHolderEntity::knot_get(), SPCurve::nodes_in_path(), Inkscape::outline_join(), SPCurve::penultimate_point(), Inkscape::LivePathEffect::LPEFilletChamfer::setSelected(), Inkscape::LivePathEffect::size_nondegenerate(), Inkscape::LivePathEffect::sp_bspline_do_effect(), Inkscape::LivePathEffect::LPESlice::splititem(), and Inkscape::LivePathEffect::NodeSatelliteArrayParam::updateAmmount().

◆ intersect()

◆ intersectSelf()

std::vector< CurveIntersection > Geom::Curve::intersectSelf ( Coord  eps = EPSILON) const
virtual

Compute intersections of this curve with itself.

Represents a sub-arc of the curve.

A closure to split the curve into portions at the prescribed split points.

A closure to find pairwise intersections between the passed subcurves.

Definition at line 103 of file curve.cpp.

References derivative(), Geom::EPSILON, portion(), result, roots(), Geom::split(), Geom::Interval::valueAt(), Geom::X, and Geom::Y.

◆ isDegenerate()

virtual bool Geom::Curve::isDegenerate ( ) const
pure virtual

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

Implemented in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurve, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::EllipticalArc, and Geom::SBasisCurve.

Referenced by arcLengthAt(), Inkscape::LivePathEffect::LPEFilletChamfer::doEffect_path(), and timeAtArcLength().

◆ isLineSegment()

virtual bool Geom::Curve::isLineSegment ( ) const
inlinevirtual

◆ isNear()

virtual bool Geom::Curve::isNear ( Curve const &  c,
Coord  precision 
) const
pure virtual

Test whether two curves are approximately the same.

Implemented in Geom::SBasisCurve, Geom::BezierCurve, and Geom::EllipticalArc.

Referenced by Geom::parting_point().

◆ length()

Coord Geom::Curve::length ( Coord  tolerance = 0.01) const
virtual

Compute the arc length of this curve.

For a curve \(\mathbf{C}(t) = (C_x(t), C_y(t))\), arc length is defined for 2D curves as

\[ \ell = \int_{0}^{1} \sqrt { [C_x'(t)]^2 + [C_y'(t)]^2 }\, \text{d}t \]

In other words, we divide the curve into infinitely small linear segments and add together their lengths. Of course we can't subdivide the curve into infinitely many segments on a computer, so this method returns an approximation. Not that there is usually no closed form solution to such integrals, so this method might be slow.

Parameters
toleranceMaximum allowed error
Returns
Total distance the curve's value travels on the plane when going from 0 to 1

Reimplemented in Geom::BezierCurve, and Geom::SBasisCurve.

Definition at line 56 of file curve.cpp.

References toSBasis().

Referenced by arcLengthAt(), Inkscape::LivePathEffect::LPEPowerStroke::doEffect_path(), Inkscape::LivePathEffect::FilletChamferKnotHolderEntity::knot_set(), NodeSatellite::time(), timeAtArcLength(), unitTangentAt(), and Inkscape::LivePathEffect::NodeSatelliteArrayParam::updateCanvasIndicators().

◆ nearestTime() [1/2]

Coord Geom::Curve::nearestTime ( Point const &  p,
Coord  a = 0,
Coord  b = 1 
) const
virtual

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 in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurve, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::SBasisCurve, and Geom::EllipticalArc.

Definition at line 46 of file curve.cpp.

References Geom::nearest_time(), and toSBasis().

Referenced by nearestTime().

◆ nearestTime() [2/2]

Coord Geom::Curve::nearestTime ( Point const &  p,
Interval const &  i 
) const
inline

A version that takes an Interval.

Definition at line 257 of file curve.h.

References Geom::GenericInterval< C >::max(), Geom::GenericInterval< C >::min(), and nearestTime().

◆ operator()()

virtual Point Geom::Curve::operator() ( Coord  t) const
inlinevirtual

Evaluate the function at the specified time value.

Allows curves to be used as functors.

Definition at line 120 of file curve.h.

References pointAt().

◆ operator*=() [1/7]

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

◆ operator*=() [2/7]

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

Reimplemented in Geom::BezierCurve, Geom::EllipticalArc, and Geom::SBasisCurve.

Definition at line 200 of file curve.h.

◆ operator*=() [3/7]

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

Reimplemented in Geom::BezierCurve, Geom::EllipticalArc, Geom::SBasisCurve, and Geom::EllipticalArc.

Definition at line 199 of file curve.h.

◆ operator*=() [4/7]

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

◆ operator*=() [5/7]

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

◆ operator*=() [6/7]

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

Reimplemented in Geom::BezierCurve, Geom::EllipticalArc, and Geom::SBasisCurve.

Definition at line 201 of file curve.h.

◆ operator*=() [7/7]

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

Reimplemented in Geom::BezierCurve, Geom::EllipticalArc, Geom::SBasisCurve, and Geom::EllipticalArc.

Definition at line 202 of file curve.h.

◆ operator==()

bool Geom::Curve::operator== ( Curve const &  c) const
inline

Test equality of two curves.

Equality means that for any time value, the evaluation of either curve will yield the same value. This means non-degenerate curves are not equal to their reverses. Note that this tests for exact equality.

Returns
True if the curves are identical, false otherwise

Definition at line 340 of file curve.h.

References _equalTo(), and c.

◆ pointAndDerivatives()

virtual std::vector< Point > Geom::Curve::pointAndDerivatives ( Coord  t,
unsigned  n 
) const
pure virtual

Evaluate the curve and its derivatives.

This will return a vector that contains the value of the curve and the specified number of derivatives. However, the returned vector might contain less elements than specified if some derivatives do not exist.

Parameters
tTime value
nThe number of derivatives to compute
Returns
Vector of at most \(n+1\) elements of the form \([\mathbf{C}(t), \mathbf{C}'(t), \mathbf{C}''(t), \ldots]\)

Implemented in Geom::BezierCurve, and Geom::SBasisCurve.

Referenced by Inkscape::LivePathEffect::LPEAttachPath::doEffect(), Geom::intersect_polish_root(), pointAt(), and unitTangentAt().

◆ pointAt()

◆ portion() [1/2]

virtual Curve * Geom::Curve::portion ( Coord  a,
Coord  b 
) const
pure virtual

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)]\)

Implemented in Geom::BezierCurve, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::SBasisCurve, and Geom::EllipticalArc.

Referenced by Geom::Path::appendPortionTo(), arcLengthAt(), Inkscape::LivePathEffect::LPEFilletChamfer::doEffect_path(), intersectSelf(), NodeSatellite::lenToRad(), Geom::parting_point(), and reverse().

◆ portion() [2/2]

Curve * Geom::Curve::portion ( Interval const &  i) const
inline

A version of that accepts an Interval.

Definition at line 228 of file curve.h.

References Geom::GenericInterval< C >::max(), Geom::GenericInterval< C >::min(), and portion().

Referenced by portion().

◆ reverse()

virtual Curve * Geom::Curve::reverse ( ) const
inlinevirtual

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 in Geom::BezierCurve, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::EllipticalArc, Geom::Path::ClosingSegment, and Geom::Path::StitchSegment.

Definition at line 234 of file curve.h.

References portion().

Referenced by Inkscape::UI::Tools::PencilTool::_fitAndSplit(), Inkscape::UI::Tools::PencilTool::_interpolate(), Inkscape::UI::Tools::PencilTool::_sketchInterpolate(), Inkscape::LivePathEffect::LPEAttachPath::doEffect(), Inkscape::UI::Tools::MarkerTool::get_marker_transform(), Geom::get_nodetype(), sp_shape_marker_get_transform(), and sp_shape_marker_get_transform_at_end().

◆ roots()

virtual std::vector< Coord > Geom::Curve::roots ( Coord  v,
Dim2  d 
) const
pure virtual

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.

Implemented in Geom::BezierCurve, Geom::SBasisCurve, and Geom::EllipticalArc.

Referenced by Geom::curve_mono_splits(), intersectSelf(), and winding().

◆ setFinal()

virtual void Geom::Curve::setFinal ( Point const &  v)
pure virtual

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

Implemented in Geom::EllipticalArc, Geom::BezierCurve, and Geom::SBasisCurve.

Referenced by Geom::SVGPathParser::_closePath(), and Geom::Path::appendPortionTo().

◆ setInitial()

virtual void Geom::Curve::setInitial ( Point const &  v)
pure virtual

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

Implemented in Geom::EllipticalArc, Geom::BezierCurve, and Geom::SBasisCurve.

Referenced by Geom::Path::appendPortionTo(), and Inkscape::LivePathEffect::LPEFilletChamfer::doEffect_path().

◆ timeRange()

virtual Interval Geom::Curve::timeRange ( ) const
inlinevirtual

Get the interval of allowed time values.

Returns
\([0, 1]\)

Definition at line 102 of file curve.h.

◆ toSBasis()

virtual D2< SBasis > Geom::Curve::toSBasis ( ) const
pure virtual

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.

Implemented in Geom::BezierCurve, Geom::EllipticalArc, and Geom::SBasisCurve.

Referenced by Inkscape::UI::PathManipulator::_bsplineHandleReposition(), Inkscape::UI::Tools::PenTool::_bsplineSpiroMotion(), allNearestTimes(), Inkscape::LivePathEffect::LPEBSpline::doBSplineFromWidget(), feed(), length(), monotonic_smash_intersect(), nearestTime(), NodeSatellite::radToLen(), Inkscape::LivePathEffect::sp_bspline_do_effect(), Inkscape::UI::PathManipulator::subdivideSegment(), and timeAtArcLength().

◆ transform()

void Geom::Curve::transform ( Affine const &  m)
inline

Transform this curve by an affine transformation.

Because of this method, all curve types must be closed under affine transformations.

Parameters
mAffine describing the affine transformation

Definition at line 193 of file curve.h.

Referenced by Geom::Ellipse::axis(), Geom::BezierCurve::expandToTransformed(), Geom::BezierCurveN< degree >::expandToTransformed(), Geom::EllipticalArc::expandToTransformed(), Geom::SBasisCurve::expandToTransformed(), Geom::Ellipse::semiaxis(), and transformed().

◆ transformed()

virtual Curve * Geom::Curve::transformed ( Affine const &  m) const
inlinevirtual

Create a curve transformed by an affine transformation.

This method returns a new curve instead modifying the existing one.

Parameters
mAffine describing the affine transformation
Returns
Pointer to a new, transformed curve

Definition at line 209 of file curve.h.

References duplicate(), and transform().

◆ unitTangentAt()

Point Geom::Curve::unitTangentAt ( Coord  t,
unsigned  n = 3 
) const
virtual

Compute a vector tangent to the curve.

This will return an unit vector (a Point with length() equal to 1) that denotes a vector tangent to the curve. This vector is defined as \( \mathbf{v}(t) = \frac{\mathbf{C}'(t)}{||\mathbf{C}'(t)||} \). It is pointed in the direction of increasing \(t\), at the specified time value. The method uses l'Hopital's rule when the derivative is zero. A zero vector is returned if no non-zero derivative could be found.

Parameters
tTime value
nThe maximum order of derivative to consider
Returns
Unit tangent vector \(\mathbf{v}(t)\)

Definition at line 201 of file curve.cpp.

References Geom::are_near(), length(), and pointAndDerivatives().

Referenced by Inkscape::UI::Tools::EraserTool::_accumulate(), Inkscape::UI::Tools::PencilTool::_fitAndSplit(), Inkscape::UI::Tools::PencilTool::_interpolate(), Inkscape::UI::Tools::PencilTool::_sketchInterpolate(), Geom::find_direction_of_travel(), Inkscape::UI::Tools::MarkerTool::get_marker_transform(), Geom::get_nodetype(), sp_shape_marker_get_transform(), sp_shape_marker_get_transform_at_end(), and winding().

◆ valueAt()

virtual Coord Geom::Curve::valueAt ( Coord  t,
Dim2  d 
) const
inlinevirtual

Evaluate one of the coordinates at the specified time value.

Parameters
tTime value
dThe dimension to evaluate
Returns
The specified coordinate of \(\mathbf{C}(t)\)

Reimplemented in Geom::BezierCurve, Geom::EllipticalArc, and Geom::SBasisCurve.

Definition at line 116 of file curve.h.

References pointAt().

Referenced by Geom::PathVector::valueAt(), Geom::Path::valueAt(), Geom::PathVector::valueAt(), and winding().

◆ winding()

int Geom::Curve::winding ( Point const &  p) const
virtual

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 in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, and Geom::EllipticalArc.

Definition at line 61 of file curve.cpp.

References roots(), unitTangentAt(), valueAt(), Geom::X, and Geom::Y.

Referenced by Geom::BezierCurveN< degree >::winding().


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