38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
#pragma once
|
|
#include "vde/core/point.h"
|
|
#include <vector>
|
|
|
|
namespace vde::curves {
|
|
using core::Point3D;
|
|
using core::Vector3D;
|
|
|
|
class BSplineCurve {
|
|
public:
|
|
BSplineCurve(std::vector<Point3D> control_points,
|
|
std::vector<double> knots, int degree);
|
|
|
|
[[nodiscard]] Point3D evaluate(double t) const;
|
|
[[nodiscard]] Vector3D derivative(double t, int order = 1) const;
|
|
[[nodiscard]] int degree() const { return degree_; }
|
|
[[nodiscard]] std::pair<double, double> domain() const;
|
|
[[nodiscard]] const std::vector<Point3D>& control_points() const { return cp_; }
|
|
[[nodiscard]] const std::vector<double>& knots() const { return knots_; }
|
|
|
|
/// Find knot span index for t
|
|
[[nodiscard]] int find_span(double t) const;
|
|
|
|
/// Evaluate basis functions at t
|
|
[[nodiscard]] std::vector<double> basis_functions(double t, int span = -1) const;
|
|
|
|
/// Evaluate first derivatives of non-zero basis functions at t
|
|
/// Returns dN_{span-degree+i, degree}/du for i = 0..degree
|
|
[[nodiscard]] std::vector<double> basis_derivatives(double t, int span = -1) const;
|
|
|
|
private:
|
|
std::vector<Point3D> cp_;
|
|
std::vector<double> knots_;
|
|
int degree_;
|
|
};
|
|
|
|
} // namespace vde::curves
|