• Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
V -= (2.0f * (V . N)) * N

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

how about

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 this post


Link to post
Share on other sites
Quote:
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.


I did.

Quote:
Original post by oliii
V -= (2.0f * (V . N)) * N

is that simple enough?


Apparently not. [depressed]

Share this post


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

Share this post


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

Share this post


Link to post
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 this post


Link to post
Share on other sites
Quote:

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?
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 this post


Link to post
Share on other sites
so this is how it should be then right?



function DotProduct(const A, B: Vector): decimal;
begin
Result:= A.X * B.X + A.Y * B.Y + A.Z * B.Z;
end;

procedure VectorReflect(var vec, normal: Vector);
var
dp: single;
begin
dp:= 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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement