integrate from time1 to time2 with clamping of the function values in [vmin,vmax]
| 704 | |
| 705 | // integrate from time1 to time2 with clamping of the function values in [vmin,vmax] |
| 706 | double |
| 707 | Interpolation::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]; |
nothing calls this directly
no test coverage detected