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

Function getRightPointAt

Engine/CoonsRegularization.cpp:191–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189} // getLeftPointAt
190
191static Point
192getRightPointAt(const BezierCPs& cps,
193 double time,
194 double t)
195{
196 int ncps = cps.size();
197
198 assert(ncps);
199 if (!ncps) {
200 throw std::logic_error("getRightPointAt()");
201 }
202 if (t < 0) {
203 t += ncps;
204 }
205 int t_i = (int)std::floor(t) % ncps;
206 int t_i_plus_1 = t_i % ncps;
207 assert(t_i >= 0 && t_i < ncps && t_i_plus_1 >= 0 && t_i_plus_1 < ncps);
208 if (t == t_i) {
209 BezierCPs::const_iterator it = cps.begin();
210 std::advance(it, t_i);
211 Point ret;
212 (*it)->getRightBezierPointAtTime(false, time, ViewIdx(0), &ret.x, &ret.y);
213
214 return ret;
215 } else if (t == t_i_plus_1) {
216 BezierCPs::const_iterator it = cps.begin();
217 std::advance(it, t_i_plus_1);
218 Point ret;
219 (*it)->getRightBezierPointAtTime(false, time, ViewIdx(0), &ret.x, &ret.y);
220
221 return ret;
222 }
223
224 BezierCPs::const_iterator it = cps.begin();
225 std::advance(it, t_i);
226 BezierCPs::const_iterator next = it;
227 ++next;
228 if ( next == cps.end() ) {
229 next = cps.begin();
230 }
231
232 t = t - t_i;
233
234 Point a, b, c, ab, bc, abc;
235 Point ret;
236 (*it)->getRightBezierPointAtTime(false, time, ViewIdx(0), &a.x, &a.y);
237 (*next)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &b.x, &b.y);
238 (*next)->getPositionAtTime(false, time, ViewIdx(0), &c.x, &c.y);
239 ab.x = (1. - t) * a.x + t * b.x;
240 ab.y = (1. - t) * a.y + t * b.y;
241
242 bc.x = (1. - t) * b.x + t * c.x;
243 bc.y = (1. - t) * b.y + t * c.y;
244
245 abc.x = (1. - t) * ab.x + t * bc.x;
246 abc.y = (1. - t) * ab.y + t * bc.y;
247 if ( (abc.x == c.x) && (abc.y == c.y) ) {
248 (*next)->getRightBezierPointAtTime(false, time, ViewIdx(0), &ret.x, &ret.y);

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