Jump to content
  • Advertisement


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



This topic is 6293 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

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

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


(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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!