Vector reflect problem

Posted by xdevel2000 on Game Development See other posts from Game Development or by xdevel2000
Published on 2012-06-18T15:00:41Z Indexed on 2012/06/18 15:25 UTC
Read the original article Hit count: 201

Filed under:
|
|

I'm testing some vector reflection and I want to check what happens when a ball collides with a paddle.

So if I have:

Vector2 velocity = new Vector2(-5, 2); 
position_ball += velocity;

if (position_ball.X < 10) 
{
    Vector2 v = new Vector2(1,0); // or Vector2.UnitX   
    velocity = Vector2.Reflect(velocity, v); 
}

then, correctly, velocity is (5,2) after Reflect, but if I do:

if (position_ball.X < 10)
{
  Vector2 v = new Vector2(1,1); 
  velocity = Vector2.Reflect(velocity, v);
}

then velocity is (1,8) and not (5, -2) that is the solution of reflection equation R = V - 2 * (V . N)

Why is that?

© Game Development or respective owner

Related posts about XNA

Related posts about c#