21 _ControlPolygon.push_back(iPoint);
22 if (_ControlPolygon.size() == 4) {
29 if (_ControlPolygon.size() != 4) {
34 vector<Vec2d>::const_iterator p0, p1, p2, p3;
35 p0 = _ControlPolygon.begin();
44 x[0] = -p0->x() + 3 * p1->x() - 3 * p2->x() + p3->x();
45 x[1] = 3 * p0->x() - 6 * p1->x() + 3 * p2->x();
46 x[2] = -3 * p0->x() + 3 * p1->x();
49 y[0] = -p0->y() + 3 * p1->y() - 3 * p2->y() + p3->y();
50 y[1] = 3 * p0->y() - 6 * p1->y() + 3 * p2->y();
51 y[2] = -3 * p0->y() + 3 * p1->y();
55 float increment = 1.0 /
float(nvertices);
57 for (
int i = 0; i <= nvertices; ++i) {
58 _Vertices.emplace_back((
x[3] + t * (
x[2] + t * (
x[1] + t *
x[0]))),
59 (
y[3] + t * (
y[2] + t * (
y[1] + t *
y[0]))));
64BezierCurve::BezierCurve()
69BezierCurve::BezierCurve(vector<Vec2d> &iPoints,
double error)
77 vector<Vec2d>::iterator
v, vend;
78 for (
v = curve.begin(), vend = curve.end();
v != vend; ++
v) {
79 if ((i == 0) || (i % 4 != 0)) {
86BezierCurve::~BezierCurve()
88 if (!_Segments.empty()) {
89 vector<BezierCurveSegment *>::iterator
v, vend;
90 for (
v = _Segments.begin(), vend = _Segments.end();
v != vend; ++
v) {
94 delete _currentSegment;
97void BezierCurve::AddControlPoint(
const Vec2d &iPoint)
99 _ControlPolygon.push_back(iPoint);
100 _currentSegment->AddControlPoint(iPoint);
101 if (_currentSegment->size() == 4) {
102 _Segments.push_back(_currentSegment);
Class to define a Bezier curve of order 4.
An Algorithm for Automatically Fitting Digitized Curves by Philip J. Schneider,.
ATTR_WARN_UNUSED_RESULT const BMVert * v
void AddControlPoint(const Vec2d &iPoint)
virtual ~BezierCurveSegment()
void AddControlPoint(const Vec2d &iPoint)
void FitCurve(std::vector< Vec2d > &data, std::vector< Vec2d > &oCurve, double error)
draw_view in_light_buf[] float
static void error(const char *str)
VecMat::Vec2< double > Vec2d