MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ cubic_hermite()

Eigen::VectorXd MayaFlux::Kinesis::cubic_hermite ( const Eigen::MatrixXd &  endpoints,
const Eigen::MatrixXd &  tangents,
double  t 
)

Cubic Hermite interpolation using Eigen matrices.

Parameters
endpoints2xN matrix (start, end)
tangents2xN matrix (tangent_start, tangent_end)
tParameter in [0,1]
Returns
Interpolated point as Nx1 vector

Definition at line 218 of file MotionCurves.cpp.

222{
223 if (endpoints.cols() != 2 || tangents.cols() != 2) {
224 error<std::invalid_argument>(
225 Journal::Component::Kinesis,
226 Journal::Context::Runtime,
227 std::source_location::current(),
228 "Cubic Hermite interpolation requires 2 endpoints and 2 tangents, but got {} endpoints and {} tangents",
229 endpoints.cols(), tangents.cols());
230 }
231
232 double t2 = t * t;
233 double t3 = t2 * t;
234
235 double h00 = 2.0 * t3 - 3.0 * t2 + 1.0;
236 double h10 = t3 - 2.0 * t2 + t;
237 double h01 = -2.0 * t3 + 3.0 * t2;
238 double h11 = t3 - t2;
239
240 return h00 * endpoints.col(0) + h10 * tangents.col(0) + h01 * endpoints.col(1) + h11 * tangents.col(1);
241}

References MayaFlux::Journal::Kinesis, and MayaFlux::Journal::Runtime.

Referenced by interpolate().

+ Here is the caller graph for this function: