06 - A ray that bounces

Drag the ring to reposition the source. The cross marks the aim and follows the pointer.

cast(originX, originY, directionX, directionY, maxDistance, options)
Cast, reflect the direction about normalX and normalY, cast again from where the ray stopped, and take what it traveled out of the budget.
The loop ends when the budget runs out or the reflections do.

This is the first page that uses a normal rather than drawing it. Reflecting is one line: subtract twice the part of the direction that points into the surface.