geomc 1.0
A c++ linear algebra template library
|
An extendable path defined by a sequence of knots and tangent points. More...
#include <geomc/shape/CubicPath.h>
Classes | |
struct | Knot |
A knot in a Bezier path, along with its tangents. More... | |
struct | Tangent |
A pair of tangents for a knot or segment in a Bezier path. More... | |
Public Types | |
using | elem_t |
The coordinate type of this object. | |
using | point_t |
The type of a point in this object's space. | |
using | Spline |
Public Member Functions | |
BezierPath ()=default | |
Construct an empty path. | |
BezierPath (const BezierSpline< T, N > &segment) | |
Construct a path from a sequence of knots and tangents. | |
VecType< T, N > | acceleration (T s) const |
Evaluate the second derivative of the path at s , with respect to s . | |
void | add_knot (const Knot &k) |
Add a knot to the path, with tangents for the new segment. | |
void | add_knot (VecType< T, N > knot, VecType< T, N > tangent) |
Add a knot to the path, with a symmetrical tangent for the previous knot. | |
Rect< T, N > | bounds () const |
Compute the axis-aligned bounding box of the path. | |
void | clear () |
Remove all knots and their tangents from the path. | |
VecType< T, N > & | knot (size_t i) |
Return a reference to the i th knot in the path. | |
VecType< T, N > | knot (size_t i) const |
Return the i th knot in the path. | |
size_t | n_segments () const |
Return the number of complete segments in the path. | |
VecType< T, N > | operator() (T s) const |
Evaluate the path at s . | |
std::optional< BezierSpline< T, N > > | operator[] (size_t i) const |
Return the i th segment in the path. | |
std::optional< Knot > | remove_knot (size_t i) |
Remove the i th knot from the path. | |
std::optional< size_t > | segment (T s) const |
Return the index of the segment containing s . | |
void | set_tangents_for_knot (size_t i, const Tangent &t) |
Set the tangents on either side of the i th knot in the path. | |
void | set_tangents_for_segment (size_t i, const Tangent &t) |
Set the tangents for the i th segment in the path. | |
void | set_velocity_for_knot (size_t i, VecType< T, N > v) |
Set the velocity for the i th knot in the path. | |
Tangent | tangents_for_knot (size_t i) const |
Return the tangents for the i th knot in the path. | |
Tangent | tangents_for_segment (size_t i) const |
Return the tangents for the i th segment in the path. | |
VecType< T, N > | velocity (T s) const |
Evaluate the derivative of the path at s , with respect to s . | |
Static Public Attributes | |
static constexpr index_t | N |
The dimension of this object. | |
An extendable path defined by a sequence of knots and tangent points.
Bezier paths are concatenated cubic Bezier splines, where the first knot of each segment is the last knot of the previous segment.
Bezier curves are C0 continuous, and pass through the guide knots. It is allowed to have "broken tangents" at each knot, though the curve can be made C1 continuous by setting a tangent velocity for each knot.
|
inherited |
The type of a point in this object's space.
An N-vector of T if N > 1, otherwise a T.
Evaluate the second derivative of the path at s
, with respect to s
.
The range of s
is the same as for operator()
.
Compute the axis-aligned bounding box of the path.
O(n) on the number of segments.
Evaluate the path at s
.
Segment i
is evaluated for s
in the range [i, i + 1]
. If s
is outside the range [0, n_segments()]
, the path is extrapolated using the first or last segment.
|
inline |
Return the i
th segment in the path.
If there are no complete segments in the path, return std::nullopt
.
|
inline |
Remove the i
th knot from the path.
If i
is not in the range of existing knots, return std::nullopt
.
|
inlineinherited |
Return the index of the segment containing s
.
If there are no complete segments in the path, return std::nullopt
.
|
inline |
Set the tangents on either side of the i
th knot in the path.
If i
is the first or last knot, then only the inward tangent is set.
Set the velocity for the i
th knot in the path.
The segments to the left and right of the knot will be made C1 continuous.
Evaluate the derivative of the path at s
, with respect to s
.
The range of s
is the same as for operator()
.