-
Accurate Bouncing Off An Angled Surface
Hey, i post here in hope someone can answer my question
How would i make a ball bounce off an angled surface? I have it bouncing off a horizontal and vertical and i have the accurate bounce sorted (Gravity, friction), but i'm stumped when it comes to angled surfaces.
I have a feeling it is to do with reflection, Ri (reflected) is R + (2N * - N . R);
Where N is the normal. However, even if it is achieved by this method, i am stuck on how to use it.
Just for clarity:
Any help would be greatly appreciated : D
-
hmm
Try here: http://www.tonypa.pri.ee/vectors/start.html
Its about vectors and has a section on making a ball bounce off any surface.
-
Hi, SA:
I have it already worked out for given values of the angle of inclination of the surface and the angle at which the ball is moving AND for the case in which the motion takes place on a horizonta surface, i.e., without gravity entering into the picture. If you give me some time I believe I can, first, having it work for any angles (that involves no problem) and for motion on a vertical plane, i.e., with gravity.
-
Senior Member
hey
i tried this a while ago using angles and such:
link
it did get a little complicated though, and since then i've discovered a much easier way to do this:
^^^^^^
<<<<VECTORS>>>>
!!!!!!!!!!!!
(can u sense the enthusiasm?)
so if you already know all about vectors, then read on
otherwise, read about what vectors are, and some of their operations (normalizing, dot-product, etc...) and then read on (it's really pretty simple)
(try tonypa's tutorials: link)
so here's my explanation:
-------------------------------------------
first we'll define pointA and pointB as the points between which the surface is stretched out
surfaceVector will represent the surface, by beginning at 'pointA' and stretching out to 'pointB'
we'll then have a velocity vector which starts at the position of the object's old position, and ends at the point of intersection on the surface
(when i say starts and ends i only mean it theoretically, as vectors have no position in space, but i use it for visualization)
so the two vectors we have are all that we really need!
as you know, in order to 'bounce' the velocity vector, we have to flip it horizontally around the surface
to do that, we'll do the following thing:
1. find the projection of the velocity vector on the surface vector (there-by getting the x-component)
2. once you have that scalar number, you create a vector in the direction of the surface, normalize it, and multiply it by the scalar #
3. you then add that vector to the velocity vector in order to make it 'bounce'
4. you are done --> watch your creation and enjoy
to add friction you can multiply that scalar by a coefficient (between 0 and 1)
If you are wondering how to 'project one vector onto another', try this:
for our example:
vectorA will be the projector (the one being projected)
vectorB will be the projectee (the one being projected upon)
1. normalize the projectee (VectorB)
2. find the dot product of VectorA and VectorB (call the result projectionScalar)
here's a picture:
---> that's all for projection, but you want to turn that scalar into a vector:
3. create a copy of surfaceVector (call it projectionVector)
4. normalize projectionVector
5. multiply projectionVector by projectionScalar
6. and there you have it, just add it to your velocity and you are done
i know that what i wrote might not be exactly 'clear', so dont be ashamed to drop me a line
Last edited by ozmic66; 01-28-2006 at 06:12 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|