# E - Raytracing Reference

## Efficiency

The efficiency of a computer program is an indication of how far it maximizes speed and minimizes memory usage. In a raytracer, speed is achieved through well-designed program structure and elimination of needless or repetitive intersection testing, as well as by making certain approximations. An example of an efficiency scheme is the Bounding Volume Hierarchy (BVH). Memory usage is reduced largely through good design, rapid freeing of unused space, and efficient data structures.

## Ellipsoid

An ellipsoid is the 3-D equivalent of an ellipse. Just as an ellipse looks like a squashed circle, an ellipsoid looks like a squashed sphere. An ellipsoid is a quadric: its equation in the standard form when centered at the origin is The quantities a, b and c may be thought of as "radii" of the ellipsoid in different directions. The ellipsoid is bounded by the box having the points (-a, -b, -c) and (a, b, c) at opposite ends of a diagonal. A sphere is a special case of an ellipsoid with a = b = c = radius.

## Epsilon

Raytracers have to deal with the finite precision of computer calculations. Let us consider a situation in which a ray hits an object and is reflected. We have to find the nearest object intersected by the reflected ray. Now it is perfectly possible that this ray goes and hits another part of the same object. Therefore this object must also be tested. Since the origin of the reflected ray lies on the surface of the object, there will be an intersection point at zero distance. If computers had infinite precision, we would indeed get 0 as one of the distances and we could safely ignore it. But this is not the case. There will almost always be a small error in the distance. Thus the position of the point of reflection will be slightly different from the ideal value, and the distance that should be 0 will more likely be some small quantity like 0.000001 (even if the point of reflection is ideally positioned). Yet we know that this result must be omitted. To handle this case, raytracers use a small value known as an "epsilon". All intersection distances less than the epsilon value are ignored. A good raytracer tries to make its epsilon setting as small as possible by reducing chances of numerical error, so that small details near the surface are not missed out.

## Equation

In simple terms, an equation states that two quantities are equal. For instance,

2 + 2 = 4

is an equation. Equations are useful when they contain variable terms such as x, y, z. For example, a quadratic (2nd degree) equation may be written as

ax^2 + bx + c = 0

where a, b and c are constants. Finding values of the variable terms such that the relation is satisfied is called "solving the equation": the values thus found are called "roots" of the equation. An equation may represent a locus, i.e. a path or a shape. For instance, the points (x, y) which satisfy the equation

x^2 + y^2 = R^2

lie on a circle in the 2-dimensional Cartesian coordinate system.

Equations provide a convenient and compact way of storing object shapes. Also, ray-intersection calculations are easiest when a shape is specified as the set of points satisfying an equation of the coordinate variables. The usual way of solving for the intersection distance s of a ray P + s * U (P is ray origin, U is direction vector) with an object F(x, y, z) = 0 is to write the equation of the object as

F(Px + s * Ux, Py + s * Uy, Pz + s * Uz) = 0

(where Px, Py, Pz and Ux, Uy, Uz are the components of P and U along the xyz coordinate axes) and then solve for s.