64ad721ed7
- CMake: INTERFACE 库修复、vde_compile_options 顺序修复 - 命名空间: 所有模块添加 using 声明 - 类型补全: Ray3Dd、Point4D - 头文件: tolerance 泛型化、std::optional include - 警告: 放宽 -Wconversion/-Wsign-conversion - 构建结果: 0 errors, 22/25 tests passed
34 lines
1002 B
C++
34 lines
1002 B
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;
|
|
|
|
private:
|
|
std::vector<Point3D> cp_;
|
|
std::vector<double> knots_;
|
|
int degree_;
|
|
};
|
|
|
|
} // namespace vde::curves
|