Reflection Vector

The direction after something moving along d bounces off a surface with unit normal n.

r = d − 2(d · n)n

Only the part of d perpendicular to the wall is flipped; the part along the wall stays.

It matches the law of reflection: the angle in equals the angle out.

Calculator

Change a value and the result and picture update instantly.

Result

Reflected x1
Reflected y1

Animated picture

The picture follows your values. Some points and shapes can be dragged.

Use in game development

Breakout balls, billiards and bouncing lasers. Multiply by a restitution factor for weaker bounces.

Code example (JavaScript)

const k = 2 * (vx*nx + vy*ny);
vx -= k * nx; vy -= k * ny; // bounce off a wall

What the symbols mean

SymbolMeaning
dxDirection x
dyDirection y
degNormal angle (°)
rxReflected x
ryReflected y

More formulas in this category

Frequently asked questions

What is the formula for Reflection Vector?
The formula for Reflection Vector is r = d − 2(d · n)n. The direction after something moving along d bounces off a surface with unit normal n.

Math Formula Quiz Math for Game Development

Sources

Checked: 2026-11-29