Medusa  1.1
Coordinate Free Mehless Method implementation
mm::cad_helpers Namespace Reference

Detailed Description

Namespace for helper functions used in CAD.

Functions

template<typename scalar_t , int dim>
Vec< scalar_t, dimevaluate_b_spline (scalar_t t, int p, const Range< Vec< scalar_t, dim >> &control_points, const Range< scalar_t > &knots, int k)
 Evaluate B-spline in one point using De Boor's algorithm - \(\mathcal{O}(d p^2)\), where \(d\) is the number of dimensions. More...
 
template<typename scalar_t , int dim>
Vec< scalar_t, dimevaluate_b_spline (scalar_t t, int p, const Range< Vec< scalar_t, dim >> &control_points, const Range< scalar_t > &knots, scalar_t epsilon=1e-10)
 Overload with binary search for position of t in knots. More...
 
template<typename scalar_t , int dim>
void generate_b_spline_derivative (int p, const Range< Vec< scalar_t, dim >> &control_points, const Range< scalar_t > &knots, Range< Vec< scalar_t, dim >> &der_control_points, Range< scalar_t > &der_knots)
 Generate control points and knot vector of a B-spline that is the first derivative of the inputed B-spline. More...
 
template<typename scalar_t , int dim>
void generate_b_spline_derivative_control_points (int p, const Range< Vec< scalar_t, dim >> &control_points, const Range< scalar_t > &knots, Range< Vec< scalar_t, dim >> &der_control_points)
 Generate control points of a B-spline that is the first derivative of the inputed B-spline. More...
 
template<typename scalar_t >
void generate_b_spline_derivative_knots (const Range< scalar_t > &knots, Range< scalar_t > &der_knots)
 Generate knots of a B-spline that is the first derivative of the inputed B-spline. More...
 

Function Documentation

◆ evaluate_b_spline() [1/2]

template<typename scalar_t , int dim>
Vec< scalar_t, dim > mm::cad_helpers::evaluate_b_spline ( scalar_t  t,
int  p,
const Range< Vec< scalar_t, dim >> &  control_points,
const Range< scalar_t > &  knots,
int  k 
)

Evaluate B-spline in one point using De Boor's algorithm - \(\mathcal{O}(d p^2)\), where \(d\) is the number of dimensions.

Adds additional time complexity of \(\mathcal{O}(\log |\mathrm{knots}|)\) if k is not given.

Template Parameters
scalar_tNumeric scalar type, e.g. double or float.
dimSpace dimension.
Parameters
pB-spline order (starting from order 0).
tPoint of evaluation.
control_pointsRange of control points.
knotsKnot vector.
kPosition of t in the knot vector, such that control_points[k] <= t < control_points[k]
Returns
Vector to the point on the B-spline corresponding to parameter t.
Examples
test/domains/cad_helpers_test.cpp.

Definition at line 18 of file cad_helpers.hpp.

◆ evaluate_b_spline() [2/2]

template<typename scalar_t , int dim>
Vec< scalar_t, dim > mm::cad_helpers::evaluate_b_spline ( scalar_t  t,
int  p,
const Range< Vec< scalar_t, dim >> &  control_points,
const Range< scalar_t > &  knots,
scalar_t  epsilon = 1e-10 
)

Overload with binary search for position of t in knots.

If parameter is outside the domain by epsilon, translate it back to the edge of the domain.

Definition at line 44 of file cad_helpers.hpp.

◆ generate_b_spline_derivative()

template<typename scalar_t , int dim>
void mm::cad_helpers::generate_b_spline_derivative ( int  p,
const Range< Vec< scalar_t, dim >> &  control_points,
const Range< scalar_t > &  knots,
Range< Vec< scalar_t, dim >> &  der_control_points,
Range< scalar_t > &  der_knots 
)

Generate control points and knot vector of a B-spline that is the first derivative of the inputed B-spline.

Note that its degree is p - 1.

Template Parameters
scalar_tNumeric scalar type, e.g. double or float.
dimSpace dimension.
Parameters
pB-spline order (starting from order 0).
control_pointsRange of control points.
knotsKnot vector.
der_control_pointsRange for derivative control points.
der_knotsRange for derivative knots.
Examples
test/domains/cad_helpers_test.cpp.

Definition at line 61 of file cad_helpers.hpp.

◆ generate_b_spline_derivative_control_points()

template<typename scalar_t , int dim>
void mm::cad_helpers::generate_b_spline_derivative_control_points ( int  p,
const Range< Vec< scalar_t, dim >> &  control_points,
const Range< scalar_t > &  knots,
Range< Vec< scalar_t, dim >> &  der_control_points 
)

Generate control points of a B-spline that is the first derivative of the inputed B-spline.

Note that its degree is p - 1.

Template Parameters
scalar_tNumeric scalar type, e.g. double or float.
dimSpace dimension.
Parameters
pB-spline order (starting from order 0).
control_pointsRange of control points.
knotsKnot vector.
der_control_pointsRange for derivative control points.

Definition at line 69 of file cad_helpers.hpp.

◆ generate_b_spline_derivative_knots()

template<typename scalar_t >
void mm::cad_helpers::generate_b_spline_derivative_knots ( const Range< scalar_t > &  knots,
Range< scalar_t > &  der_knots 
)

Generate knots of a B-spline that is the first derivative of the inputed B-spline.

Note that its degree is p - 1.

Template Parameters
scalar_tNumeric scalar type, e.g. double or float.
Parameters
knotsKnot vector.
der_knotsRange for derivative knots.

Definition at line 85 of file cad_helpers.hpp.