Archived

This topic is now archived and is closed to further replies.

Booiiinngg!!!

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

Recommended Posts

lo ppl =) simple maths/physics question: i have a vector that has a collision with a plane that i have the normal of (plane defined by two vectors of triangle, normals precalculated using cross product). how would i make the vector "bounce" off of the plane? i know that the angle at which it bounces off the plane will be equal to the angle it hits the plane at, you know what i mean, and i heard that you have do use cosine and dot products or something, but i dont know how. hlp? http://www.xeodus.com

Share on other sites
Its easier if your vector is a speed (most likely cause for boing). Your vector can be decomposed as a sum of two vectors, one that goes straight into the plane (perpendicular on the plane, paralel to the plane normal), and a vector paralel to the plane.

v = vt + vn (your vector equals the vectorial sum of the tangential component and the normal component)

The way to find the vector perpendicular to the plane involves a simple dot product. First, lets notice that since this vector is paralel to the plane normal, you could get its xyz components by multiplying the normals xyz with the vectors length. But the normal vectors length is just the dot product between the plane normal and the initial vector.

So,

(length of)vn = v (dot) n

The difference between (length of)vn and vn is that the first is a number, while the second is a vector with three components. As you know, the dot products result is a number (while the cross dots product result is a vector)

Like I said,
vn = (length of)vn * n = (v (dot) n) * n

Obviously, by * I mean a multiplication between an number and a vector, which results in a vector (number * vector = number * (x, y, z) = (x * number, y * number, z * number))

Now, you have

v = vn + vt

Since you want the boing effect, its obvious that you want the direction of the vn vector reversed. So, you want your resulting vector to look like this

v1 = -vn + vt (movement towards the plane gets switched (boing), movement across the plane goes on unchanged) I bet you've seen this with 2d collisions with horizontal or vertical lines.

This means that

v1 = vt - vn + vn - vn = vt + vn - 2 * vn = v - 2 * vn

So the final formula :

v1 = v - 2 * (v(dot)n) * n

Edited by - Diodor on April 23, 2001 9:40:57 PM

1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 38
• 23
• 13
• 13
• 17
• Forum Statistics

• Total Topics
631708
• Total Posts
3001840
×