Inkscape
Vector Graphics Editor
|
Two-dimensional Bezier curve of arbitrary order. More...
#include <bezier-curve.h>
Public Member Functions | |
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. | |
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. | |
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. | |
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 deg) const override |
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. | |
void | operator*= (Translate const &tr) override |
void | operator*= (Scale const &s) override |
void | operator*= (Affine const &m) override |
Curve * | derivative () const override |
Create a derivative of this curve. | |
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 | 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. | |
Coord | length (Coord tolerance) const override |
Compute the arc length of this curve. | |
std::vector< CurveIntersection > | intersect (Curve const &other, Coord eps=EPSILON) const override |
Compute intersections with another 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. | |
void | feed (PathSink &sink, bool) const override |
Feed the curve to a PathSink. | |
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 |
Access and modify control points | |
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 int | winding (Point const &p) const |
Compute the partial winding number of this curve. | |
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 Public Member Functions | |
Construct a Bezier curve with runtime-determined order. | |
static BezierCurve * | create (std::vector< Point > const &pts) |
Construct a curve from a vector of control points. | |
Protected Member Functions | |
BezierCurve () | |
BezierCurve (Bezier const &x, Bezier const &y) | |
BezierCurve (std::vector< Point > const &pts) | |
bool | _equalTo (Curve const &c) const override |
Protected Attributes | |
D2< Bezier > | inner |
Related Symbols | |
(Note that these are not member symbols.) | |
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. | |
Two-dimensional Bezier curve of arbitrary order.
Bezier curves are an expansion of the concept of linear interpolation to n points. Linear segments in 2Geom are in fact Bezier curves of order 1.
Let \(\mathbf{B}_{\mathbf{p}_0\mathbf{p}_1\ldots\mathbf{p}_n}\) denote a Bezier curve of order \(n\) defined by the points \(\mathbf{p}_0, \mathbf{p}_1, \ldots, \mathbf{p}_n\). Bezier curve of order 1 is a linear interpolation curve between two points, defined as
\[ \mathbf{B}_{\mathbf{p}_0\mathbf{p}_1}(t) = (1-t)\mathbf{p}_0 + t\mathbf{p}_1 \]
If we now substitute points \(\mathbf{p_0}\) and \(\mathbf{p_1}\) in this definition by linear interpolations, we get the definition of a Bezier curve of order 2, also called a quadratic Bezier curve.
\begin{align*} \mathbf{B}_{\mathbf{p}_0\mathbf{p}_1\mathbf{p}_2}(t) &= (1-t) \mathbf{B}_{\mathbf{p}_0\mathbf{p}_1}(t) + t \mathbf{B}_{\mathbf{p}_1\mathbf{p}_2}(t) \\ \mathbf{B}_{\mathbf{p}_0\mathbf{p}_1\mathbf{p}_2}(t) &= (1-t)^2\mathbf{p}_0 + 2(1-t)t\mathbf{p}_1 + t^2\mathbf{p}_2 \end{align*}
By substituting points for quadratic Bezier curves in the original definition, we get a Bezier curve of order 3, called a cubic Bezier curve.
\begin{align*} \mathbf{B}_{\mathbf{p}_0\mathbf{p}_1\mathbf{p}_2\mathbf{p}_3}(t) &= (1-t) \mathbf{B}_{\mathbf{p}_0\mathbf{p}_1\mathbf{p}_2}(t) + t \mathbf{B}_{\mathbf{p}_1\mathbf{p}_2\mathbf{p}_3}(t) \\ \mathbf{B}_{\mathbf{p}_0\mathbf{p}_1\mathbf{p}_2\mathbf{p}_3}(t) &= (1-t)^3\mathbf{p}_0+3(1-t)^2t\mathbf{p}_1+3(1-t)t^2\mathbf{p}_2+t^3\mathbf{p}_3 \end{align*}
In general, a Bezier curve or order \(n\) can be recursively defined as
\[ \mathbf{B}_{\mathbf{p}_0\mathbf{p}_1\ldots\mathbf{p}_n}(t) = (1-t) \mathbf{B}_{\mathbf{p}_0\mathbf{p}_1\ldots\mathbf{p}_{n-1}}(t) + t \mathbf{B}_{\mathbf{p}_1\mathbf{p}_2\ldots\mathbf{p}_n}(t) \]
This substitution can be repeated an arbitrary number of times. To picture this, imagine the evaluation of a point on the curve as follows: first, all control points are joined with straight lines, and a point corresponding to the selected time value is marked on them. Then, the marked points are joined with straight lines and the point corresponding to the time value is marked. This is repeated until only one marked point remains, which is the point at the selected time value.
An important property of the Bezier curves is that their parameters (control points) have an intuitive geometric interpretation. Because of this, they are frequently used in vector graphics editors.
Every Bezier curve is contained in its control polygon (the convex polygon composed of its control points). This fact is useful for sweepline algorithms and intersection.
dynamic_cast
to those types, and for higher orders it will create an instance of BezierCurve. Definition at line 47 of file bezier-curve.h.
|
inlineprotected |
Definition at line 50 of file bezier-curve.h.
Referenced by create(), derivative(), duplicate(), portion(), and reverse().
Definition at line 51 of file bezier-curve.h.
|
protected |
Definition at line 111 of file bezier-curve.cpp.
Definition at line 55 of file bezier-curve.h.
|
overrideprotectedvirtual |
Implements Geom::Curve.
Definition at line 261 of file bezier-curve.cpp.
References c, controlPoint(), and size().
|
inlineoverridevirtual |
Compute the curve's exact bounding box.
This method can be dramatically slower than boundsFast() depending on the curve type.
Implements Geom::Curve.
Definition at line 112 of file bezier-curve.h.
References Geom::bounds_exact(), and inner.
|
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.
Implements Geom::Curve.
Definition at line 111 of file bezier-curve.h.
References Geom::bounds_fast(), and inner.
Referenced by boundsLocal(), and Geom::Ellipse::intersect().
|
inlineoverridevirtual |
Implements Geom::Curve.
Definition at line 114 of file bezier-curve.h.
References Geom::bounds_local(), boundsFast(), Geom::derivative(), inner, order(), Geom::X, and Geom::Y.
|
inline |
Access control points of the curve.
ix | The (zero-based) index of the control point. Note that the caller is responsible for checking that this value is <= order(). |
Definition at line 67 of file bezier-curve.h.
References inner, Geom::X, and Geom::Y.
Referenced by _equalTo(), feed(), feed_curve_to_cairo(), isLineSegment(), and operator*=().
|
inline |
Get the control points.
Definition at line 71 of file bezier-curve.h.
References Geom::bezier_points(), and inner.
Referenced by length(), and wrap_rq_to_cubic_l().
|
static |
Construct a curve from a vector of control points.
This will construct the appropriate specialization of BezierCurve (i.e. LineSegment, QuadraticBezier or Cubic Bezier) if the number of control points in the passed vector does not exceed 4.
Definition at line 310 of file bezier-curve.cpp.
References BezierCurve().
|
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 155 of file bezier-curve.h.
References order().
|
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.
Implements Geom::Curve.
Reimplemented in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, and Geom::BezierCurveN< 1 >.
Definition at line 152 of file bezier-curve.h.
References BezierCurve(), Geom::derivative(), inner, Geom::X, and Geom::Y.
|
inlineoverridevirtual |
Create an exact copy of this curve.
Implements Geom::Curve.
Reimplemented in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::Path::ClosingSegment, and Geom::Path::StitchSegment.
Definition at line 123 of file bezier-curve.h.
References BezierCurve().
Referenced by portion().
|
overridevirtual |
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. |
Implements Geom::Curve.
Reimplemented 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::BezierCurveN< degree >, and Geom::BezierCurveN< 1 >.
Definition at line 148 of file bezier-curve.cpp.
References Geom::bounds_exact(), inner, and Geom::Curve::transform().
Referenced by Geom::BezierCurveN< degree >::expandToTransformed().
|
overridevirtual |
Feed the curve to a PathSink.
Reimplemented from Geom::Curve.
Reimplemented 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::BezierCurveN< degree >, and Geom::BezierCurveN< 1 >.
Definition at line 281 of file bezier-curve.cpp.
References controlPoint(), Geom::PathSink::curveTo(), Geom::Curve::feed(), Geom::PathSink::lineTo(), Geom::PathSink::moveTo(), Geom::PathSink::quadTo(), and size().
Referenced by Geom::BezierCurveN< degree >::feed().
|
inlineoverridevirtual |
Retrieve the end of the curve.
Implements Geom::Curve.
Definition at line 106 of file bezier-curve.h.
References inner.
Referenced by Inkscape::UI::Tools::EraserTool::_accumulate(), Geom::Path::do_append(), intersect(), Geom::intersection(), Geom::detail::intersection_impl(), Geom::detail::intersection_impl(), length(), Geom::length(), Geom::middle_point(), Geom::projection(), Geom::BezierCurveN< degree >::reverse(), Geom::Path::snapEnds(), and TEST().
Definition at line 72 of file bezier-curve.h.
References inner.
|
inlineoverridevirtual |
Retrieve the start of the curve.
Implements Geom::Curve.
Definition at line 105 of file bezier-curve.h.
References inner.
Referenced by Inkscape::UI::Tools::EraserTool::_accumulate(), Geom::Path::do_append(), Geom::Path::do_update(), intersect(), Geom::intersection(), Geom::detail::intersection_impl(), Geom::detail::intersection_impl(), length(), Geom::length(), Geom::middle_point(), Geom::Path::nearestTime(), Geom::projection(), Geom::BezierCurveN< degree >::reverse(), Geom::Path::stitchTo(), and TEST().
|
overridevirtual |
Compute intersections with another curve.
Reimplemented from Geom::Curve.
Reimplemented 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::BezierCurveN< degree >, and Geom::BezierCurveN< 1 >.
Definition at line 177 of file bezier-curve.cpp.
References finalPoint(), Geom::find_intersections(), initialPoint(), inner, Geom::Curve::intersect(), Geom::BezierCurveN< degree >::intersect(), isLineSegment(), result, and Geom::transpose_in_place().
Referenced by Geom::BezierCurveN< degree >::intersect(), and Geom::BezierCurveN< degree >::intersect().
|
overridevirtual |
Check whether the curve has exactly zero length.
Implements Geom::Curve.
Reimplemented in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, and Geom::BezierCurveN< 1 >.
Definition at line 119 of file bezier-curve.cpp.
Referenced by Geom::BezierCurveN< degree >::isDegenerate().
|
overridevirtual |
Return false if there are at least 3 distinct control points, true otherwise.
Reimplemented from Geom::Curve.
Reimplemented in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, and Geom::BezierCurveN< 1 >.
Definition at line 131 of file bezier-curve.cpp.
References controlPoint(), end, size(), and start.
Referenced by intersect(), and Geom::BezierCurveN< degree >::isLineSegment().
Test whether two curves are approximately the same.
Implements Geom::Curve.
Definition at line 207 of file bezier-curve.cpp.
References Geom::are_near(), c, inner, isNear(), order(), and size().
Referenced by isNear().
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.
tolerance | Maximum allowed error |
Reimplemented from Geom::Curve.
Definition at line 153 of file bezier-curve.cpp.
References bezier_length(), controlPoints(), Geom::distance(), finalPoint(), initialPoint(), and order().
Referenced by Geom::Ellipse::intersect(), and Geom::Path::snapEnds().
|
overridevirtual |
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::Curve.
Reimplemented in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::BezierCurveN< degree >, and Geom::BezierCurveN< 1 >.
Definition at line 276 of file bezier-curve.cpp.
References inner, and Geom::nearest_time().
Referenced by Geom::BezierCurveN< degree >::nearestTime().
|
inlineoverridevirtual |
Implements Geom::Curve.
Definition at line 146 of file bezier-curve.h.
References controlPoint(), setPoint(), and size().
|
virtual |
Implements Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlineoverridevirtual |
Reimplemented from Geom::Curve.
Definition at line 140 of file bezier-curve.h.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlineoverridevirtual |
Reimplemented from Geom::Curve.
Definition at line 134 of file bezier-curve.h.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inline |
Definition at line 68 of file bezier-curve.h.
|
inline |
Get the order of the Bezier curve.
A Bezier curve has order() + 1 control points.
Definition at line 61 of file bezier-curve.h.
References inner, and Geom::X.
Referenced by Inkscape::UI::PathManipulator::_createControlPointsFromGeometry(), boundsLocal(), degreesOfFreedom(), isNear(), length(), setFinal(), and setPoints().
|
inlineoverridevirtual |
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.
t | Time value |
n | The number of derivatives to compute |
Implements Geom::Curve.
Definition at line 165 of file bezier-curve.h.
References inner.
Referenced by Geom::BezierFitter::NewtonRaphsonRootFind(), and Geom::EllipticalArc::pointAndDerivatives().
Evaluate the curve at a specified time value.
t | Time value |
Reimplemented from Geom::Curve.
Definition at line 164 of file bezier-curve.h.
References inner.
Referenced by GrDrag::addStopNearPoint(), Geom::EllipticalArc::allNearestTimes(), Geom::BezierFitter::compute_hook(), Geom::distance(), Inkscape::distance_to_segment(), draw_ratquad(), gr_knot_moved_midpoint_handler(), RectHandle::hit(), Inkscape::intersect_line_rectangle(), Geom::BezierFitter::NewtonRaphsonRootFind(), Inkscape::LivePathEffect::path_from_piecewise_fix_cusps(), Geom::EllipticalArc::pointAt(), Geom::BezierCurveN< degree >::portion(), GrDrag::selected_move(), sp_gradient_reset_to_userspace(), and Geom::xAx::toCurve().
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 |
Implements Geom::Curve.
Reimplemented in Geom::BezierCurveN< degree >, and Geom::BezierCurveN< 1 >.
Definition at line 250 of file bezier-curve.cpp.
References BezierCurve(), duplicate(), inner, Geom::portion(), and reverse().
|
inlineoverridevirtual |
Create a reversed version of this curve.
The result corresponds to portion(1, 0)
, but this method might be faster.
Reimplemented from Geom::Curve.
Reimplemented in Geom::BezierCurveN< degree >, Geom::BezierCurveN< 1 >, Geom::Path::ClosingSegment, and Geom::Path::StitchSegment.
Definition at line 129 of file bezier-curve.h.
References BezierCurve(), inner, and Geom::reverse().
Referenced by portion().
Computes time values at which the curve intersects an axis-aligned line.
v | The coordinate of the line |
d | Which axis the coordinate is on. X means a vertical line, Y a horizontal line. |
Implements Geom::Curve.
Definition at line 158 of file bezier-curve.h.
References inner.
Referenced by Geom::EllipticalArc::roots().
|
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.
p | New ending point of the curve |
Implements Geom::Curve.
Definition at line 110 of file bezier-curve.h.
References order(), and setPoint().
Referenced by Geom::Path::clear(), Geom::Path::do_append(), Geom::Path::do_update(), draw_ray(), Geom::Path::Path(), Geom::Path::setInitial(), and Geom::Path::start().
|
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.
p | New starting point of the curve |
Implements Geom::Curve.
Definition at line 109 of file bezier-curve.h.
References setPoint().
Referenced by Geom::Path::clear(), Geom::Path::close(), Geom::Path::do_append(), Geom::Path::do_update(), Inkscape::LivePathEffect::LPEFillBetweenMany::doEffect(), draw_ray(), Geom::Path::Path(), Geom::Path::setFinal(), Geom::Path::snapEnds(), and Geom::Path::start().
|
inline |
Modify a control point.
ix | The zero-based index of the point to modify. Note that the caller is responsible for checking that this value is <= order(). |
v | The new value of the point |
Definition at line 77 of file bezier-curve.h.
References inner, Geom::X, and Geom::Y.
Referenced by SPCurve::last_point_additive_move(), operator*=(), setFinal(), setInitial(), and setPoints().
|
inlinevirtual |
Set new control points.
ps | Vector which must contain order() + 1 points. Note that the caller is responsible for checking the size of this vector. |
LogicalError | Thrown when the size of the vector does not match the order. |
Definition at line 85 of file bezier-curve.h.
References order(), and setPoint().
|
inline |
Get the number of control points.
Definition at line 63 of file bezier-curve.h.
References inner, and Geom::X.
Referenced by _equalTo(), feed(), isDegenerate(), isLineSegment(), isNear(), operator*=(), operator*=(), operator*=(), TEST(), TEST_F(), TEST_F(), and timesWithRadiusOfCurvature().
std::vector< Coord > Geom::BezierCurve::timesWithRadiusOfCurvature | ( | double | radius | ) | const |
Computes the times where the radius of curvature of the bezier curve equals the given radius.
The algorithm works as follows: Find the solutions of curvature of curve at t = curvatureValue This is equivalent to (dx*ddy-ddx*dy)/curvatureValue = (dx**2+dy**2)**(3/2) When the left side is positive, taking the square gives ((dx*ddy-ddx*dy)/curvatureValue)**2 - (dx**2+dy**2)**3 = 0 This is a polyomial for BezierCurves and can be solved with root finding algos.
Definition at line 331 of file bezier-curve.cpp.
References Geom::derivative(), inner, size(), Geom::X, and Geom::Y.
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 169 of file bezier-curve.h.
References inner.
Referenced by Geom::xAx::crossings(), Geom::EllipticalArc::toSBasis(), wrap_rq_to_cubic_sb(), and wrap_rq_to_cubic_sb_l().
Evaluate one of the coordinates at the specified time value.
t | Time value |
d | The dimension to evaluate |
Reimplemented from Geom::Curve.
Definition at line 168 of file bezier-curve.h.
References inner.
Referenced by Geom::EllipticalArc::valueAt().
Compute the length of a bezier curve given by a vector of its control points.
Definition at line 746 of file bezier-curve.cpp.
References Geom::bezier_length_internal().
Referenced by length().
Definition at line 49 of file bezier-curve.h.
Referenced by Geom::BezierCurveN< degree >::BezierCurveN(), Geom::BezierCurveN< degree >::BezierCurveN(), Geom::BezierCurveN< degree >::BezierCurveN(), Geom::BezierCurveN< degree >::BezierCurveN(), Geom::BezierCurveN< degree >::BezierCurveN(), Geom::BezierCurveN< degree >::BezierCurveN(), Geom::BezierCurveN< degree >::BezierCurveN(), boundsExact(), boundsFast(), boundsLocal(), controlPoint(), controlPoints(), derivative(), expandToTransformed(), finalPoint(), fragment(), initialPoint(), intersect(), isDegenerate(), isNear(), nearestTime(), operator*=(), operator*=(), operator[](), order(), pointAndDerivatives(), pointAt(), portion(), Geom::BezierCurveN< degree >::portion(), reverse(), Geom::BezierCurveN< degree >::reverse(), roots(), setPoint(), size(), Geom::BezierCurveN< degree >::subdivide(), timesWithRadiusOfCurvature(), toSBasis(), and valueAt().