RFR: 8176501: Method Shape.getBounds2D() incorrectly includes Bezier control points in bounding box [v2]

Laurent Bourgès lbourges at openjdk.java.net
Fri Nov 5 11:10:11 UTC 2021


On Fri, 5 Nov 2021 10:05:41 GMT, Laurent Bourgès <lbourges at openjdk.org> wrote:

>> Jeremy has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8176501: Method Shape.getBounds2D() incorrectly includes Bezier control points in bounding box
>>   
>>   Addressing some of Laurent's code review recommendations/comments:
>>   
>>   1. use the convention t for the parametric variable x(t),y(t)
>>   2. solve the quadratic equation using QuadCurve2d.solveQuadratic() or like Helpers.quadraticRoots()
>>   3. always use braces for x = (a < b) ? ...
>>   4. always use double-precision constants in math or logical operations: (2 * x => 2.0 * x) and (coefficients[3] != 0) => (coefficients[3] != 0.0)
>>   
>>   (There are two additional recommendations not in this commit that I'll ask about shortly.)
>>   
>>   See https://github.com/openjdk/jdk/pull/6227#issuecomment-959757954
>
> src/java.desktop/share/classes/java/awt/geom/Path2D.java line 2189:
> 
>> 2187:                     double t = tExtrema[i];
>> 2188:                     if (t > 0 && t < 1) {
>> 2189:                         double x = x_coeff[0] + t * (x_coeff[1] + t * (x_coeff[2] + t * x_coeff[3]));
> 
> using 3rd order polynom is only useful for cubic curves, for quads 2nd order is enough.
> How to improve precision on (abcd) or (bcd) polynomial evaluation ?

Ideally the compensated-horner scheme should be used to guarantee optimal precision (2x slower):
paper: 
https://www-pequan.lip6.fr/~jmc/polycopies/Compensation-horner.pdf

See julia code: 
https://discourse.julialang.org/t/more-accurate-evalpoly/45932/6

-------------

PR: https://git.openjdk.java.net/jdk/pull/6227



More information about the client-libs-dev mailing list