TinySpline
0.7.0
Spline Library for a Multitude of Programming Languages
|
#include <tinyspline.h>
Public Attributes | |
struct tsDeBoorNetImpl * | pImpl |
Represents the output of De Boor's algorithm. De Boor's algorithm is used to evaluate a spline at a certain knot by iteratively computing a net of intermediate points until the resulting point is available:
https://en.wikipedia.org/wiki/De_Boor%27s_algorithm https://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/de-Boor.html
All points of a net are stored in points
(ts_deboornet_points). The resulting point is the last point in points
and, for the sake of convenience, can be accessed with ts_deboornet_result.
Two dimensional points are stored as follows:
[x_0, y_0, x_1, y_1, ..., x_n-1, y_n-1]
Tree dimensional points are stored as follows:
[x_0, y_0, z_0, x_1, y_1, z_1, ..., x_n-1, y_n-1, z_n-1]
... and so on. The output also supports homogeneous coordinates (cf. tsBSpline).
There is a special case in which the evaluation of a knot u
returns two results instead of one. It occurs when the multiplicity of u
(s(u)
) is equals to the order of the evaluated spline, indicating that the spline is discontinuous at u
. This is common practice for B-Splines (and NURBS) consisting of connected Bezier curves where the endpoint of curve c_i
is equal to the start point of curve c_i+1
. Yet, the end point of c_i
and the start point of c_i+1
may still be completely different, yielding to visible gaps (if distance of the points is large enough). In such case (s(u)
== order
), ts_deboornet_points stores only the two resulting points (there is no net to calculate) and ts_deboornet_result points to the first point in ts_deboornet_points. Since having gaps in splines is unusual, both points in ts_deboornet_points are generally equal, making it easy to handle this special case by simply calling ts_deboornet_result. However, one can access both points if necessary:
ts_deboornet_result(...)[0] ... // Access the first component of // the first result. ts_deboornet_result(...)[dim(spline)] // Access the first component of // the second result.
As if this wasn't complicated enough, there is an exception for this special case, yielding to exactly one result (just like the regular case) even if s(u)
== order
. It occurs when u
is the lower or upper bound of the domain of the evaluated spline. For instance, if b
is a spline with domain [0, 1] and b
is evaluated at u
= 0
or u
= 1
, then ts_deboornet_result is always a single point regardless of the multiplicity of u
.
In summary, there are three different types of evaluation:
s(u)
== order
).All in all this looks quite complex (and actually it is), but for most applications you do not have to deal with this. Just use ts_deboornet_result to access the outcome of De Boor's algorithm.
struct tsDeBoorNetImpl* tsDeBoorNet::pImpl |
The actual implementation.