PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabs
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry

More from Optics & Light

Other simulators in this category — or see all 44.

View category →
NewSchool

Moiré (Line Gratings)

Two translucent rulings: spacing, tilt, shift — spatial beats and envelopes.

Launch Simulator
NewSchool

Fiber: Numerical Aperture

NA from n_core, n_clad; acceptance angle and bend loss cue.

Launch Simulator
NewSchool

Fiber Bend & TIR Loss

Curved core: outer-wall incidence vs θ_c; tight R leaks (meridional sketch).

Launch Simulator
NewUniversity / research

Evanescent Wave (TIR)

Beyond θ_c: penetration depth scale in the rarer medium vs λ.

Launch Simulator
NewSchool

Retina & Diffraction

Order-of-magnitude θ ~ λ/D and cone spacing scale.

Launch Simulator
NewSchool

Pinhole Camera

Camera obscura: similar triangles, image size h_i = h_o · v/u.

Launch Simulator
PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Optics & Light/CD / Grating Rainbow

CD / Grating Rainbow

Diffraction gratings, like the grooves on a CD or a precisely ruled surface, separate white light into its constituent colors. This simulator visualizes the core phenomenon: light of different wavelengths is diffracted into specific angles, creating the characteristic rainbow pattern. The central physics is governed by the grating equation, mλ = d(sin θ_m - sin θ_i). Here, 'm' is the diffraction order (an integer), 'λ' is the wavelength of light, 'd' is the distance between adjacent grating lines (the groove spacing), 'θ_i' is the angle of incidence, and 'θ_m' is the angle of the m-th order diffracted beam. The model simplifies real-world optics by treating the grating as a perfect, one-dimensional, scalar grating, ignoring polarization effects and the finite size of the light source. It also visualizes multiple spectral orders as colored fans, showing how different wavelengths (colors) fan out at different angles. By adjusting the lines per millimeter (which inversely sets 'd') and the incidence angle, students directly explore how these parameters control the angular spread and separation of the spectrum. Key learnings include the relationship between groove density and spectral dispersion, the symmetric or asymmetric pattern created by oblique incidence, and the concept of overlapping orders.

Who it's for: High school and introductory undergraduate physics students studying wave optics, particularly the principles of diffraction and dispersion.

Key terms

  • Diffraction Grating
  • Grating Equation
  • Diffraction Order
  • Wavelength
  • Dispersion
  • Incidence Angle
  • Lines per Millimeter
  • Spectrum

Grating

1250
35°
3

Pedagogical fan of rays: spacing d = 1/(lines per mm) in mm; not a full blazed-grating efficiency model.

Measured values

d (groove)0.8000 µm

How it works

White light hits a mirrored groove train: each wavelength peels off at its own angle — the same idea as a spectroscope slit on a disc.

Frequently asked questions

Why does a grating with more lines per millimeter spread the colors out more?
More lines per millimeter means a smaller distance 'd' between grooves. According to the grating equation, for a fixed wavelength and order, a smaller 'd' requires a larger sin θ, meaning the diffraction angle θ must increase. This results in greater angular separation between different wavelengths, enhancing the dispersion and making the rainbow appear wider.
What are the colored fans or arcs I see on either side of the center?
These represent different diffraction orders (m = ±1, ±2, etc.). The central bright spot (or white fan at normal incidence) is the zeroth order (m=0), where all wavelengths combine to form undeviated light. Each subsequent order on either side contains a full spectrum, but higher orders are more spread out. The simulator shows these orders as overlapping colored fans for visualization.
How is this different from a prism making a rainbow?
Both separate white light, but their mechanisms differ fundamentally. A prism relies on refraction, where light bends due to a change in speed in a material, with shorter wavelengths (blue) bending more. A grating uses diffraction and interference from many slits; the angle depends directly on wavelength and slit spacing. Gratings typically produce sharper, more widely separated spectra and multiple copies (orders).
Why does tilting the grating (changing incidence) make the pattern asymmetric?
When light hits at an angle (θ_i ≠ 0), the path difference between rays from adjacent grooves changes asymmetrically. In the grating equation, sin θ_i is subtracted on one side. This makes the diffraction angle θ_m different for the +m and -m orders, compressing the spectrum on one side and stretching it on the other, breaking the symmetry seen at normal incidence.