[OpenJDK 2D-Dev] CubicCurve2D.solveCubic and containment/intersection bugs.

Jim Graham james.graham at oracle.com
Thu Jan 27 19:19:49 UTC 2011


On 1/27/2011 6:16 AM, Denis Lila wrote:
>> Line 1161 - "num>  1"?
>
> Done.
> Can the compiler take care of this sort of thing? It should be able to
> figure out that the only possible values for num are {0, 1, 2, 3}.

I don't think it can without a tremendous amount of code scanning.  I 
don't think the compiler group would find it worth the effort, or that 
the translation of "num==2||num==3" can be approximated with "num>1" is 
easy for a computer to come up with...

>> Line 1271 - if the vals are opposite sign, is it worth bisectRoot'ing?
>
> Do you mean if badRootVal and fx are of opposite signs?
> I don't think bisectRoot would be good here. It is far slower than what we
> have, and in terms of accuracy we wouldn't really gain much because in
> the two root case the polynomial is very flat at the second root and
> evaluating solveEqn(eqn, 3, x), where x is all the doubles near the second
> root, shows that the computed values change sign many, many times. BisectRoot
> finds a root in an interval where the function is known to be monotonic and
> has opposite signs at the end points. Monotonicity doesn't hold in this case,
> so all bisectRoot would do is look for values in the interval where
> solveEqn returns exactly 0, but that's not really any better than a random
> sampling of the interval in the 2 root case.

Sounds good.

> Is it good to go now?

1163 - I'd slice the trailing ") {" off the end of the line since that 
could confuse some autoformatters that aren't good at parsing through 
comments (gnuemacs sometimes reacts to unbalanced entities in comments).

1387 - very formal!  I would have just put "[dlila]" where you put 
"[1]".  When I first saw "I am Denis Lila" I chuckled because it came 
across like "I am Ironman" or "I am Legend"... ;-)

It's good to go, I don't think I need to see another webrev if you go 
with the previous 2 suggestions...

			...jim



More information about the 2d-dev mailing list