mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-06 15:30:18 +01:00
[_cairo_spline_bound] Simplify condition
This commit is contained in:
parent
3bf1b7d574
commit
0b59e29004
1 changed files with 9 additions and 5 deletions
|
|
@ -277,18 +277,22 @@ _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
|
|||
double b2 = b * b; \
|
||||
double delta = b2 - a * c; \
|
||||
if (delta > 0) { \
|
||||
double a2_b2 = a * a + b2; \
|
||||
cairo_bool_t feasible; \
|
||||
double _2ab = 2 * a * b; \
|
||||
double _b_a = - b / a; \
|
||||
/* We are only interested in solutions t that satisfy 0<t<1 \
|
||||
* here. We do some checks to avoid sqrt if the solutions \
|
||||
* are not in that range. The checks can be derived from: \
|
||||
* \
|
||||
* 0 < (-b±√delta)/a < 1 \
|
||||
*/ \
|
||||
if ((_2ab >= 0 && delta > b2 && delta < a2_b2 - _2ab) || \
|
||||
(_2ab < 0 && ((_b_a>=1 && (delta < b2 && delta > a2_b2 + _2ab)) || \
|
||||
(_b_a< 1 && (delta < b2 || delta < a2_b2 + _2ab))))) { \
|
||||
if (_2ab >= 0) \
|
||||
feasible = delta > b2 && delta < a*a + b2 - _2ab; \
|
||||
else if (-b / a >= 1) \
|
||||
feasible = delta < b2 && delta > a*a + b2 + _2ab; \
|
||||
else \
|
||||
feasible = delta < b2 || delta < a*a + b2 + _2ab; \
|
||||
\
|
||||
if (unlikely (feasible)) { \
|
||||
double sqrt_delta = sqrt (delta); \
|
||||
ADD ((-b - sqrt_delta) / a); \
|
||||
ADD ((-b + sqrt_delta) / a); \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue