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

Function getPointAt

Engine/CoonsRegularization.cpp:72–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70
71
72NATRON_NAMESPACE_ENTER
73
74
75static Point
76getPointAt(const BezierCPs& cps,
77 double time,
78 double t)
79{
80 int ncps = (int)cps.size();
81
82 assert(ncps);
83 if (!ncps) {
84 throw std::logic_error("getPointAt()");
85 }
86 if (t < 0) {
87 t += ncps;
88 }
89 int t_i = (int)std::floor(t) % ncps;
90 int t_i_plus_1 = t_i % ncps;
91 assert(t_i >= 0 && t_i < ncps && t_i_plus_1 >= 0 && t_i_plus_1 < ncps);
92 if (t == t_i) {
93 BezierCPs::const_iterator it = cps.begin();
94 std::advance(it, t_i);
95 Point ret;
96 (*it)->getPositionAtTime(false, time, ViewIdx(0), &ret.x, &ret.y);
97
98 return ret;
99 } else if (t == t_i_plus_1) {
100 BezierCPs::const_iterator it = cps.begin();
101 std::advance(it, t_i_plus_1);
102 Point ret;
103 (*it)->getPositionAtTime(false, time, ViewIdx(0), &ret.x, &ret.y);
104
105 return ret;
106 }
107
108 BezierCPs::const_iterator it = cps.begin();
109 std::advance(it, t_i);
110 BezierCPs::const_iterator next = it;
111 ++next;
112 if ( next == cps.end() ) {
113 next = cps.begin();
114 }
115 Point p0, p1, p2, p3;
116 (*it)->getPositionAtTime(false, time, ViewIdx(0), &p0.x, &p0.y);
117 (*it)->getRightBezierPointAtTime(false, time, ViewIdx(0), &p1.x, &p1.y);
118 (*next)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &p2.x, &p2.y);
119 (*next)->getPositionAtTime(false, time, ViewIdx(0), &p3.x, &p3.y);
120 Point ret;
121 Bezier::bezierPoint(p0, p1, p2, p3, t - t_i, &ret);
122
123 return ret;
124}
125
126static Point
127getLeftPointAt(const BezierCPs& cps,

Callers 6

predirFunction · 0.85
postdirFunction · 0.85
dirVectFunction · 0.85
findIntersectionFunction · 0.85
splitAtFunction · 0.85
tensorFunction · 0.85

Calls 8

getPositionAtTimeMethod · 0.80
ViewIdxClass · 0.70
floorFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected