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

◆ cubic_hermite()

MAYAFLUX_API 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 341 of file MotionCurves.cpp.

345{
346 if (endpoints.cols() != 2 || tangents.cols() != 2) {
347 error<std::invalid_argument>(
348 Journal::Component::Kinesis,
349 Journal::Context::Runtime,
350 std::source_location::current(),
351 "Cubic Hermite interpolation requires 2 endpoints and 2 tangents, but got {} endpoints and {} tangents",
352 endpoints.cols(), tangents.cols());
353 }
354
355 double t2 = t * t;
356 double t3 = t2 * t;
357
358 double h00 = 2.0 * t3 - 3.0 * t2 + 1.0;
359 double h10 = t3 - 2.0 * t2 + t;
360 double h01 = -2.0 * t3 + 3.0 * t2;
361 double h11 = t3 - t2;
362
363 return h00 * endpoints.col(0) + h10 * tangents.col(0) + h01 * endpoints.col(1) + h11 * tangents.col(1);
364}

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

Referenced by interpolate().

+ Here is the caller graph for this function: