2D Bezier curve
More...
#include <BezierCurve.h>
2D Bezier curve
BezierCurve is a class to represent a parametric Bezier curve.
◆ BezierCurve()
spatium::gfx2d::BezierCurve::BezierCurve |
( |
const std::vector< std::array< double, 2 >> & |
points | ) |
|
|
inline |
Constructor.
- Parameters
-
[in] | points | Anchor points (first and last point) and control points (intermediate). Min length = 2. |
◆ degree()
int spatium::gfx2d::BezierCurve::degree |
( |
| ) |
const |
|
inline |
Get the degree of the curve.
The degree is the number of points - 1. A 1st degree curve (linear) has two points, a 2nd degree curve (cubic) has 3 points, a 3rd degree curve (cubic) has 4 points, etc,
- Returns
- Degree
◆ divide()
BezierCurve spatium::gfx2d::BezierCurve::divide |
( |
| ) |
const |
|
inline |
Divide a bezier curve.
This will increase the degree of the curve without affecting the shape. The new control points are placed in between the existing control points
- Returns
- Bezier curve with degree + 1
- Todo:
- This function doesn't work properly yet. Perhaps it should be recursive.
◆ evaluate()
std::array<double, 2> spatium::gfx2d::BezierCurve::evaluate |
( |
double |
t | ) |
const |
|
inline |
Evaluate bezier curve.
- Parameters
-
[in] | t | Parameter along curve. Range [0,1] |
- Returns
- Point coordinates (x,y)
◆ points()
std::vector<std::array<double,2> > spatium::gfx2d::BezierCurve::points |
( |
| ) |
const |
|
inline |
Get the points of the curve.
A curve should at least have 2 control points. The first and last control points (anchor points) are the starting point and end point of the line.
- Returns
- Points
◆ operator<<
std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const BezierCurve & |
curve |
|
) |
| |
|
friend |
The documentation for this class was generated from the following file:
- /home/martijn/Development/Projects/SpatiumLib/include/spatium/gfx2d/BezierCurve.h