Labs · Vectors

Laser & Mirrors (Ray Tracing)

Laser & Mirrors (Ray Tracing) simulation

Bouncing balls used the reflection formula once per collision. A light ray applies it again and again. From the laser we cast a ray, find the nearest mirror it hits (ray–segment intersection), reflect its direction with r = d − 2(d·n)n, and continue from the hit point. This is the core loop of a ray tracer.

The laser aims at your mouse. Mirrors can be dragged by their ends or their middle. Right-click adds a mirror.

Turn on "Mirrored walls" to trap the beam in a box, and raise the bounce limit.

Controls

Evolved from Reflection off Walls.