|
Description
|
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
Given certain variables the ptLineDistSq() call is returning negative numbers.
This is causing the error that ptLineDist() is returning NaN because when it
tries to get the sqrt() of the result of ptLineDistSq() and sees it is negative
automatically return NaN. The situation is where you can 2 lines which are
extremely close to being colinear. if you get the distance from the points of
one of the lines to the other, NaN will be returned for one of them.
Code:
mport java.awt.geom.*;
public class Test {
public static void main (String[] args) {
Line2D.Double l1 = new Line2D.Double(-313.0, 241.0, -97.0,
75.0);
Line2D.Double l2 = new Line2D.Double(126.15362619253153, -
96.49769420351959, -97.0, 75.0);
System.out.println(l1.ptLineDistSq(l2.getP1()));
System.out.println(l1.ptLineDist(l2.getP1()));
System.out.println(l1.ptLineDistSq(l2.getP1()));
System.out.println(l1.ptLineDist(l2.getP2()));
}
}
(Review ID: 104357)
======================================================================
|
|
Comments
|
Submitted On 31-JUL-2002
metasim
Please fix, as the fix is very easy. I'm having to add
Math.abs() for proper operation.
Submitted On 12-AUG-2002
ghedges99
I agree with metasim, the fix is pretty easy and I'd like to see it fixed too. Line2D is very useful otherwise.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|