b2KIT

Optics Ray Tracer

Simulate light rays through lenses, mirrors, and prisms. Trace reflections, refractions, and show image formation with thin lens equation.

Tested tool guide Tested browser tools Checked August 16, 2026

What Optics Ray Tracer does, with a checked example

The Optics Ray Tracer draws how idealized light rays reflect from mirrors, refract at material boundaries, and pass through lenses or prisms. It also relates focal length, object distance, image distance, and magnification for thin-lens image formation. The diagram helps distinguish a real image, where outgoing rays converge, from a virtual image located by extending diverging rays backward. A common mistake is to treat every apparent ray intersection as a real image without checking whether the physical rays actually meet there.

Worked example

A concrete input and expected output from the current implementation.

Input

Converging lens: focal length = 10 cm; object distance = 30 cm; object height = 4 cm

Expected output

Image distance = 15 cm; magnification = -0.5; image height = -2 cm; real, inverted image at half the object's height.

The thin-lens equation gives 1/di = 1/10 - 1/30 = 1/15, so di is 15 cm. Magnification is -di/do = -15/30 = -0.5, making the 4 cm image height -2 cm; the negative sign indicates inversion.

How the result is produced

1

Reflection and refraction

A traced ray follows a straight path within a uniform medium. At a mirror, its reflected angle equals its incident angle when both are measured from the surface normal. At a refracting boundary, its direction follows Snell's law, n1 sin(theta1) = n2 sin(theta2). At each prism face, refraction depends on the incidence angle and refractive indices; normal incidence or equal indices causes no bending, and total internal reflection can prevent transmission.

2

Thin-lens image formation

For an ideal thin lens, focal length f, object distance do, and image distance di are related by 1/f = 1/do + 1/di. The transverse magnification is m = -di/do, so its magnitude gives the image-to-object size ratio and its sign identifies orientation under the selected convention. The traced principal rays provide a geometric check on the calculated image position.

Good uses

  • Check where a converging or diverging lens places an image for a specified focal length and object position.
  • Compare reflected ray directions after changing a mirror's orientation or the angle of incidence.
  • Inspect how a prism's geometry and refractive indices redirect a ray at its two faces.

Limits and checks

  • The thin-lens result is a first-order idealization. It does not by itself describe lens thickness, spherical aberration, chromatic aberration, diffraction, diffraction-limited resolution, or manufacturing errors.
  • Keep focal length, object distance, image distance, and object height in compatible units. A numerically correct ratio can still be labeled incorrectly if centimeters and millimeters are mixed.
  • Optics texts use more than one sign convention. Interpret negative distances or magnifications using the tool's ray direction and displayed geometry before comparing them with values from another source.

Common questions

Why does the image appear on the same side of the lens as the object?

For a converging lens, this occurs when the object is inside the focal length. The transmitted rays leave the lens diverging, so they do not form a real image on the far side. Their backward extensions meet on the object's side, defining an upright, magnified virtual image. A screen placed there would not capture that image.

Can this replace a detailed optical design or camera simulation?

No. It is suited to geometric ray direction and ideal image formation, including reflection, refraction, and thin-lens relationships. A real optical assembly may also depend on curved-surface geometry, lens thickness, wavelength-dependent refractive index, stops, aberrations, diffraction, coatings, tolerances, and sensor properties. Those effects require a more detailed physical model.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools