cgv
Loading...
Searching...
No Matches
hermite.h
1#pragma once
2
3#include "fvec.h"
4#include "fmat.h"
5#include "interpolate.h"
6#include "parametric_curve.h"
7
8namespace cgv {
9namespace math {
10
11template<typename T>
13 T val; // the point value (e.g. position)
14 T tan; // the tangent
15};
16
17template<typename PointT>
18struct cubic_hermite_curve : public parametric_curve<cubic_hermite_curve<PointT>> {
23
25 cubic_hermite_curve(const PointT& p0, const PointT& m0, const PointT& p1, const PointT& m1) : n0{ p1, m0 }, n1{ p1, m1 } {}
26 cubic_hermite_curve(const hermite_node<PointT>& n0, const hermite_node<PointT>& n1) : n0(n0), n1(n1) {}
27
28 template<typename ParamT = float>
29 PointT evaluate(ParamT t) const {
30 return interpolate_cubic_hermite(n0.val, n0.tan, n1.val, n1.tan, t);
31 }
32};
33
34} // namespace math
35} // namespace cgv
CRTP base class for parametric curves.
the cgv namespace
Definition print.h:11
hermite_node< PointT > n0
the start node
Definition hermite.h:20
hermite_node< PointT > n1
the end node
Definition hermite.h:22