#### Archived

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

# How to calculate bounce angle?

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

## 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 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

,Matt

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

##### Share on other sites
Yeah that is what i am trying to do but i dont know how to get the reciprocal.

##### Share on other sites
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 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.

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 18
• ### Forum Statistics

• Total Topics
632160
• Total Posts
3004497

×