24#include "declarations.h"
135 double length(
double t1,
double t2)
const;
145 double step(
double t,
double ds)
const;
352 void swap(
Curve& other)
noexcept;
357 Eigen::MatrixX2d control_points_;
362 Cache(
const Cache& other);
363 Cache(Cache&&) =
default;
364 Cache& operator=(
const Cache& other);
365 Cache& operator=(Cache&&) =
default;
367 std::unique_ptr<const Curve> derivative;
368 std::optional<ParamVector> roots;
369 std::optional<BoundingBox> bounding_box;
370 std::optional<PointVector> polyline;
371 std::optional<ParamVector> polyline_t;
372 double polyline_flatness{};
373 std::optional<Eigen::VectorXd> projection_polynomial_const;
374 std::optional<Eigen::MatrixX2d> projection_polynomial_der;
375 std::optional<Eigen::VectorXd> chebyshev_polynomial;
379 mutable Cache cache_;
380 mutable std::recursive_mutex cache_mutex_;
A Bezier curve class.
Definition bezier.h:37
void applyContinuity(const Curve &curve, const std::vector< double > &beta_coeffs)
Apply geometric continuity based on another curve.
Eigen::MatrixX2d valueAt(const ParamVector &t_vector) const
Get the point vector on curve for given parameters.
Point controlPoint(unsigned idx) const
Get the control point at index idx.
double curvatureAt(double t) const
Get curvature of the curve for a given t.
Point valueAt(double t) const
Get the point on curve for a given t.
static Curve fromPolyline(const PointVector &polyline, unsigned order=0)
Fit a Bezier curve to an ordered polyline.
double distance(const Point &point) const
Get distance of the point to the curve.
Curve(const PointVector &points)
Create the Bezier curve.
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.
void reverse()
Reverse order of control points.
const Curve & derivative(unsigned n) const
Get the nth derivative of a curve.
Curve(Eigen::MatrixX2d points)
Create the Bezier curve.
static Curve joinCurves(const Curve &curve1, const Curve &curve2, unsigned order=0)
Fit a single Bezier curve through two curves joined end to end.
PointVector polyline(double flatness) const
Get a polyline representation of the curve as a vector of points on curve.
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 curve for a given t.
PointVector polyline() const
Get a polyline representation of the curve as a vector of points on curve.
PointVector controlPoints() const
Get a vector of control points.
Vector derivativeAt(double t) const
Get value of a derivative for a given t.
double length() const
Compute exact arc length using Chebyshev polynomials.
void raiseOrder()
Raise the curve order by 1.
ParamVector extrema() const
Get all extrema of the curve.
BoundingBox boundingBox() const
Get the bounding box of curve.
ParamVector roots() const
Get roots of the curve on both axes.
double projectPoint(const Point &point) const
Get the parameter t where curve is closest to given point.
const Curve & derivative() const
Get the derivative of a curve.
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.
std::pair< Point, Point > endPoints() const
Get first and last control points.
ParamVector polylineParams() const
Get curve parameters corresponding to polyline points.
double length(double t) const
Compute exact arc length using Chebyshev polynomials.
std::vector< Curve > splitCurve(const ParamVector &t_vector) const
Split the curve into subcurves at multiple parameters.
void lowerOrder()
Lower the curve order by 1.
static Curve offsetCurve(const Curve &curve, double offset, unsigned order=0)
Fit a Bezier approximation of the curve offset by a given distance.
double step(double t, double ds) const
Compute parameter t which is ds distance from given t.
std::pair< Curve, Curve > splitCurve(double t=0.5) const
Split the curve into two subcurves.
unsigned order() const
Get order of the curve (Nth order curve is described with N+1 points)
double curvatureDerivativeAt(double t) const
Get curvature derivative of the curve for a given t.
Vector tangentAt(double t) const
Get the unit tangent of the curve for a given t.
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