Inkscape
Vector Graphics Editor
|
Bezier curve with compile-time specified order. More...
#include <bezier-curve.h>
Public Member Functions | |
std::pair< BezierCurveN, BezierCurveN > | subdivide (Coord t) const |
Divide a Bezier curve into two curves. | |
bool | isDegenerate () const override |
Check whether the curve has exactly zero length. | |
bool | isLineSegment () const override |
Return false if there are at least 3 distinct control points, true otherwise. | |
Curve * | duplicate () const override |
Create an exact copy of this curve. | |
Curve * | portion (Coord f, Coord t) const override |
Create a curve that corresponds to a part of this curve. | |
Curve * | reverse () const override |
Create a reversed version of this curve. | |
Curve * | derivative () const override |
Create a derivative of this curve. | |
Coord | nearestTime (Point const &p, Coord from=0, Coord to=1) const override |
Compute a time value at which the curve comes closest to a specified point. | |
std::vector< CurveIntersection > | intersect (Curve const &other, Coord eps=EPSILON) const override |
Compute intersections with another curve. | |
int | winding (Point const &p) const override |
Compute the partial winding number of this curve. | |
void | feed (PathSink &sink, bool moveto_initial) const override |
Feed the curve to a PathSink. | |
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. | |
bool | isDegenerate () const |
Check whether the curve has exactly zero length. | |
bool | isLineSegment () const |
Return false if there are at least 3 distinct control points, true otherwise. | |
Curve * | derivative () const |
Create a derivative of this curve. | |
Coord | nearestTime (Point const &, Coord, Coord) const |
Compute a time value at which the curve comes closest to a specified point. | |
std::vector< CurveIntersection > | intersect (Curve const &, Coord) const |
Compute intersections with another curve. | |
std::vector< CurveIntersection > | intersect (Curve const &, Coord) const |
Compute intersections with another curve. | |
std::vector< CurveIntersection > | intersect (Curve const &, Coord) const |
Compute intersections with another curve. | |
int | winding (Point const &) const |
Compute the partial winding number of this curve. | |
void | feed (PathSink &sink, bool moveto_initial) const |
Feed the curve to a PathSink. | |
void | feed (PathSink &sink, bool moveto_initial) const |
Feed the curve to a PathSink. | |
void | feed (PathSink &sink, bool moveto_initial) const |
Feed the curve to a PathSink. | |
void | expandToTransformed (Rect &bbox, Affine const &transform) const |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point. | |
void | expandToTransformed (Rect &bbox, Affine const &transform) const |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point. | |
void | expandToTransformed (Rect &bbox, Affine const &transform) const |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point. | |
Curve * | derivative () const |
Create a derivative of this curve. | |
Coord | nearestTime (Point const &p, Coord from, Coord to) const |
Compute a time value at which the curve comes closest to a specified point. | |
std::vector< CurveIntersection > | intersect (Curve const &other, Coord eps) const |
Compute intersections with another curve. | |
std::vector< CurveIntersection > | intersect (Curve const &other, Coord eps) const |
Compute intersections with another curve. | |
std::vector< CurveIntersection > | intersect (Curve const &other, Coord eps) const |
Compute intersections with another curve. | |
int | winding (Point const &p) const |
Compute the partial winding number of this curve. | |
void | feed (PathSink &sink, bool moveto_initial) const |
Feed the curve to a PathSink. | |
void | feed (PathSink &sink, bool moveto_initial) const |
Feed the curve to a PathSink. | |
void | feed (PathSink &sink, bool moveto_initial) const |
Feed the curve to a PathSink. | |
void | expandToTransformed (Rect &bbox, Affine const &transform) const |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point. | |
void | expandToTransformed (Rect &bbox, Affine const &transform) const |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point. | |
void | expandToTransformed (Rect &bbox, Affine const &transform) const |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point. | |
Construct Bezier curves | |
BezierCurveN () | |
Construct a Bezier curve of the specified order with all points zero. | |
BezierCurveN (D2< Bezier > const &x) | |
Construct from 2D Bezier polynomial. | |
BezierCurveN (Bezier x, Bezier y) | |
Construct from two 1D Bezier polynomials of the same order. | |
BezierCurveN (std::vector< Point > const &points) | |
Construct a Bezier curve from a vector of its control points. | |
BezierCurveN (Point c0, Point c1) | |
Construct a linear segment from its endpoints. | |
BezierCurveN (Point c0, Point c1, Point c2) | |
Construct a quadratic Bezier curve from its control points. | |
BezierCurveN (Point c0, Point c1, Point c2, Point c3) | |
Construct a cubic Bezier curve from its control points. | |
![]() | |
BezierCurve (D2< Bezier > const &b) | |
Point | initialPoint () const override |
Retrieve the start of the curve. | |
Point | finalPoint () const override |
Retrieve the end of the curve. | |
void | setInitial (Point const &v) override |
Change the starting point of the curve. | |
void | setFinal (Point const &v) override |
Change the ending point of the curve. | |
Rect | boundsFast () const override |
Quickly compute the curve's approximate bounding box. | |
Rect | boundsExact () const override |
Compute the curve's exact bounding box. | |
OptRect | boundsLocal (OptInterval const &i, unsigned deg) const override |
void | operator*= (Translate const &tr) override |
void | operator*= (Scale const &s) override |
void | operator*= (Affine const &m) override |
int | degreesOfFreedom () const override |
Return the number of independent parameters required to represent all variations of this curve. | |
std::vector< Coord > | roots (Coord v, Dim2 d) const override |
Computes time values at which the curve intersects an axis-aligned line. | |
Coord | length (Coord tolerance) const override |
Compute the arc length of this curve. | |
Point | pointAt (Coord t) const override |
Evaluate the curve at a specified time value. | |
std::vector< Point > | pointAndDerivatives (Coord t, unsigned n) const override |
Evaluate the curve and its derivatives. | |
Coord | valueAt (Coord t, Dim2 d) const override |
Evaluate one of the coordinates at the specified time value. | |
D2< SBasis > | toSBasis () const override |
Convert the curve to a symmetric power basis polynomial. | |
bool | isNear (Curve const &c, Coord precision) const override |
Test whether two curves are approximately the same. | |
std::vector< Coord > | timesWithRadiusOfCurvature (double radius) const |
Computes the times where the radius of curvature of the bezier curve equals the given radius. | |
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 |
unsigned | order () const |
Get the order of the Bezier curve. | |
unsigned | size () const |
Get the number of control points. | |
Point | controlPoint (unsigned ix) const |
Access control points of the curve. | |
Point | operator[] (unsigned ix) const |
std::vector< Point > | controlPoints () const |
Get the control points. | |
D2< Bezier > const & | fragment () const |
void | setPoint (unsigned ix, Point const &v) |
Modify a control point. | |
virtual void | setPoints (std::vector< Point > const &ps) |
Set new control points. | |
![]() | |
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. | |
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 Curve * | transformed (Affine const &m) const |
Create a curve transformed by an affine transformation. | |
Curve * | portion (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. | |
virtual std::vector< Coord > | allNearestTimes (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< Coord > | allNearestTimes (Point const &p, Interval const &i) |
A version that takes an Interval. | |
virtual std::vector< CurveIntersection > | intersectSelf (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. | |
Static Private Member Functions | |
template<unsigned required_degree> | |
static void | assert_degree (BezierCurveN< required_degree > const *) |
Additional Inherited Members | |
![]() | |
static BezierCurve * | create (std::vector< Point > const &pts) |
Construct a curve from a vector of control points. | |
![]() | |
BezierCurve () | |
BezierCurve (Bezier const &x, Bezier const &y) | |
BezierCurve (std::vector< Point > const &pts) | |
bool | _equalTo (Curve const &c) const override |
![]() | |
D2< Bezier > | inner |
![]() | |
Coord | bezier_length (std::vector< Point > const &points, Coord tolerance) |
Compute the length of a bezier curve given by a vector of its control points. | |
Bezier curve with compile-time specified order.
degree | unsigned value indicating the order of the Bezier curve |
Definition at line 179 of file bezier-curve.h.
|
inline |
Construct a Bezier curve of the specified order with all points zero.
Definition at line 189 of file bezier-curve.h.
References degree, and Geom::BezierCurve::inner.
Referenced by Geom::BezierCurveN< degree >::duplicate(), Geom::BezierCurveN< degree >::portion(), Geom::BezierCurveN< degree >::reverse(), and Geom::BezierCurveN< degree >::subdivide().
|
inlineexplicit |
Construct from 2D Bezier polynomial.
Definition at line 194 of file bezier-curve.h.
References Geom::BezierCurve::inner.
|
inline |
Construct from two 1D Bezier polynomials of the same order.
Definition at line 199 of file bezier-curve.h.
References Geom::BezierCurve::inner.
|
inline |
Construct a Bezier curve from a vector of its control points.
Definition at line 204 of file bezier-curve.h.
References degree, and Geom::BezierCurve::inner.
|
inline |
Construct a linear segment from its endpoints.
Definition at line 215 of file bezier-curve.h.
References Geom::BezierCurve::inner.
|
inline |
Construct a quadratic Bezier curve from its control points.
Definition at line 222 of file bezier-curve.h.
References Geom::BezierCurve::inner.
|
inline |
Construct a cubic Bezier curve from its control points.
Definition at line 229 of file bezier-curve.h.
References Geom::BezierCurve::inner.
|
inlinestaticprivate |
Definition at line 183 of file bezier-curve.h.
|
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.
Reimplemented from Geom::BezierCurve.
|
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.
Reimplemented from Geom::BezierCurve.
Definition at line 370 of file bezier-curve.cpp.
|
inlineoverridevirtual |
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.
Reimplemented from Geom::BezierCurve.
Definition at line 322 of file bezier-curve.h.
References degree, Geom::derivative(), inner(), Geom::X, and Geom::Y.
Referenced by Geom::EllipticalArc::derivative().
|
inlineoverridevirtual |
Create an exact copy of this curve.
Reimplemented from Geom::BezierCurve.
Reimplemented in Geom::Path::ClosingSegment, and Geom::Path::StitchSegment.
Definition at line 264 of file bezier-curve.h.
References Geom::BezierCurveN< degree >::BezierCurveN().
|
virtual |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.
bbox[in,out] | bbox The rectangle to expand; it is assumed to already contain (initialPoint() * transform). |
transform | The transform to apply to the curve before taking its bounding box. |
Reimplemented from Geom::BezierCurve.
|
virtual |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.
bbox[in,out] | bbox The rectangle to expand; it is assumed to already contain (initialPoint() * transform). |
transform | The transform to apply to the curve before taking its bounding box. |
Reimplemented from Geom::BezierCurve.
|
virtual |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.
bbox[in,out] | bbox The rectangle to expand; it is assumed to already contain (initialPoint() * transform). |
transform | The transform to apply to the curve before taking its bounding box. |
Reimplemented from Geom::BezierCurve.
|
virtual |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.
bbox[in,out] | bbox The rectangle to expand; it is assumed to already contain (initialPoint() * transform). |
transform | The transform to apply to the curve before taking its bounding box. |
Reimplemented from Geom::BezierCurve.
Definition at line 643 of file bezier-curve.cpp.
References Geom::GenericRect< C >::expandTo().
|
virtual |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.
bbox[in,out] | bbox The rectangle to expand; it is assumed to already contain (initialPoint() * transform). |
transform | The transform to apply to the curve before taking its bounding box. |
Reimplemented from Geom::BezierCurve.
Definition at line 649 of file bezier-curve.cpp.
References Geom::bezier_expand_to_image().
|
virtual |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.
bbox[in,out] | bbox The rectangle to expand; it is assumed to already contain (initialPoint() * transform). |
transform | The transform to apply to the curve before taking its bounding box. |
Reimplemented from Geom::BezierCurve.
Definition at line 657 of file bezier-curve.cpp.
References Geom::bezier_expand_to_image().
|
inlineoverridevirtual |
Expand the given rectangle to include the transformed curve, assuming it already contains its initial point.
bbox[in,out] | bbox The rectangle to expand; it is assumed to already contain (initialPoint() * transform). |
transform | The transform to apply to the curve before taking its bounding box. |
Reimplemented from Geom::BezierCurve.
Definition at line 297 of file bezier-curve.h.
References Geom::BezierCurve::expandToTransformed(), and Geom::Curve::transform().
|
virtual |
Feed the curve to a PathSink.
Reimplemented from Geom::BezierCurve.
|
virtual |
Feed the curve to a PathSink.
Reimplemented from Geom::BezierCurve.
|
virtual |
Feed the curve to a PathSink.
Reimplemented from Geom::BezierCurve.
|
virtual |
Feed the curve to a PathSink.
Reimplemented from Geom::BezierCurve.
Definition at line 602 of file bezier-curve.cpp.
References Geom::PathSink::lineTo(), and Geom::PathSink::moveTo().
|
virtual |
Feed the curve to a PathSink.
Reimplemented from Geom::BezierCurve.
Definition at line 611 of file bezier-curve.cpp.
References Geom::PathSink::moveTo(), and Geom::PathSink::quadTo().
|
virtual |
Feed the curve to a PathSink.
Reimplemented from Geom::BezierCurve.
Definition at line 620 of file bezier-curve.cpp.
References Geom::PathSink::curveTo(), and Geom::PathSink::moveTo().
|
inlineoverridevirtual |
Feed the curve to a PathSink.
Reimplemented from Geom::BezierCurve.
Definition at line 293 of file bezier-curve.h.
References Geom::BezierCurve::feed().
|
virtual |
Compute intersections with another curve.
Reimplemented from Geom::BezierCurve.
|
virtual |
Compute intersections with another curve.
Reimplemented from Geom::BezierCurve.
|
virtual |
Compute intersections with another curve.
Reimplemented from Geom::BezierCurve.
|
virtual |
Compute intersections with another curve.
Filter out candidate times outside of the interval [0, 1] fuzzed so as to accommodate for epsilon.
Reimplemented from Geom::BezierCurve.
Definition at line 399 of file bezier-curve.cpp.
References Geom::cross(), Geom::distance(), Geom::dot(), Geom::Curve::finalPoint(), Geom::infinity(), Geom::Curve::initialPoint(), Geom::Curve::intersect(), Geom::Curve::isLineSegment(), Geom::Point::isZero(), len, Geom::Point::length(), Geom::middle_point(), Geom::Point::normalized(), Geom::Curve::pointAt(), result, Geom::transpose_in_place(), and w.
|
virtual |
Compute intersections with another curve.
Reimplemented from Geom::BezierCurve.
Definition at line 556 of file bezier-curve.cpp.
References Geom::BezierCurve::intersect().
|
virtual |
Compute intersections with another curve.
Reimplemented from Geom::BezierCurve.
Definition at line 572 of file bezier-curve.cpp.
References Geom::BezierCurve::intersect().
|
inlineoverridevirtual |
Compute intersections with another curve.
Reimplemented from Geom::BezierCurve.
Definition at line 286 of file bezier-curve.h.
References Geom::BezierCurve::intersect().
Referenced by Geom::BezierCurve::intersect(), Geom::EllipticalArc::intersect(), TEST(), TEST(), TEST(), TEST(), and TEST_F().
|
inlinevirtual |
Check whether the curve has exactly zero length.
Reimplemented from Geom::BezierCurve.
Definition at line 327 of file bezier-curve.h.
|
inlineoverridevirtual |
Check whether the curve has exactly zero length.
Reimplemented from Geom::BezierCurve.
Definition at line 252 of file bezier-curve.h.
References Geom::BezierCurve::isDegenerate().
Referenced by Geom::Path::_includesClosingSegment(), Geom::Path::back_closed(), Geom::Path::size_closed(), and sp_gradient_reset_to_userspace().
|
inlinevirtual |
Return false if there are at least 3 distinct control points, true otherwise.
Reimplemented from Geom::BezierCurve.
Definition at line 330 of file bezier-curve.h.
|
inlineoverridevirtual |
Return false if there are at least 3 distinct control points, true otherwise.
Reimplemented from Geom::BezierCurve.
Definition at line 256 of file bezier-curve.h.
References degree, and Geom::BezierCurve::isLineSegment().
|
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.
p | Query point |
a | Minimum time value to consider |
b | Maximum time value to consider; \(a < b\) |
Reimplemented from Geom::BezierCurve.
|
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.
p | Query point |
a | Minimum time value to consider |
b | Maximum time value to consider; \(a < b\) |
Reimplemented from Geom::BezierCurve.
Definition at line 376 of file bezier-curve.cpp.
References Geom::dot().
|
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.
p | Query point |
a | Minimum time value to consider |
b | Maximum time value to consider; \(a < b\) |
Reimplemented from Geom::BezierCurve.
Definition at line 283 of file bezier-curve.h.
References Geom::BezierCurve::nearestTime().
Referenced by GrDrag::addStopNearPoint(), Geom::EllipticalArc::allNearestTimes(), Geom::distance(), Inkscape::distance_to_segment(), gr_knot_moved_midpoint_handler(), RectHandle::hit(), GrDrag::selected_move(), and sp_item_gradient_set_coords().
|
inlineoverridevirtual |
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.
a | Beginning of the interval specifying the portion of the curve |
b | End of the interval |
Reimplemented from Geom::BezierCurve.
Definition at line 267 of file bezier-curve.h.
References Geom::BezierCurveN< degree >::BezierCurveN(), degree, Geom::BezierCurve::inner, Geom::BezierCurve::pointAt(), and Geom::portion().
|
inlineoverridevirtual |
Create a reversed version of this curve.
The result corresponds to portion(1, 0)
, but this method might be faster.
Reimplemented from Geom::BezierCurve.
Reimplemented in Geom::Path::ClosingSegment, and Geom::Path::StitchSegment.
Definition at line 274 of file bezier-curve.h.
References Geom::BezierCurveN< degree >::BezierCurveN(), degree, Geom::BezierCurve::finalPoint(), Geom::BezierCurve::initialPoint(), Geom::BezierCurve::inner, and Geom::reverse().
|
inline |
Divide a Bezier curve into two curves.
t | Time value |
Definition at line 245 of file bezier-curve.h.
References Geom::BezierCurveN< degree >::BezierCurveN(), Geom::BezierCurve::inner, Geom::X, and Geom::Y.
Referenced by Inkscape::LivePathEffect::LPERoughen::addNodesAndJitter(), Inkscape::LivePathEffect::path_from_piecewise_fix_cusps(), and Inkscape::UI::PathManipulator::subdivideSegment().
|
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.
p | Point where the winding number should be determined |
Reimplemented from Geom::Curve.
|
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.
p | Point where the winding number should be determined |
Reimplemented from Geom::Curve.
Definition at line 585 of file bezier-curve.cpp.
References inner(), Geom::lerp(), Geom::X, and Geom::Y.
|
inlineoverridevirtual |
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.
p | Point where the winding number should be determined |
Reimplemented from Geom::Curve.
Definition at line 290 of file bezier-curve.h.
References Geom::Curve::winding().