Skip to content
Part IA Michaelmas Term

Ray Equation

Ray Representation

A ray is represented parametrically as: P(s)=O+sD,s0\mathbf{P}(s) = \mathbf{O} + s\mathbf{D}, \quad s \geq 0

where:

  • O\mathbf{O} is the ray origin (starting point)
  • D\mathbf{D} is the direction vector (typically normalised)
  • ss is the parameter measuring distance along the ray

Properties

  • For s=0s = 0: P(0)=O\mathbf{P}(0) = \mathbf{O} (origin)
  • For s>0s > 0: Points along the ray in direction D\mathbf{D}
  • Negative ss values are invalid (behind the origin)

Constructing Rays from Camera

For a pixel at screen coordinates (x,y)(x, y):

  1. Compute the world-space position of the pixel on the image plane
  2. Direction: D=PpixelOcameraPpixelOcamera\mathbf{D} = \frac{\mathbf{P}_{\text{pixel}} - \mathbf{O}_{\text{camera}}}{|\mathbf{P}_{\text{pixel}} - \mathbf{O}_{\text{camera}}|}

Why Parametric?

The parametric form is ideal for intersection testing:

  • Substitute P(s)\mathbf{P}(s) into the surface equation
  • Solve for ss (the distance to intersection)
  • IF s0s \geq 0, the intersection is in front of the ray origin

Summary

  • A ray is defined by origin O\mathbf{O} and direction D\mathbf{D}
  • The parameter ss gives distance along the ray
  • Parametric form enables algebraic intersection calculations