30 template<
typename ParamT =
float>
33 n.pos = interpolate_cubic_hermite(n0.val, n0.tan, n1.val, n1.tan, t);
34 n.rad = interpolate_cubic_hermite(n0.val, n0.tan, n1.val, n1.tan, t);
38 template<
typename ParamT =
float>
39 std::vector<node_type> sample(
size_t num_segments)
const {
40 std::vector<node_type> points;
41 points.reserve(num_segments + 1);
42 sample_steps_transform<ParamT>(std::back_inserter(points), [
this](ParamT t) {
return evaluate(t); }, num_segments);
46 std::pair<vec_type, vec_type> approximate_axis_aligned_bounding_box()
const {
47 std::pair<vec_type, vec_type> box;
48 std::array<quadratic_bezier_tube<T>, 2> qtubes = split_to_quadratic_bezier_tubes();
50 std::pair<vec_type, vec_type> qbox = qtubes[0].axis_aligned_bounding_box();
51 box.first = qbox.first;
52 box.second = qbox.second;
54 qbox = qtubes[1].axis_aligned_bounding_box();
55 box.first = min(box.first, qbox.first);
56 box.second = max(box.second, qbox.second);
61 std::array<quadratic_bezier_tube<T>, 2> split_to_quadratic_bezier_tubes()
const {
62 std::array<vec_type, 5> ps = split_hermite_to_quadratic_beziers(n0.pos, n1.pos);
63 std::array<T, 5> rs = split_hermite_to_quadratic_beziers(n0.rad, n1.rad);
65 std::array<quadratic_bezier_tube<T>, 2> qtubes;
66 qtubes[0].n0 = { ps[0], rs[0] };
67 qtubes[0].n1 = { ps[1], rs[1] };
68 qtubes[0].n2 = { ps[2], rs[2] };
69 qtubes[1].n0 = { ps[2], rs[2] };
70 qtubes[1].n1 = { ps[3], rs[3] };
71 qtubes[1].n2 = { ps[4], rs[4] };