Reflection off of a surface

1. Nov 25, 2014

Xyius

I am writing a simulation in MATLAB of particles that perfectly reflect off of a surface. However, my question is physics based, not code based.

So here is my issue. A particle is traveling towards a flat plane in space at z=1 with a velocity vector of [0,0,1]. The normal vector of the surface is [0,0,-1].

I want to calculate the reflected trajectory of the particle so I use the following expression.

$$|\vec{v}|\left[2(\hat{n} \cdot \hat{v})\hat{n}-\hat{v}\right]$$

The problem is, in my head, the reflected trajectory should clearly be [0,0,-1] However, when I calculate it, I get [0,0,1]. Why is this happening? Is my equation right?

EDIT:

I know the normal vector of the surface is correct, as the front of the plane is facing the particle source.

Also, I need to use the general expression for a reflection as I will be moving onto any 3D object as the next step.

Last edited: Nov 25, 2014
2. Nov 25, 2014

SredniVashtar

Draw the vectors and their versors for a generic incident beam, let's say at 30° wrt the surface.
Then draw the projection of versor v on the direction of n, and its double.
Then sum it to the negative versor of v using the parallelogram rule.
You have to use a ruler to have the proportions right.

It appears that the result is opposite to the reflected beam. Do you agree?

3. Nov 25, 2014

Khashishi

I'm not sure where you got the equation from. Break up your initial velocity vector into a lateral component and a normal component. Reverse the normal component, and add it back to the lateral component. It should work regardless of the direction of the normal.

4. Nov 25, 2014

Xyius

SredniVashtar

It seems like I get the opposite of what I should get. But I already got this result using the simpler case of a vector normal to the plane.

Khashishi

I remember in many of my electromagnetics courses, there was a general expression for the reflection of a vector. I looked on the internet to try and find it and got this..

http://en.wikipedia.org/wiki/Reflection_(mathematics)

Scroll down to "Reflection across a line in the plane"

The result of the equation doesn't seem to match my intuition.

EDIT:

I will look into using MATLAB functions to project the normal then subtract as another way of doing this without the equation.

5. Nov 25, 2014

Khashishi

Try manually deriving the reflection by breaking it up into components. Maybe the wiki is wrong (I didn't check).

6. Nov 25, 2014

Xyius

So everything points to there being a negative sign that is wrong. I swapped the negative sign and it works in one scenario in my code, but not another. I will determine if this problem is really solved or if something is weird in my code and report back!