Thunderbots Project
Loading...
Searching...
No Matches
CubicBezierSpline2d Class Reference

#include <cubic_bezier_spline2d.h>

Inheritance diagram for CubicBezierSpline2d:
Collaboration diagram for CubicBezierSpline2d:

Public Member Functions

 CubicBezierSpline2d (const Point &start_point, const Vector &start_vector, const Point &end_point, const Vector &end_vector, const std::vector< Point > &intermediate_knots)
 
const Point getValueAt (double t) const override
 
const std::vector< PointgetKnots () const override
 
size_t getNumKnots () const override
 
std::vector< double > getKnotParametrizationValues () const override
 
const Point getStartPoint () const override
 
const Point getEndPoint () const override
 
const std::vector< SplineSegment2dgetSplineSegments () const override
 
const std::vector< Point > & getControlPoints () const
 
size_t getNumSegments () const
 

Additional Inherited Members

- Static Protected Member Functions inherited from Spline2d
static SplineSegment2d createSplineSegment2d (double start_val, double end_val, Polynomial2d polynomial)
 

Detailed Description

A Cubic Bezier spline is a C2 continuous spline that is formed by a series of bezier curves.

Some useful resources: https://www.ibiblio.org/e-notes/Splines/Intro.htm https://www.ibiblio.org/e-notes/Splines/b-int.html

Constructor & Destructor Documentation

◆ CubicBezierSpline2d()

CubicBezierSpline2d ( const Point start_point,
const Vector start_vector,
const Point end_point,
const Vector end_vector,
const std::vector< Point > &  intermediate_knots 
)
explicit

Create a CubicBezierSpline2d that:

  • starts from start and is tangent to start_vector at the start
  • ends at end and is tangent to end_vector at the end

    ** EXAMPLE: **

                       XXXXXXXXX
    start_vector  XXXXX         XXXXX   end_vector
          ^     XXX                 XXX     ^
          |    XX                     XX    |
          |   XX                       XX   |
          |  XX                         XX  |
          |  X                           X  |
          | XX                           XX |
          | X                             X |
          | X                             X |
          |XX                             XX|
          |X                               X|
          |X                               X|
          |X                               X|
    

    start + + end

Parameters
start_pointThe first point on the spline
start_vectorThe tangent vector at the start of the spline
end_pointThe last point on the spline
end_vectorThe tangent vector at the end of the spline. NOTE: this points back along the body of the spline, instead of "off the end" of the spline. ie. this vector is "symmetric" with start_vector
intermediate_knotsThe intermediate points between start_point and end_point that this spline will pass through

The direction of the start and end vectors determine the direction of the curve at the start and end points. The magnitude of these vectors determine how far the curve is stretched in the direction of the vector before connecting with the intermediate points

Member Function Documentation

◆ getControlPoints()

const std::vector< Point > & getControlPoints ( ) const

Get the control points that are the implicit representation of the bezier curves that form this spline.

Returns
The control points that represent the the bezier curves that form this spline.

◆ getEndPoint()

const Point getEndPoint ( ) const
overridevirtual

Gets end point of spline

Returns
end point of spline

Implements Spline2d.

◆ getKnotParametrizationValues()

std::vector< double > getKnotParametrizationValues ( ) const
overridevirtual

Get the parametrization values corresponding to the knots of this spline

So for example, if we had a 3-knot spline that is linearly interpolated, this function would return {0, 0.5, 1}.

NOTE: There is no guarantee that the knots will be at linearly interpolated (equally spaced) intervals. This could return {0, 0.25, 1.0} and still be well defined.

Returns
The parametrization values corresponding to the knots of this spline

Implements Spline2d.

◆ getKnots()

const std::vector< Point > getKnots ( ) const
overridevirtual

Get the knots of this spline, including the start and end points

Returns
The knots of this spline, including the start and end points

Implements Spline2d.

◆ getNumKnots()

size_t getNumKnots ( ) const
overridevirtual

Gets the number of knots in the spline including start and end points

Returns
The number of knots in the spline including start and end points

Implements Spline2d.

◆ getNumSegments()

size_t getNumSegments ( ) const

Get the number of segments on this spline.

Returns
The number of segments on this spline.

◆ getSplineSegments()

const std::vector< SplineSegment2d > getSplineSegments ( ) const
overridevirtual

Get the segments that make up this spline.

Returns
The segments that make up this spline, with the order of segments being the order in which they appear along the spline, going from start to end.

Implements Spline2d.

◆ getStartPoint()

const Point getStartPoint ( ) const
overridevirtual

Gets start point of spline

Returns
start point of spline

Implements Spline2d.

◆ getValueAt()

const Point getValueAt ( double  t) const
overridevirtual

Calculates the value of spline evaluated at value t

Parameters
tA value in [0,1] to get the value of the spline at. 0 is one endpoint of the spline 1 is the other endpoint of the spline
Returns
Value of spline evaluated at t. If t not in [0,1], then the closest endpoint

Implements Spline2d.


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