Explain like I'm 5: Reflection Algorithm

This topic is 2298 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Someone helped me solve a difficult physics problem where it involves balls hitting a circular wall from both sides. It can also be applied to an object hitting an wall with an arbitary angle. In essence, it relies on the collision detection, rather than the response from the object.

Quoted:

To reflect a vector on another + reverting the direction:
N: normal vector you want to use the mirroring line, make sure it is normalized(length = 1)
V: vector you want to reflect with N
R: reflected vector

R = -2*(V dot N)*N + V
[/quote]

I would like for someone to help me explain how they get this formula. I just could not get around it on paper and head. Thanks in advance.

Share on other sites
The (V dot N)*N part of the equation is equal to the projection of V on the mirroring line, so if you subtract that from V, you get the part of V which is going parallel to the reflecting surface. If you subtract (V dot N)*N from this new vector, you get a vector that has the same component parallel to the reflecting surface, but an inverted component parallel to the line of reflection. Does this help?

Share on other sites
To Bacterius:

I did not realize I have to draw them like this. I figured, since it involves reflecting from a circular wall, I went from there. Comparing my drawings with yours, my normalized N vector is too long. The minus sign on the V vector also confuses me. Why would a dot product of (-V) and (N) be on the N vector, instead of towards the dark green arrow (the R vector)? So, I drew differently.

[size=2]The humilation... Edited by tom_mai78101

Share on other sites

To Bacterius:

I did not realize I have to draw them like this. I figured, since it involves reflecting from a circular wall, I went from there. Comparing my drawings with yours, my normalized N vector is too long. The minus sign on the V vector also confuses me. Why would a dot product of (-V) and (N) be on the N vector, instead of towards the dark green arrow (the R vector)? So, I drew differently.

[size=2]The humilation...

My own diagram is far from perfect too, and is not to scale either (having all the vectors the same size just ends up looking awkward in this case, so I didn't mind an extra-long normal vector). It is true that you could have used the positive dot product, which will have required you to subtract V instead of adding it, and then ultimately negate everything to get the R vector in the right direction, which should - hopefully - give the same result. This version just seemed more straightforward to me.

There is no need to be embarrassed, we all make mistakes every now and then

Share on other sites
Wait a minute, I'm not done... yet...

This is correct?

Edited by tom_mai78101

Share on other sites
No, the dot product is a scalar, not a vector, so it doesn't make sense to give it an arrow. I gave mine two arrows to indicate it was a length, and only made it a vector by multiplying it by N. What you are looking at in your diagram is the vector A + B. Edited by Bacterius

Share on other sites
No, that's A+B. A dot B is a scalar, but if you multiply A dot B by B you get the projection of A on B like so:

EDIT: actually not like that, I got the blue arrow the wrong way around somehow so the red vector should be A-(A.B)B. Sorry about that. Edited by RulerOfNothing

Share on other sites
[s]@RulerOfNothing Actually you drew (-A) dot B. The two vectors must be "going apart" in the dot product definition![/s] ignore this Edited by Bacterius

Share on other sites
R = -2*(V dot N)*N + V = V-2*(V dot N)*N

V dot N ===> Gives you the amount "how much N is in V"

(V dot N)*N ===> Builds a vector in the direction of N with that amount

V-(V dot N)*N ===> Would give you a vector *without* the normal component of the reflecting wall.

V-2*(V dot N)*N ===> Gives you the vector with an inverted normal-component. That's what the law of reflection is about.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633726
• Total Posts
3013570
×