Jump to content
  • Advertisement


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


How to calculate bounce angle?

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

I am making a particle system where the particles hit a plane and bounce in the proper direction. The problem is that I dont know how to calculate the angle. Do I take the dot product of the contaction plane and the vector for the particle? Can ne1 help? Thanks.

Share this post

Link to post
Share on other sites
im really no expert on this subject, but heres my two cents, wouldnt it be possible(assuming slopes of particles that are a straight line) to find out the slope of the particles movement just before it hits the plane and use the recipricole(spelling?)as the slope for the particle after it hits the plane?

ive never done this so im not sure if it will work, but hey, its better than not getting any reply, c ya


-= kill one, your a murderer, kill thousands your a conquerer =-

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Straight from my raytracer. I think you want the reflection of the vector striking the plane as the new particle direction.
Ignore the raytrace bits of this code, but you can see how reflectedRay.direction is calculated, I think this what you want. The vector "normal" is simply the (A,B,C) normal of the plane. The official way to find reflection is R = I - 2*(N·I)*N. Basically, the code below simply implements this formula.

Color Reflect(Ray& ray, Vector& intersection, Vector& normal, int currPrimitiveNum, Primitive* primitives, int numPrimitives, Light* lights, int numLights, Color& ambientCoef, int depth)
Ray reflectedRay;
float scaleFactor = 2 * VectorDot(normal, ray.direction);
reflectedRay.direction.x = ray.direction.x - (normal.x * scaleFactor);
reflectedRay.direction.y = ray.direction.y - (normal.y * scaleFactor);
reflectedRay.direction.z = ray.direction.z - (normal.z * scaleFactor);
reflectedRay.origin = intersection;

return Trace(currPrimitiveNum, reflectedRay, primitives, numPrimitives, lights, numLights, ambientCoef, depth+1);

Share this post

Link to post
Share on other sites
The way I find the above easiest to remember is to draw a rectangle and divide it into four equally sized rectangles then draw the diagonals of the original rectangle. One diagonal is the ray and the other is the reflected ray. Where they meet is the surface. The dot product of the normal and the ray''s direction is one half the length of a side. While you are really only using two of those four equally sized rectangles it just seems easier to picture with all four of them.

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!