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

Function getLeftPointAt

Engine/CoonsRegularization.cpp:125–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125static Point
126getLeftPointAt(const BezierCPs& cps,
127 double time,
128 double t)
129{
130 int ncps = (int)cps.size();
131
132 assert(ncps);
133 if (!ncps) {
134 throw std::logic_error("getLeftPointAt()");
135 }
136 if (t < 0) {
137 t += ncps;
138 }
139 int t_i = (int)std::floor(t) % ncps;
140 int t_i_plus_1 = t_i % ncps;
141 assert(t_i >= 0 && t_i < ncps && t_i_plus_1 >= 0 && t_i_plus_1 < ncps);
142 if (t == t_i) {
143 BezierCPs::const_iterator it = cps.begin();
144 std::advance(it, t_i);
145 Point ret;
146 (*it)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &ret.x, &ret.y);
147
148 return ret;
149 } else if (t == t_i_plus_1) {
150 BezierCPs::const_iterator it = cps.begin();
151 std::advance(it, t_i_plus_1);
152 Point ret;
153 (*it)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &ret.x, &ret.y);
154
155 return ret;
156 }
157
158 BezierCPs::const_iterator it = cps.begin();
159 std::advance(it, t_i);
160 BezierCPs::const_iterator next = it;
161 ++next;
162 if ( next == cps.end() ) {
163 next = cps.begin();
164 }
165
166 t = t - t_i;
167
168 Point a, b, c, ab, bc, abc;
169 Point ret;
170 (*it)->getPositionAtTime(false, time, ViewIdx(0), &a.x, &a.y);
171 (*it)->getRightBezierPointAtTime(false, time, ViewIdx(0), &b.x, &b.y);
172 (*next)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &c.x, &c.y);
173 ab.x = (1. - t) * a.x + t * b.x;
174 ab.y = (1. - t) * a.y + t * b.y;
175
176 bc.x = (1. - t) * b.x + t * c.x;
177 bc.y = (1. - t) * b.y + t * c.y;
178
179 abc.x = (1. - t) * ab.x + t * bc.x;
180 abc.y = (1. - t) * ab.y + t * bc.y;
181 if ( (abc.x == a.x) && (abc.y == a.y) ) {
182 (*it)->getLeftBezierPointAtTime(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

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

Tested by

no test coverage detected