开发者

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 wo开发者_运维技巧uld be traveling right, 180 traveling left, 270 down, etc.

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


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


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.


It would be

outAngle = 360 - inAngle

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜