# Reflection off of arbitrary normal

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

## Recommended Posts

Is there an equation that will calculate the reflection vector of an arbitrary surface normal? (You know, bouncing collision response.) :)

##### Share on other sites
Fruny: how funny, i see this question every few weeks and so far nobody, NOBODY
has provided any actual solution for it, go google that yourself, you will see
that not even google is able to answer that question, at least not in a way
that I or general public could understand.

##### Share on other sites
V -= (2.0f * (V . N)) * N

is that simple enough? See basic optics for explanation, or draw it on paper.

V -= (2.0f * (V . N) / (N . N)) * N

if N isn't normalised.

or

Vn = ((V . N) / (N . N)) * N
Vt = V - Vn
V = Vn * (-CoE) + (1.0f - CoD) * Vt

CoE = coefficient of elasticity
CoD = Drag (or firction) coefficient.

ect...

##### Share on other sites
Quote:
 Fruny: how funny, i see this question every few weeks and so far nobody, NOBODYhas provided any actual solution for it, go google that yourself, you will seethat not even google is able to answer that question, at least not in a waythat I or general public could understand.

I did.

Quote:
 Original post by oliiiV -= (2.0f * (V . N)) * Nis that simple enough?

Apparently not. [depressed]

##### Share on other sites
what does "V . N" mean? multiply those? why do you then use asterixes too?

##### Share on other sites
. <==> vector dot product
* <==> vector-scalar or scalar-scalar multiplication

##### Share on other sites
Quote:
 Original post by GameCat. <==> vector dot product * <==> vector-scalar or scalar-scalar multiplication

so that makes:

V.x:= -(2.0 * (crossProduct(V, N)) * N.x
V.y:= -(2.0 * (crossProduct(V, N)) * N.y
V.z:= -(2.0 * (crossProduct(V, N)) * N.z

is this correct?

##### Share on other sites
No, the dot product is not the same as the cross product.

##### Share on other sites
Quote:
 so that makes: V.x:= -(2.0 * (crossProduct(V, N)) * N.xV.y:= -(2.0 * (crossProduct(V, N)) * N.yV.z:= -(2.0 * (crossProduct(V, N)) * N.z is this correct?
Close, but it's the dot product, not the cross product. (Maybe just a typo...) Also, if := is assignment then you probably need to insert V.x, V.y, and V.z, respectively, before the negative sign and after the = sign in each line, like this:

V.x:=V.x - (2.0 * etc...
V.y:=V.y - etc...
V.z etc...

##### Share on other sites
so this is how it should be then right?

function DotProduct(const A, B: Vector): decimal;beginResult:= A.X * B.X + A.Y * B.Y + A.Z * B.Z;end;procedure VectorReflect(var vec, normal: Vector);vardp: single;begindp:= DotProduct(vec, normal);vec.x:= vec.x - (2 * (dp * normal.x));vec.y:= vec.y - (2 * (dp * normal.y));vec.z:= vec.z - (2 * (dp * normal.z));end;

the function always returns same vector - the
normal itself but different length :S