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