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

Function getPointAt

Engine/CoonsRegularization.cpp:71–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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

Tested by

no test coverage detected