[OpenJDK 2D-Dev] CubicCurve2D.solveCubic and containment/intersection bugs.
Denis Lila
dlila at redhat.com
Wed Jan 12 22:33:11 UTC 2011
Hi Jim.
> I replaced that test with
>
> if (!getBounds2D().contains(x, y, w, h)) {
> return false;
> }
>
> and that fixed both the bug and the performance of (1) without making
> (3) worse.
It turns out that that test actually slows it down a bit. It was helping
us when we were using the PathIterator, but after the introduction of
the rectCrossings method you suggested, it's faster in all cases (even (1))
to just do the general thing all the time. I've updated the webrev with this.
Eliminating the PathIterator also had a large impact on the intersect(rect)
method. Now it's about 20% faster in cases (1) and (3). (2) is still slower
but only by a factor of 2-3. Here's the webrev for it:
http://icedtea.classpath.org/~dlila/webrevs/intersectsFix/webrev/
I think the reason (2) is slow is because rectCrossingsForCubic recursively
searches through subdivisions of the input curve starting at t=0 and
in increasing t. Do you think it would be worth it to switch the order
of the recursive calls depending on the distances of the two
subdivided curves relative to the rectangle (so that perhaps we would get
to the subdivided curve that crosses one of the rectangle sides sooner)?
Regards,
Denis.
More information about the 2d-dev
mailing list