Hi Everybody,
Anybody else out there doing hit
detection on CubicCurves?
I'm developing a 2D CAD application
which uses Bezier Splines. I'm using CubicCurve2D.Double, and I'm performing hit
detection on the segments using a combination of .intersects(Rectangle2D) and
.contains(Rectangle2D). The Rectangle2D in this case is a region of x pixels
square at the mouse pointer, mapped to their appropriate world coordinates. This
works well, and is speedy enough. However, there occurs an intermittent problem
in each of these calls which will cause the application to hang. I've managed to
narrow it down a bit - It occurs in
[intersects()|contains()]->solveCubic()->fixRoots()->findZero().
The following code will highlight the
problem: It seems 't' is oscillating about
1, (in this case, from value t = 0.9999999999999998 to t =
1.0000000000000002)
This happens with
other curves too, this code is just a sample case. Could somebody tell me if the
Solaris release is equally afflicted? Anybody got any suggestions for a
work-around?
import
java.awt.geom.CubicCurve2D;
class Looper
{
public Looper() {
public Looper() {
CubicCurve2D curve
= new
CubicCurve2D.Double(
83.0, 101.0,
-5.3919918959078075, 94.23530547506019,
71.0, 39.0,
122.0, 44.0
);
83.0, 101.0,
-5.3919918959078075, 94.23530547506019,
71.0, 39.0,
122.0, 44.0
);
System.out.println("Checking contains()
>>>");
curve.contains(71.0, 44.0);
System.out.println("Check complete!!");
}
curve.contains(71.0, 44.0);
System.out.println("Check complete!!");
}
public static
void main(String args[]) {
Looper looper = new Looper();
}
}
Looper looper = new Looper();
}
}
Cheers,
Jason
