MCPcopy
hub / github.com/animatedjs/animated / binarySubdivide

Function binarySubdivide

src/bezier.js:29–41  ·  view source on GitHub ↗
(aX, aA, aB, mX1, mX2)

Source from the content-addressed store, hash-verified

27 function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); }
28
29 function binarySubdivide (aX, aA, aB, mX1, mX2) {
30 var currentX, currentT, i = 0;
31 do {
32 currentT = aA + (aB - aA) / 2.0;
33 currentX = calcBezier(currentT, mX1, mX2) - aX;
34 if (currentX > 0.0) {
35 aB = currentT;
36 } else {
37 aA = currentT;
38 }
39 } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
40 return currentT;
41 }
42
43 function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
44 for (var i = 0; i < NEWTON_ITERATIONS; ++i) {

Callers 1

getTForXFunction · 0.85

Calls 1

calcBezierFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…