/** Planar ring * @author: Phil Gage */ class Ring extends AbstractPlane { double innerRadius, outerRadius; Ring (Point point, Vector3 normal, double innerRadius, double outerRadius, Color color) { super(point,normal,color); this.innerRadius = innerRadius; this.outerRadius = outerRadius; } double intersect (Ray ray, Intersection intersection) { double t = super.intersect (ray,intersection); if (t > 0.0) { double dist = point.distance (intersection.point); if (dist >= innerRadius && dist <= outerRadius) return t; } return 0.0; } /** Return bounding box around this object, could improve */ Extent getExtent () { return new Extent ( new Point (point.x - outerRadius, point.y - outerRadius, point.z - outerRadius), new Point (point.x + outerRadius, point.y + outerRadius, point.z + outerRadius)); } }