Original interactive / Reflection geometry

Aim once.
See five rebounds.

Drag in the room, focus it and use the arrow keys, or move the angle control. Zero degrees points right and angles increase downwards on screen. The route stops at its fifth wall contact; hitting a corner counts as one contact and reverses both components.

325°5 of 5 possible rebounds shown
START

Aim 325°. Wall sequence: top, right, bottom, left, top.

The equal angles are measured from a normal.

The law of reflection says that the angle of reflection equals the angle of incidence. OpenStax’s university physics textbook adds the essential detail: both angles are measured relative to the perpendicular at the contact point, called the normal. They are not ordinarily measured from the wall itself.

Our room applies that ideal law to a moving point. There is no friction, spin, ball radius or loss of speed. Those omissions are deliberate. The point preserves its direction between contacts and changes only at a wall, allowing the geometry to be inspected without pretending to simulate a physical game in full.

Set the aim to 45 degrees. On this screen, that direction travels equally right and down. After the bottom contact, it travels equally right and up. The incoming and outgoing segments make equal angles with the vertical normal. A vertical wall similarly reverses the horizontal component while leaving the vertical component unchanged.

Turn the law into two simple component rules.

Represent a direction as a pair (dx, dy). A contact with the left or right wall changes it to (−dx, dy). A contact with the top or bottom changes it to (dx, −dy). Because only the component perpendicular to the wall reverses, the component parallel to the wall is preserved. That is the vector form behind the equal-angle picture.

To find the next contact, calculate the positive travel distance to every wall lying ahead. The smallest distance wins. For example, if the right wall is 200 units away horizontally and dx is 0.5, its candidate distance along the unit direction is 400. Compare that with the vertical candidate rather than comparing raw horizontal and vertical gaps.

The model then moves to that point, reverses the appropriate component and repeats. It stops after five contacts so that every direction has a bounded, readable result. At the default 325 degrees, the sequence is top, right, bottom, left, top. Changing the angle by one degree can change a later wall even when the first contact stays on the same side.

Edges and corners need explicit rules.

Zero degrees points horizontally right; 90 points down; 180 points left; 270 points up. At these exact directions, two candidate walls have infinite or irrelevant travel distances rather than becoming accidental contacts. The implementation considers only walls in the direction of travel and requires a strictly positive distance.

A corner is different because the nearest vertical and horizontal distances are equal. The contact is recorded once with both walls named, then both components reverse. The path therefore goes back the way it came. Treating the corner as two successive contacts would attempt a second calculation at the same point and could produce a zero-length segment.

The independent tests exercise these angle boundaries, exact corners, the five-contact limit and component reflection. You can explore them with the buttons or slider. For keyboard aiming, focus the room: left and right adjust by one degree, while up and down adjust by five. Dragging uses the same angle state, so no input method reveals a different model.

Unfold the room instead of bending the ray.

A mirror-room construction reverses the way the scene is described. At a wall, keep the direction straight and reflect the next copy of the room across that wall instead. The first segment now continues into a neighbouring copy. At the next contact, reflect again. Several rebound segments become one straight route through a sequence of rooms.

Enable Show the mirror-room construction. The central highlighted room is the original. The straight mint line joins the unfolded versions of the same contact points. Each straight segment has the same length as its corresponding folded segment because reflection preserves distances. The wall crossings identify where a fold would turn the line back into the original room.

This view separates two questions that can look muddled in a zigzag: “Which wall comes next?” and “In which copy of the room does the straight ray arrive?” It also connects directly with visual reflection. Try the rotation and reflection guide to compare the transformations, or make your own reflected drawing in Symmetry Studio.

Use the model as a ruler, not as a promise.

The demo predicts a route only for its stated assumptions. A circular ball touching a wall uses its centre’s offset from the edge; a rotating or accelerating object needs additional rules. A target with width needs a collision test against an area rather than a mathematical point. None of those features is secretly included here.

Nevertheless, the small model provides useful questions. Does an early contact change when the angle moves slightly? How many contacts remain after a corner? Does the unfolded route stay straight at every wall? Predict before dragging, then inspect the displayed wall sequence. This turns aiming from a purely visual guess into a checkable geometric statement.

The same discipline appears in our symmetry pattern study: keep one input fixed and change the transformation deliberately. You can also compare the geometry with the discrete choices in number gates, or return to How games work for another original model.

Sources and method.

The rebound algorithm and mirror-room construction are original to this page. Their routes, boundary cases and equal-angle behaviour are checked by local pure-function tests. Read our editorial standards for more on sourced explanations and reproducible examples.

Questions to try next.

Is the angle measured from the wall or its normal?

The law of reflection measures incidence and reflection from the normal, the line perpendicular to the wall at the contact point. The aiming control instead uses a screen direction: zero degrees points right and angles increase downwards. Both descriptions are valid, but they should not be mixed in one calculation.

What changes when the path hits a vertical wall?

The horizontal component of its direction reverses and the vertical component stays the same. At a horizontal wall, the vertical component reverses instead. This component rule produces equal angles with the wall’s normal for the ideal, frictionless point used in the demonstration.

What happens at an exact corner?

The vertical and horizontal contacts occur at the same distance along the ray. The demo records one corner contact and reverses both direction components, so the route returns along the incoming line. That corner still uses one of the five available contacts, avoiding a zero-distance loop at the boundary.

Does the mirror-room view predict a different route?

No. It represents the same route. Reflecting the room across each contacted wall lets the path continue straight instead of changing direction. Folding those reflected rooms back onto the original reconstructs the same sequence of rebounds and the same segment lengths.