discr = (a1 * a1) - a;
root = Math.sqrt(discr);
final double[] distances = new double[] { root - a1 };
final Vector3[] points = new Vector3[] { ray.getDirection().multiply(distances[0], new Vector3())
.addLocal(ray.getOrigin()) };
return new IntersectionRecord(distances, points);
}
a1 = ray.getDirection().dot(diff);
if (a1 >= 0.0) {
// No intersection
return null;
}
discr = a1 * a1 - a;
if (discr < 0.0) {
return null;
} else if (discr >= MathUtils.ZERO_TOLERANCE) {
root = Math.sqrt(discr);
final double[] distances = new double[] { -a1 - root, -a1 + root };
final Vector3[] points = new Vector3[] {
ray.getDirection().multiply(distances[0], new Vector3()).addLocal(ray.getOrigin()),
ray.getDirection().multiply(distances[1], new Vector3()).addLocal(ray.getOrigin()) };
final IntersectionRecord record = new IntersectionRecord(distances, points);
return record;
}
final double[] distances = new double[] { -a1 };
final Vector3[] points = new Vector3[] { ray.getDirection().multiply(distances[0], new Vector3())
.addLocal(ray.getOrigin()) };
return new IntersectionRecord(distances, points);
}