Inkscape
Vector Graphics Editor
|
Symmetric power basis curve. More...
#include <sbasis-curve.h>
Public Member Functions | |
SBasisCurve (D2< SBasis > const &sb) | |
SBasisCurve (Curve const &other) | |
Curve * | duplicate () const override |
Create an exact copy of this curve. | |
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 |
Check whether the curve is a line segment. | |
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. | |
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 |
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. | |
std::vector< Coord > | allNearestTimes (Point const &p, Coord from=0, Coord to=1) const override |
Compute time values at which the curve comes closest to a specified point. | |
Coord | length (Coord tolerance) const override |
Compute the arc length of this curve. | |
Curve * | portion (Coord f, Coord t) const override |
Create a curve that corresponds to a part of this curve. | |
void | operator*= (Affine const &m) override |
Curve * | derivative () const override |
Create a derivative of this curve. | |
D2< SBasis > | toSBasis () const override |
Convert the curve to a symmetric power basis polynomial. | |
bool | isNear (Curve const &, Coord) const override |
Test whether two curves are approximately the same. | |
int | degreesOfFreedom () const override |
Return the number of independent parameters required to represent all variations 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 |
![]() | |
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. | |
virtual Curve * | reverse () const |
Create a reversed version of this curve. | |
Coord | nearestTime (Point const &p, Interval const &i) const |
A version that takes an Interval. | |
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 > | intersect (Curve const &other, Coord eps=EPSILON) const |
Compute intersections with another 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. | |
virtual void | feed (PathSink &sink, bool moveto_initial) const |
Feed the curve to a PathSink. | |
Protected Member Functions | |
bool | _equalTo (Curve const &c) const override |
Private Attributes | |
D2< SBasis > | inner |
Symmetric power basis curve.
Symmetric power basis (S-basis for short) polynomials are a versatile numeric representation of arbitrary continuous curves. They are the main representation of curves in 2Geom.
S-basis is defined for odd degrees and composed of the following polynomials:
\begin{align*} P_k^0(t) &= t^k (1-t)^{k+1} \\ P_k^1(t) &= t^{k+1} (1-t)^k \end{align*}
This can be understood more easily with the help of the chart below. Each square represents a product of a specific number of \(t\) and \((1-t)\) terms. Red dots are the canonical (monomial) basis, the green dots are the Bezier basis, and the blue dots are the S-basis, all of them of degree 7.
The S-Basis has several important properties:
More in-depth information can be found in the following paper: J Sanchez-Reyes, "The symmetric analogue of the polynomial power basis". ACM Transactions on Graphics, Vol. 16, No. 3, July 1997, pages 319–357. http://portal.acm.org/citation.cfm?id=256162
Definition at line 80 of file sbasis-curve.h.
Definition at line 85 of file sbasis-curve.h.
|
inlineexplicit |
Definition at line 86 of file sbasis-curve.h.
|
inlineoverrideprotectedvirtual |
|
inlineoverridevirtual |
Compute time values at which the curve comes closest to a specified point.
p | Query point |
a | Minimum time value to consider |
b | Maximum time value to consider; \(a < b\) |
Reimplemented from Geom::Curve.
Definition at line 116 of file sbasis-curve.h.
References Geom::all_nearest_times(), and inner.
|
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 105 of file sbasis-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 104 of file sbasis-curve.h.
References Geom::bounds_fast(), and inner.
|
inlineoverridevirtual |
Implements Geom::Curve.
Definition at line 109 of file sbasis-curve.h.
References Geom::bounds_local(), and inner.
Referenced by Geom::EllipticalArc::boundsLocal().
|
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 137 of file sbasis-curve.h.
References inner.
|
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.
Definition at line 129 of file sbasis-curve.h.
References Geom::derivative(), and inner.
|
inlineoverridevirtual |
Create an exact copy of this curve.
Implements Geom::Curve.
Definition at line 88 of file sbasis-curve.h.
|
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. |
Implements Geom::Curve.
Definition at line 106 of file sbasis-curve.h.
References Geom::bounds_exact(), inner, and Geom::Curve::transform().
|
inlineoverridevirtual |
Retrieve the end of the curve.
Implements Geom::Curve.
Definition at line 90 of file sbasis-curve.h.
References inner.
|
inlineoverridevirtual |
Retrieve the start of the curve.
Implements Geom::Curve.
Definition at line 89 of file sbasis-curve.h.
References inner.
|
inlineoverridevirtual |
Check whether the curve has exactly zero length.
Implements Geom::Curve.
Definition at line 91 of file sbasis-curve.h.
References inner.
|
inlineoverridevirtual |
Check whether the curve is a line segment.
Reimplemented from Geom::Curve.
Definition at line 92 of file sbasis-curve.h.
Test whether two curves are approximately the same.
Implements Geom::Curve.
Definition at line 133 of file sbasis-curve.h.
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 121 of file sbasis-curve.h.
References inner.
|
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::Curve.
Definition at line 113 of file sbasis-curve.h.
References inner, and Geom::nearest_time().
|
inlineoverridevirtual |
|
virtual |
Implements Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
inlinevirtual |
Reimplemented from Geom::Curve.
|
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 94 of file sbasis-curve.h.
References inner.
Evaluate the curve at a specified time value.
t | Time value |
Reimplemented from Geom::Curve.
Definition at line 93 of file sbasis-curve.h.
References inner.
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.
Definition at line 122 of file sbasis-curve.h.
References inner, and Geom::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 112 of file sbasis-curve.h.
References inner, and Geom::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 101 of file sbasis-curve.h.
References inner.
|
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 98 of file sbasis-curve.h.
References inner.
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 132 of file sbasis-curve.h.
References inner.
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 97 of file sbasis-curve.h.
References inner.
Definition at line 82 of file sbasis-curve.h.
Referenced by _equalTo(), allNearestTimes(), boundsExact(), boundsFast(), boundsLocal(), degreesOfFreedom(), derivative(), expandToTransformed(), finalPoint(), initialPoint(), isDegenerate(), isLineSegment(), length(), nearestTime(), operator*=(), pointAndDerivatives(), pointAt(), portion(), roots(), setFinal(), setInitial(), toSBasis(), and valueAt().