Bezier 0.4.0
Fast and lightweight class for using the Bezier curves of any order in C++
Loading...
Searching...
No Matches
polycurve.h
1/*
2 * Copyright 2019 Mirko Kokot
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef POLYCURVE_H
18#define POLYCURVE_H
19
20#include <deque>
21
22#include "Bezier/bezier.h"
23#include "Bezier/declarations.h"
24
25namespace Bezier
26{
27
39{
40public:
41 PolyCurve() = default;
42 ~PolyCurve() = default;
43
48 PolyCurve(std::deque<Curve> curves);
49
50 PolyCurve(const PolyCurve&) = default;
51 PolyCurve(PolyCurve&&) = default;
52 PolyCurve& operator=(const PolyCurve&) = default;
53 PolyCurve& operator=(PolyCurve&&) = default;
54
61 void insertAt(unsigned idx, Curve curve);
62
68
74
80 void removeAt(unsigned idx);
81
87
92 void removeBack();
93
98 unsigned size() const;
99
107 unsigned curveIdx(double t) const;
108
110
116 Curve& curve(unsigned idx);
117 const Curve& curve(unsigned idx) const;
119
121
125 std::deque<Curve>& curves();
126 const std::deque<Curve>& curves() const;
128
135
141 PointVector polyline(double flatness) const;
142
149
155 ParamVector polylineParams(double flatness) const;
156
161 double length() const;
162
168 double length(double t) const;
169
176 double length(double t1, double t2) const;
177
184 double step(double t, double ds) const;
185
191 std::pair<Point, Point> endPoints() const;
192
198
205 void setControlPoint(unsigned idx, const Point& point);
206
212 Point valueAt(double t) const;
213
219 PointVector valueAt(const ParamVector& t_vector) const;
220
226 double curvatureAt(double t) const;
227
233 double curvatureDerivativeAt(double t) const;
234
240 Vector tangentAt(double t) const;
241
247 Vector normalAt(double t) const;
248
254 Vector derivativeAt(double t) const;
255
262 Vector derivativeAt(unsigned n, double t) const;
263
269
271
279
285 double projectPoint(const Point& point) const;
286
292 ParamVector projectPoint(const PointVector& point_vector) const;
293
299 double distance(const Point& point) const;
300
306 std::vector<double> distance(const PointVector& point_vector) const;
307
308protected:
310 std::deque<Curve> curves_;
311};
312
313} // namespace Bezier
314#endif // POLYCURVE_H
A Bezier curve class.
Definition bezier.h:37
A Bezier polycurve class.
Definition polycurve.h:39
std::deque< Curve > curves_
Structure for holding underlying Bezier curves.
Definition polycurve.h:310
unsigned size() const
Get number of subcurves.
double curvatureAt(double t) const
Get curvature of the polycurve for a given t.
Point valueAt(double t) const
Get the point on polycurve for a given t.
double distance(const Point &point) const
Get distance of the point to the polycurve.
ParamVector polylineParams(double flatness) const
Get curve parameters corresponding to polyline points.
PointVector intersections(const Curve &curve) const
Get the points of intersection with another curve or polycurve.
std::deque< Curve > & curves()
Get list of all subcurves.
void insertFront(Curve curve)
Insert new curve at the beginning of the polycurve.
void removeFirst()
Remove a subcurve from the beginning of the polycurve.
Curve & curve(unsigned idx)
Get a subcurve.
PointVector polyline(double flatness) const
Get a polyline representation of the polycurve as a vector of points on curve.
void insertBack(Curve curve)
Insert new curve at the end of the polycurve.
void setControlPoint(unsigned idx, const Point &point)
Set the new coordinates to a control point.
Vector normalAt(double t) const
Get the unit normal of the polycurve for a given t.
void removeBack()
Remove a subcurve from the end of the polycurve.
PolyCurve(std::deque< Curve > curves)
Create the Bezier polycurve from deque of curves.
PointVector polyline() const
Get a polyline representation of the polycurve as a vector of points on curve.
std::vector< double > distance(const PointVector &point_vector) const
Get the distance vector of points to the polycurve.
PointVector controlPoints() const
Get the control points of all subcurves.
Vector derivativeAt(double t) const
Get value of a derivative for a given t.
const Curve & curve(unsigned idx) const
Get a subcurve.
double length() const
Compute exact arc length using Chebyshev polynomials.
ParamVector projectPoint(const PointVector &point_vector) const
Get the parameter t vector where polycurve is closest to given points.
BoundingBox boundingBox() const
Get the bounding box of the polycurve.
void insertAt(unsigned idx, Curve curve)
Insert new curve into polycurve.
double projectPoint(const Point &point) const
Get the parameter t where polycurve is closest to given point.
Vector derivativeAt(unsigned n, double t) const
Get value of an nth derivative for a given t.
double length(double t1, double t2) const
Compute exact arc length using Chebyshev polynomials.
PointVector intersections(const PolyCurve &curve) const
Get the points of intersection with another curve or polycurve.
std::pair< Point, Point > endPoints() const
Get first and last control points.
ParamVector polylineParams() const
Get curve parameters corresponding to polyline points.
const std::deque< Curve > & curves() const
Get list of all subcurves.
double length(double t) const
Compute exact arc length using Chebyshev polynomials.
double step(double t, double ds) const
Compute parameter t which is ds distance from given t.
void removeAt(unsigned idx)
Remove a subcurve from the polycurve.
PointVector valueAt(const ParamVector &t_vector) const
Get the point vector on polycurve for given parameters.
unsigned curveIdx(double t) const
Resolve polycurve parameter to subcurve index.
double curvatureDerivativeAt(double t) const
Get curvature derivative of the polycurve for a given t.
Vector tangentAt(double t) const
Get the unit tangent of the polycurve for a given t.
Definition bezier.h:27
Eigen::Vector2d Point
Point in xy plane.
Definition declarations.h:40
std::vector< double > ParamVector
A vector of curve parameters.
Definition declarations.h:50
std::vector< Point > PointVector
A vector of Points.
Definition declarations.h:45
Eigen::AlignedBox2d BoundingBox
Bounding box class.
Definition declarations.h:60
Eigen::Vector2d Vector
A Vector in xy plane.
Definition declarations.h:55