How to calculate bounce angle?
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.
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 =-
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 =-
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.
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);}
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement