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

Function predir

Engine/CoonsRegularization.cpp:270–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270static Point
271predir(const BezierCPs& cps,
272 double time,
273 double t)
274{
275 //Compute the unit vector in the direction of the bysector angle
276 Point dir;
277 Point p1, p2, p2p1, p1p2;
278
279 p2 = getPointAt(cps, time, t);
280 p2p1 = getLeftPointAt(cps, time, t);
281 p1p2 = getRightPointAt(cps, time, t - 1);
282 p1 = getPointAt(cps, time, t - 1);
283 dir.x = 3. * (p2.x - p2p1.x);
284 dir.y = 3. * (p2.y - p2p1.y);
285
286 double epsilon = norm(p1, p1p2, p2p1, p2);
287 double predirNormSquared = dir.x * dir.x + dir.y * dir.y;
288 if (predirNormSquared > epsilon) {
289 double normDir = std::sqrt(predirNormSquared);
290 assert(normDir != 0);
291 Point ret;
292 ret.x = dir.x / normDir;
293 ret.y = dir.y / normDir;
294
295 return ret;
296 }
297 dir.x = 2. * p2p1.x - p1p2.x - p2.x;
298 dir.y = 2. * p2p1.y - p1p2.y - p2.y;
299 predirNormSquared = dir.x * dir.x + dir.y * dir.y;
300
301 if (predirNormSquared > epsilon) {
302 double normDir = std::sqrt(predirNormSquared);
303 assert(normDir != 0);
304 Point ret;
305 ret.x = dir.x / normDir;
306 ret.y = dir.y / normDir;
307
308 return ret;
309 }
310 dir.x = p2.x - p1.x + 3. * (p1p2.x - p2p1.x);
311 dir.y = p2.y - p1.y + 3. * (p1p2.y - p2p1.y);
312 predirNormSquared = dir.x * dir.x + dir.y * dir.y;
313 double normDir = std::sqrt(predirNormSquared);
314 assert(normDir != 0);
315 Point ret;
316 ret.x = dir.x / normDir;
317 ret.y = dir.y / normDir;
318
319 return ret;
320}
321
322static Point
323postdir(const BezierCPs& cps,

Callers 1

dirVectFunction · 0.85

Calls 5

getPointAtFunction · 0.85
getLeftPointAtFunction · 0.85
getRightPointAtFunction · 0.85
normFunction · 0.85
sqrtFunction · 0.50

Tested by

no test coverage detected