28 lines
836 B
C++
28 lines
836 B
C++
|
|
#pragma once
|
||
|
|
#include "vde/core/point.h"
|
||
|
|
#include <vector>
|
||
|
|
|
||
|
|
namespace vde::curves {
|
||
|
|
|
||
|
|
class BezierCurve {
|
||
|
|
public:
|
||
|
|
explicit BezierCurve(std::vector<Point3D> control_points);
|
||
|
|
|
||
|
|
[[nodiscard]] Point3D evaluate(double t) const;
|
||
|
|
[[nodiscard]] Vector3D derivative(double t, int order = 1) const;
|
||
|
|
[[nodiscard]] int degree() const { return static_cast<int>(cp_.size()) - 1; }
|
||
|
|
[[nodiscard]] std::pair<double, double> domain() const { return {0.0, 1.0}; }
|
||
|
|
[[nodiscard]] const std::vector<Point3D>& control_points() const { return cp_; }
|
||
|
|
|
||
|
|
/// Split at parameter t into two curves
|
||
|
|
[[nodiscard]] std::pair<BezierCurve, BezierCurve> split(double t) const;
|
||
|
|
|
||
|
|
/// Degree elevation
|
||
|
|
[[nodiscard]] BezierCurve degree_elevate(int times = 1) const;
|
||
|
|
|
||
|
|
private:
|
||
|
|
std::vector<Point3D> cp_;
|
||
|
|
};
|
||
|
|
|
||
|
|
} // namespace vde::curves
|