If you look at the source code of Worldwind , in particular the intershere () and intersect () methods of Sphere and go through their code as input, you will see the following:
Method:
public boolean intersects(Line line)
returns true, since the distance from the center of the sphere to the line is less than the radius of the sphere, as expected.
For the method:
public final Intersection[] intersect(Line line)
it turns out that the quadratic discriminant is less than zero (i.e. there are no real roots of the quadratic equation - two different complex roots).
Link to WorldWind API here .
Specific methods:
public boolean intersects(Line line) { if (line == null) { String msg = Logging.getMessage("nullValue.LineIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } return line.distanceTo(this.center) <= this.radius; }
and
public final Intersection[] intersect(Line line) { if (line == null) { String message = Logging.getMessage("nullValue.LineIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } double a = line.getDirection().getLengthSquared3(); double b = 2 * line.selfDot(); double c = line.getOrigin().getLengthSquared3() - this.radius * this.radius; double discriminant = Sphere.discriminant(a, b, c); if (discriminant < 0) return null; double discriminantRoot = Math.sqrt(discriminant); if (discriminant == 0) { Vec4 p = line.getPointAt((-b - discriminantRoot) / (2 * a)); return new Intersection[] {new Intersection(p, true)}; } else
which uses:
private static double discriminant(double a, double b, double c) { return b * b - 4 * a * c; }
in this case, your code will not be able to execute the command:
if (discriminant < 0)
test.
It seems that I was a little slow to answer this question, and in the meantime, Chris K. indicated that this was due to the intersect () method, which expects the coordinates of the lines to be centered at the origin of the sphere, not the Earth.
As Chris K. said, this seems like a mistake and should probably be recorded with the maintainers of this source code.