if (capped) {
double t = Plane3.XZ.intersect(ray);
if (recorder.interval().contains(t)) {
Point3 p = ray.pointAt(t);
if (p.distanceToOrigin() <= radius) {
Intersection x = super.newIntersection(ray, t, ray.origin().y() < 0.0, CONE_SURFACE_BASE)
.setLocation(p);
recorder.record(x);
}
}
}
Point3 org = ray.origin();
Vector3 dir = ray.direction();
double x0 = org.x() / radius;
double y0 = org.y() / height - 1.0;
double z0 = org.z() / radius;
double x1 = dir.x() / radius;
double y1 = dir.y() / height;
double z1 = dir.z() / radius;
Polynomial f = new Polynomial(
x0 * x0 - y0 * y0 + z0 * z0,
2.0 * (x0 * x1 - y0 * y1 + z0 * z1),
x1 * x1 - y1 * y1 + z1 * z1);
double[] t = f.roots();
if (t.length == 2) {
for (int i = 0; i < 2; i++) {
if (recorder.interval().contains(t[i])) {
Point3 p = ray.pointAt(t[i]);
if (0.0 <= p.y() && p.y() <= height) {
Intersection x = super.newIntersection(ray, t[i], i == 0, CONE_SURFACE_BODY)
.setLocation(p);
recorder.record(x);
}
}