# reflect() function for normal and light vector?

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

## Recommended Posts

I have to admit my knowledge of vector math is very limited indeed. :) How do I compute the reflection vector if I have an 'incoming' vector v and a surface normal n of the reflecting surface please? is it "2 * n * (n dot v) - v"?

##### Share on other sites
edit:
-2.0f * n * (n*normalize(v)) + v

where n is the surface normal and v is the direction vector you want to reflect

since you aren't normalizeing v i think you're over estimateing the projection of v onto n which would fuck up your results.

##### Share on other sites
v-2*n*(n.v) is correct as long as n is normalized. If it isn't, v - 2*n*(n.v)/(n.n) is the way to go. v doesn't need to be normalized in either case.

##### Share on other sites
Quote:
 Original post by Darkstrikev-2*n*(n.v) is correct as long as n is normalized. If it isn't, v - 2*n*(n.v)/(n.n) is the way to go. v doesn't need to be normalized in either case.

quoted for truth.

sorry, i didn't think before posting.

##### Share on other sites
Thx. I am normalizing all vectors, just did not explicitly note that here.

##### Share on other sites
Quote:
 I am normalizing all vectors, just did not explicitly note that here.

Not the velocity I hope ...

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002295
×