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

Function coonsPatch

Engine/CoonsRegularization.cpp:734–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

732}
733
734static void
735coonsPatch(const BezierCPs& p,
736 double time,
737 Point ret[4][4])
738{
739 assert(p.size() >= 3);
740 Point internal[4];
741 BezierCPs::const_iterator cur = p.begin();
742 BezierCPs::const_iterator prev = p.end();
743 --prev;
744 BezierCPs::const_iterator next = cur;
745 ++next;
746 BezierCPs::const_iterator nextNext = next;
747 ++nextNext;
748
749 for (int j = 0; j < 4; ++j,
750 ++prev, ++cur, ++next, ++nextNext) {
751 if ( cur == p.end() ) {
752 cur = p.begin();
753 }
754 if ( prev == p.end() ) {
755 prev = p.begin();
756 }
757 if ( next == p.end() ) {
758 next = p.begin();
759 }
760 if ( nextNext == p.end() ) {
761 nextNext = p.begin();
762 }
763
764 Point p1;
765 (*cur)->getPositionAtTime(false, time, ViewIdx(0), &p1.x, &p1.y);
766
767 Point p1left;
768 (*cur)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &p1left.x, &p1left.y);
769
770 Point p1right;
771 (*cur)->getRightBezierPointAtTime(false, time, ViewIdx(0), &p1right.x, &p1right.y);
772
773 Point p0;
774 (*prev)->getPositionAtTime(false, time, ViewIdx(0), &p0.x, &p0.y);
775
776 Point p2;
777 (*next)->getPositionAtTime(false, time, ViewIdx(0), &p2.x, &p2.y);
778
779 Point p0left;
780 (*prev)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &p0left.x, &p0left.y);
781
782 Point p2right;
783 (*next)->getRightBezierPointAtTime(false, time, ViewIdx(0), &p2right.x, &p2right.y);
784
785 Point p3;
786 (*nextNext)->getPositionAtTime(false, time, ViewIdx(0), &p3.x, &p3.y);
787
788 internal[j].x = 1. / 9. * (-4. * p1.x + 6. * (p1left.x + p1right.x) - 2. * (p0.x + p2.x) + 3. * (p0left.x + p2right.x) - p3.x);
789 internal[j].y = 1. / 9. * (-4. * p1.y + 6. * (p1left.y + p1right.y) - 2. * (p0.y + p2.y) + 3. * (p0left.y + p2right.y) - p3.y);
790 }
791

Callers 1

regularizeMethod · 0.85

Calls 8

tensorFunction · 0.85
getPositionAtTimeMethod · 0.80
ViewIdxClass · 0.70
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected