Thursday, April 21, 2011

Reflection Vector Research

Reflection Vector Research:

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

v' = 2 * (v . n) * n - v;
Where '*' is the scalar multiplication operator, '.' is the dot product of two vectors, and '-' is the subtraction operator for two vectors. v is reflected off of the surface, and gives a reflection vector v' which is used as the new velocity of the object.

Dot Product By Hand:
http://www.slideshare.net/ChelseaDarling0/trigonometry-lesson-dot-product



Basically: [1]Multiply the X components together.
[2]Multiply the Y components together.
[3]Add the X and Y of the new point2 value
together to get a single scalar float value.

2 comments:

  1. Static initializers/ Constructors found here:
    http://manishjethani.com/blog/2008/03/31/static-initializers-in-as3

    ReplyDelete
  2. Mouse Listener:
    http://polygeek.com/426_flex_using-the-delegate-class-to-manage-scope

    Having problem setting up mouse listener inside a class.

    ReplyDelete