MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / integrate_clamp

Method integrate_clamp

Engine/Interpolation.cpp:706–860  ·  view source on GitHub ↗

integrate from time1 to time2 with clamping of the function values in [vmin,vmax]

Source from the content-addressed store, hash-verified

704
705// integrate from time1 to time2 with clamping of the function values in [vmin,vmax]
706double
707Interpolation::integrate_clamp(double tcur,
708 const double vcur, //start control point
709 const double vcurDerivRight, //being the derivative dv/dt at tcur
710 const double vnextDerivLeft, //being the derivative dv/dt at tnext
711 double tnext,
712 const double vnext, //end control point
713 double time1,
714 double time2,
715 double vmin,
716 double vmax,
717 KeyframeTypeEnum interp,
718 KeyframeTypeEnum interpNext)
719{
720 if ( vmin == -std::numeric_limits<double>::infinity() &&
721 vmax == +std::numeric_limits<double>::infinity() ) {
722 return integrate(tcur,
723 vcur, //start control point
724 vcurDerivRight, //being the derivative dv/dt at tcur
725 vnextDerivLeft, //being the derivative dv/dt at tnext
726 tnext,
727 vnext, //end control point
728 time1,
729 time2,
730 interp,
731 interpNext);
732 }
733 double P0 = vcur;
734 double P3 = vnext;
735 // Hermite coefficients P0' and P3' are the derivatives with respect to x \in [0,1]
736 double P0pr = vcurDerivRight * (tnext - tcur); // normalize for x \in [0,1]
737 double P3pl = vnextDerivLeft * (tnext - tcur); // normalize for x \in [0,1]
738
739 // in the next expression, the correct test is t2 <= tnext (not <), in order to integrate from tcur to tnext
740 assert( ( (interp == eKeyframeTypeNone) || (tcur <= time1) ) && (time1 <= time2) && ( (time2 <= tnext) || (interpNext == eKeyframeTypeNone) ) );
741 // after the last / before the first keyframe, derivatives are wrt currentTime (i.e. non-normalized)
742 if (interp == eKeyframeTypeNone) {
743 // virtual previous frame at t-1
744 P0 = P3 - P3pl;
745 P0pr = P3pl;
746 tcur = tnext - 1.;
747 } else if (interp == eKeyframeTypeConstant) {
748 P0pr = 0.;
749 P3pl = 0.;
750 P3 = P0;
751 }
752 if (interpNext == eKeyframeTypeNone) {
753 // virtual next frame at t+1
754 P3pl = P0pr;
755 P3 = P0 + P0pr;
756 tnext = tcur + 1;
757 }
758 double c0, c1, c2, c3;
759 hermiteToCubicCoeffs(P0, P0pr, P3pl, P3, &c0, &c1, &c2, &c3);
760
761 // solve cubic = vmax
762 double tmax[3];
763 int omax[3];

Callers

nothing calls this directly

Calls 10

hermiteToCubicCoeffsFunction · 0.85
maxFunction · 0.85
cubicDeriveFunction · 0.85
SolClass · 0.85
cubicIntegrateFunction · 0.85
Sol_less_than_tClass · 0.85
emptyMethod · 0.80
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected