Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float SolveBezierCurve(float x1, float y1, float x2, float y2, float t)
- {
- float a = GMin(0.0f, GMin(y1, GMin(y2, 1.0f)));
- float b = GMax(0.0f, GMax(y1, GMax(y2, 1.0f)));
- // Starts the looping.
- const int maxIterations = 1000;
- int iterations = 0;
- while (iterations <= maxIterations)
- {
- float c = (a + b) / 2.0f;
- if (abs(BezierFunctionCall(x1, x2, c, t) - 0.0f) < FLT_EPSILON || (b - a) / 2.0f < 0.001f) return c;
- iterations++;
- if (sign(BezierFunctionCall(x1, x2, c, t)) == sign(BezierFunctionCall(x1, x2, a, t))) a = c;
- else b = c;
- }
- return 0.0f;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement