Griffin
Griffin

Reputation: 2517

Equation to calculate new object velocity(angle specifically) after reflection?

Hey I can't figure out what the equation to find the new angle of travel of an object is after reflecting off of a wall.... The angle of travel is also based off the unit circle so 0degrees would be traveling right, 180 traveling left, 270 down, etc.

Just making the angle negative doesn't work either, any tips?

Upvotes: 0

Views: 1053

Answers (3)

Jeff Gortmaker
Jeff Gortmaker

Reputation: 4737

I think this is what you're looking for. I added in the angle of the wall, even if you didn't need it.

reflectionAngle = wallAngle + ((wallAngle + 180) - (incidenceAngle + 180))

If the wall is just vertical, its angle would be 90 degrees.

I hope this helps, and good luck!

EDIT: As a more simplified method, posted by Casey below:

reflectionAngle = 2*wallAngle - incidenceAngle

Upvotes: 5

duffymo
duffymo

Reputation: 308743

You have to change the angle relative to the wall coordinate system (t, n) and then transform back to (x, y) coordinates. The wall coordinate n is perpendicular to the wall; the direction t is created by taking the cross-product of the t-vector into the z-direction.

The algorithm would say that the incoming (v_t, v_n) velocity are changed as follows:

  1. perpendicular component v_n changes sign.
  2. tangential component v_t is unchanged, assuming no friction.

Once you have those, transform back to (x, y) coordinates.

It's easy if you think in terms of 2D vectors.

Upvotes: 1

Wolfgang Kuehn
Wolfgang Kuehn

Reputation: 12926

It would be

outAngle = 360 - inAngle

Upvotes: -2

Related Questions