The disk is an interesting quadric since it has a particularly straightforward intersection routine that avoids solving the quadratic equation. In pbrt, a Disk is a circular disk of radius at height along the axis. It is implemented in the files shapes/disk.h and shapes/disk.cpp.
In order to describe partial disks, the user may specify a maximum value beyond which the disk is cut off (Figure 3.8). The disk can also be generalized to an annulus by specifying an inner radius, . In parametric form, it is described by
Figure 3.9 is a rendered image of two disks.
The bounding method is quite straightforward; it computes a bounding box centered at the height of the disk along , with extent of radius in both the and directions.
3.4.2 Intersection Tests
Intersecting a ray with a disk is also easy. The intersection of the ray with the plane that the disk lies in is found and the intersection point is checked to see if it lies inside the disk.
The first step is to compute the parametric value where the ray intersects the plane that the disk lies in. We want to find such that the component of the ray’s position is equal to the height of the disk. Thus,
The intersection method computes a value and checks to see if it is inside the legal range of values . If not, the routine can return false.
If the ray is parallel to the disk’s plane (i.e., the component of its direction is zero), no intersection is reported. The case where a ray is both parallel to the disk’s plane and lies within the plane is somewhat ambiguous, but it’s most reasonable to define intersecting a disk edge-on as “no intersection.” This case must be handled explicitly so that NaN floating-point values aren’t generated by the following code.
Now the intersection method can compute the point pHit where the ray intersects the plane. Once the plane intersection is known, false is returned if the distance from the hit to the center of the disk is more than Disk::radius or less than Disk::innerRadius. This process can be optimized by actually computing the squared distance to the center, taking advantage of the fact that the and coordinates of the center point are zero, and the coordinate of pHit is equal to height.
If the distance check passes, a final test makes sure that the value of the hit point is between zero and , specified by the caller. Inverting the disk’s parameterization gives the same expression for as the other quadric shapes.
If we’ve gotten this far, there is an intersection with the disk. The parameter u is scaled to reflect the partial disk specified by , and v is computed by inverting the parametric equation. The equations for the partial derivatives at the hit point can be derived with a process similar to that used for the previous quadrics. Because the normal of a disk is the same everywhere, the partial derivatives and are both trivially .
3.4.3 Surface Area
Disks have trivially computed surface area, since they’re just portions of an annulus: