Jump to content

  • Log In with Google      Sign In   
  • Create Account


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.

  • You cannot reply to this topic
3 replies to this topic

#1 HUWUWA   Members   -  Reputation: 122

Like
Likes
Like

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.

Sponsor:

#2 Yohumbus   Members   -  Reputation: 152

Like
Likes
Like

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]

#3 Cedric   Members   -  Reputation: 158

Like
Likes
Like

Posted 29 June 2003 - 01:25 PM

WallN must be normalized.

#4 JavaCoolDude   Members   -  Reputation: 670

Like
Likes
Like

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.



PARTNERS