Ray Intersection
Ray–Surface Intersection
An interactive geometry primer
A ray tracer renders images by casting rays from a camera through<br>every pixel and finding where each ray hits a surface. This tool explores the<br>core mathematical question: how do you compute that intersection?
Choose a geometry — sphere , cylinder , or<br>torus — and explore it across three lenses:
📐
Theory
Derive the intersection polynomial step by step
🎮
Intuition
Aim a ray interactively and watch the roots move
💻
Code
Edit live GLSL — see the shader render in real time
Start exploring →
🔵 Ray–Sphere Intersection
🔵 Sphere<br>🔷 Cylinder<br>🍩 Torus
drag near-plane · orbit 3D · click shape to transform
Theory<br>Intuition<br>Code
§ 1 — Ray Casting
drag to orbit
drag to orbit
drag to orbit
§ 2 — 🔵 Sphere — Degree-2 Polynomial
drag to orbit
§ 3 — 🔷 Cylinder — Degree-2 Barrel + Caps
drag to orbit
§ 4 — 🍩 Torus — Degree-4 Polynomial
drag to orbit
Parameters
Radius R
2.00
Minor radius r
0.50
Ray X (near plane)
0.00
Ray Y (near plane)
0.00
Near Plane (click/drag to aim ray)
Quadratic f(t)
f(t) = 0 ⟹ ray hits sphere at parameter t