• FEATURED
• FEATURED
• FEATURED
• FEATURED
• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# 2D Vector Reflection ?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1HUWUWA  Members

Posted 29 June 2003 - 11:32 AM

Hi guys, I''m making a breakout clone and need to reflect the ball off the wall. I thought I had the perfect formula but I added angled walls and the reflection doesn''t work right now. I was basing the reflection off the wall normal. It would be nice to have a formula that can take any normal and reflect the ball direction, then I don''t have to do all the if...then tests. I guess I don''t really care though so long as it''s fast. Thanks.

### #2Yohumbus  Members

Posted 29 June 2003 - 11:42 AM

Arg I know this one if I can just remeber it from POV-Ray!

ah here we go...
Vect1 is the direction of the ball before hitting the wall
Vect2 is after the wall
WallN is the normal of the wall
DOT is the dot product

Vect2 = Vect1 - 2 * WallN * (WallN DOT Vect1)

note that this will work for 3D vectors too

[edited by - Yohumbus on June 29, 2003 6:43:00 PM]

### #3Cedric  Members

Posted 29 June 2003 - 01:25 PM

WallN must be normalized.

### #4JavaCoolDude  Members

Posted 29 June 2003 - 01:40 PM

I like this better;
V-=2*Normal_wall*(Normal_wall.V)

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.