Add cubic hermite spline to geom
This commit is contained in:
parent
4cb86d9314
commit
43e95e89f3
1 changed files with 26 additions and 0 deletions
26
libs/geom/include/psemek/geom/hermite.hpp
Normal file
26
libs/geom/include/psemek/geom/hermite.hpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
namespace psemek::geom
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct cubic_hermite
|
||||
{
|
||||
T a[3];
|
||||
|
||||
cubic_hermite() = default;
|
||||
cubic_hermite(T p0, T m0, T p1, T m1)
|
||||
{
|
||||
a[0] = p0;
|
||||
a[1] = m0;
|
||||
a[2] = - 3 * p0 - 2 * m0 + 3 * p1 - m1;
|
||||
a[3] = 2 * p0 + m0 - 2 * p1 + m1;
|
||||
}
|
||||
|
||||
T operator() (T t) const
|
||||
{
|
||||
return a[0] + t * (a[1] + t * (a[2] + t * a[3]));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue