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 x
Reflected y
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
| Symbol | Meaning |
|---|---|
dx | Direction x |
dy | Direction y |
deg | Normal angle (°) |
rx | Reflected x |
ry | Reflected y |
More formulas in this category
- Rectangle Collision (AABB)
- Circle Collision
- Linear Interpolation (lerp)
- Easing Functions
- Cubic Bézier Curves
- Projectile Path
- Pseudo-Random Numbers (xorshift)
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