   A question about normals
  Hello. Im currently messing about writing a physics program, at the moment a projectile is fired into the air at a random angle and velocity, then when it reaches it's apex it explodes and creates several particles as shown:what i would like all the particles to do is bounce on the ground appropriately. i tried just reversing their velocities and adding a multiplier for friction. this worked ok for some particles however some just seemed to run along the ground, plus i dont think is a very realistic way of doing it. i know how to work out a bounce velocity using a normal - but what i do not understand is how to work out the normal in the first place. i googled it but the answers were either irrelevant or too complicated for me. Any advice?Thanks   
  Check out the article and app:http://www.darwin3d.com/gdm1999.htm#gdm0399This will explain the math and technique behind collision response for 3D particles.As to your specific question, the normal in the case of the ground is just the up vector (whatever that is in your coordinate system).  The ground is just a plane with the up vector normal and the D of the plane is the ground height (often 0).   ;  The normal is simply the plane's normal ( [A,B,C] from the plane equation Ax+By+Cz+D=0), but you question is confusing so I doubt that is what you are looking for.Anyway, just a guess... If you let the particles go below the ground, they could get "stuck". When a particle collides with the ground, you must compute it's post-collision location and velocity, and not just start the next frame below the ground. If you don't mind the inaccuracy, then it could be as simple as forcing the height to 0 in any frame that the particle collides with the ground.As for the problem of jittering along the ground, most people solve that by setting the velocity to 0 when it is below a certain threshold.   ;  thanks for the replies but i don't really understand what you both mean. it is a 2D program. What do you mean by the 'up vector'? The ground in my program is just a line i draw along the screen and i determine that a particle has hit the ground when the particles y position is equal to or less than the grounds y position.Sorry for the questions, I'm not very good at physicsps. thanks for the link, i'll take a look   ;  A normalized vector is just a vector within the unit circle. This means all elements of the vector have a value between 0 and (+ or -)1. To get a normalized vector is actually quite simple:We have 3d vector A(2, 3, 4). To normalize it we divide every element of the vector by its length/norm/magnitude.The norm of A: ||A|| = sqrt(2^2 + 3^2 + 4^2) = sqrt(27) = 5.196A normalized = (2 / 5.196, 3 / 5.196, 4 / 5.196)If you've ever noticed that the positive X vector is always represented as (1, 0, 0) when you could just as easily do (12345, 0, 0) it's because it's normalized:||X|| = sqrt(12345^2 + 0^2 + 0^2) = 12345X / 12345 = (1, 0, 0)Normalized vectors are also used a lot with lighting.   ;  2D is not much different.  Just less math to do...I don't know your coordinate system so that makes it tricky.  But assume that y is positive up and the ground is y=0.  Your UP vector in that case would be (0,1), pointed up.  But for your simple problem, none of that matters.So I assume you have a velocity vector that is the x,y velocity of the particle. Call that vx,vy.  The particle position is px,py. So here is a simple ground response function:if (py <= 0)  // collision with ground vector   vy = -vy;  // reflect the y velocity to create the bounceThis is perfectly elastic collision meaning it loses no energy in the bounce. If you want to make it more realistic, add a coefficient of restitution:   vy = -vy * Cr;  // where Cr = (0 - 1.0) 0 = lump of clay, 1 = superball.Also you would want some general drag to make the particles stop eventually.  For viscous drag that is vx = vx - (vx * Vd);  // Vd is a small number (0 - 0.2) or somethingvy = vy - (vy * Vd);I use a 2d/3d vector library for this but you get it.  Advanced info: The reason for the up vector is that to handle the collision easily in 3D or when the thing you want to bounce off is not an axis-aligned plane.  In that case the collision code requires the collision normal vector using dot products and such.  See my article when you are ready for this.  In fact your homework after finishing this demo is to convert it to 3D.;  I think if you reverse the velocities and the positions (assuming y=0 is the ground), it should work just fine. You can multiply both by a coefficient smaller than 1, as you said. If this doesn't work, I suggest you post some code.   ;  I glossed over a few of the details that are in the articles but it occurred to me at least one is pretty important.  A minor point is that you don't need to negate or move the position as the simulation will take care of that the next frame.  In general, you don't want to directly move positions without fixing up the velocities unless you are using an integrator like the oft-quoted velocityless-verlet.  The "right thing" to do is effect the particles through impulses and forces.This will lead to some penetration of the ground if your timesteps are very large.  The options if this is not acceptable is to find the exact contact time and then apply the impulse (what the negating of the vy is really).  Or you can reduce the timestep until it is acceptable.  Whatever you like.  You can always move the position if you need to but fix up the velocity if you are using it.The point I forgot is that when you are detecting the collision, you need to make sure the particle is moving into the ground instead of away, otherwise, you could get an oscillation around 0 at big timesteps.  So the code we were talking about becomes:if (py <= 0 && // collision with ground vector    vy < 0) // make sure you are moving into the groundvy = -vy; // reflect the y velocity to create the bounceAnd don't just negate the velocity vector.  You only want to effect the component in the surface normal direction.  That is in this case only the Y part.  That is why I don't negate the x part.  Otherwise it will move wrong.-Jeff   ;  thanks, you've been a great help :)   ;  hi, i have one more question. the code you have given works fine except for when the particle comes to a stop after it has bounced. the acceleration for the y component is -9.81 and when the particle has stopped moving in the x direction it continues to descend into the ground as the velocity is continually updated. what would be the best way to get around this, simply set acceleration to 0 on the y component when it is appropriate? this would work but it does not seem to be a good implementation from a physics point of view. any suggestions?thanks   