20 BSpline::BSpline(
const unsigned int degree,
25 const unsigned int cps_per_half,
28 _start_point(start_point),
29 _end_point(end_point),
30 _start_dir(start_direction),
31 _end_dir(end_direction),
32 _cps_per_half(cps_per_half),
33 _sharpness(sharpness),
34 _control_points(createControlPoints()),
35 _knot_vector(buildKnotVector())
42 mooseAssert((t >= 0) && (t <= 1),
"t should be in [0, 1]. t=" + std::to_string(t));
52 std::vector<libMesh::Point>
55 std::vector<libMesh::Point> cps;
62 std::vector<libMesh::Real>
65 std::vector<libMesh::Real> knot_vector(
_degree, 0);
69 mooseError(
"Number of control points must be greater than or equal to degree + 1!");
71 for (
const auto i :
make_range(num_points_left))
73 knot_vector.push_back(i);
75 "i must be less than the number of control points because of 0 indexing.");
84 knot_vector.push_back(num_points_left - 1);
90 for (
auto &
value : knot_vector)
92 value /= (num_points_left - 1);
93 mooseAssert(value <= 1.0 && value >= 0.0,
94 "knot_vector must be normalized to 1 with minimum value 0.");
103 mooseAssert(i + 1 <
_knot_vector.size(),
"Out of bounds access in knot vector");
105 "Knot vector is ill-formatted. Ensure values are increasing." +
117 mooseAssert(i + j <
_knot_vector.size(),
"Out of bounds access in knot vector");
121 return (t - ti) / (tij - ti);
129 mooseAssert(i + j + 1 <
_knot_vector.size(),
"Out of bounds access in knot vector");
133 return (tij1 - t) / (tij1 - ti1);
const libMesh::Real _sharpness
sharpness of the curve
const unsigned int _cps_per_half
number of control points per half of the spline (vertex is auto-included)
libMesh::Real secondCoeff(const libMesh::Real t, const unsigned int i, const unsigned int j) const
Submethod used in CdBBasis routine.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
const libMesh::RealVectorValue _end_dir
ending direction of spline
const libMesh::RealVectorValue _start_dir
starting direction of spline
const libMesh::Point _end_point
ending point of spline
std::vector< libMesh::Real > buildKnotVector() const
Internal method for building the knot vector given the degree and control points. ...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
libMesh::Real CdBBasis(const libMesh::Real t, const unsigned int i, const unsigned int j) const
Evaluates the the basis function for a B-Spline according to the Cox-de-Boor recursive formula...
void libmesh_ignore(const Args &...)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
std::string stringify(const T &t)
conversion to string
std::vector< Point > bSplineControlPoints(const libMesh::Point &start_point, const libMesh::Point &end_point, const libMesh::RealVectorValue &start_direction, const libMesh::RealVectorValue &end_direction, const unsigned int cps_per_half, const libMesh::Real sharpness)
Creates control points for an open uniform BSpline.
libMesh::Point getPoint(const libMesh::Real t) const
Evaluate the BSpline interpolation at given value of t.
const std::vector< libMesh::Point > _control_points
The control points.
std::vector< libMesh::Point > createControlPoints() const
Creates a vector control points from the SplineUtils set of functions.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const libMesh::Point _start_point
starting point of spline
IntRange< T > make_range(T beg, T end)
const std::vector< libMesh::Real > _knot_vector
The knot vector.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
auto index_range(const T &sizable)
libMesh::Real firstCoeff(const libMesh::Real t, const unsigned int i, const unsigned int j) const
Submethod used in CdBBasis routine.
const unsigned int _degree
The polynomial degree of the B-Spline.