geomc 1.0
A c++ linear algebra template library
Loading...
Searching...
No Matches
BezierPath< T, N > Class Template Reference

An extendable path defined by a sequence of knots and tangent points. More...

#include <geomc/shape/CubicPath.h>

Inheritance diagram for BezierPath< T, N >:
SplinePath< T, N, BezierSpline< T, N >, BezierPath< T, N > > Dimensional< T, N >

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, Nacceleration (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, Nbounds () 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 ith knot in the path.
 
VecType< T, Nknot (size_t i) const
 Return the ith knot in the path.
 
size_t n_segments () const
 Return the number of complete segments in the path.
 
VecType< T, Noperator() (T s) const
 Evaluate the path at s.
 
std::optional< BezierSpline< T, N > > operator[] (size_t i) const
 Return the ith segment in the path.
 
std::optional< Knotremove_knot (size_t i)
 Remove the ith 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 ith knot in the path.
 
void set_tangents_for_segment (size_t i, const Tangent &t)
 Set the tangents for the ith segment in the path.
 
void set_velocity_for_knot (size_t i, VecType< T, N > v)
 Set the velocity for the ith knot in the path.
 
Tangent tangents_for_knot (size_t i) const
 Return the tangents for the ith knot in the path.
 
Tangent tangents_for_segment (size_t i) const
 Return the tangents for the ith segment in the path.
 
VecType< T, Nvelocity (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.
 

Detailed Description

template<typename T, index_t N>
class geom::BezierPath< T, N >

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.

Member Typedef Documentation

◆ point_t

using point_t
inherited

The type of a point in this object's space.

An N-vector of T if N > 1, otherwise a T.

Member Function Documentation

◆ acceleration()

VecType< T, N > acceleration ( T s) const
inlineinherited

Evaluate the second derivative of the path at s, with respect to s.

The range of s is the same as for operator().

◆ bounds()

Rect< T, N > bounds ( ) const
inlineinherited

Compute the axis-aligned bounding box of the path.

O(n) on the number of segments.

◆ operator()()

VecType< T, N > operator() ( T s) const
inlineinherited

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.

◆ operator[]()

template<typename T, index_t N>
std::optional< BezierSpline< T, N > > operator[] ( size_t i) const
inline

Return the ith segment in the path.

If there are no complete segments in the path, return std::nullopt.

◆ remove_knot()

template<typename T, index_t N>
std::optional< Knot > remove_knot ( size_t i)
inline

Remove the ith knot from the path.

If i is not in the range of existing knots, return std::nullopt.

◆ segment()

std::optional< size_t > segment ( T s) const
inlineinherited

Return the index of the segment containing s.

If there are no complete segments in the path, return std::nullopt.

◆ set_tangents_for_knot()

template<typename T, index_t N>
void set_tangents_for_knot ( size_t i,
const Tangent & t )
inline

Set the tangents on either side of the ith knot in the path.

If i is the first or last knot, then only the inward tangent is set.

◆ set_velocity_for_knot()

template<typename T, index_t N>
void set_velocity_for_knot ( size_t i,
VecType< T, N > v )
inline

Set the velocity for the ith knot in the path.

The segments to the left and right of the knot will be made C1 continuous.

◆ velocity()

VecType< T, N > velocity ( T s) const
inlineinherited

Evaluate the derivative of the path at s, with respect to s.

The range of s is the same as for operator().


The documentation for this class was generated from the following file: