#### Archived

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

# Physics problem - collision response

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

## Recommended Posts

This is probably meant to be a vector math question. I''m creating a 2D game engine for a side-scroller (I''m a die-hard fan of the Castlevania series) with a real-world physics model. I''m working from my old physics notes, using the basic freebody diagram. Here''s a picture: If you can''t see the picture, blame GeoCities. Anyway, it''s just a box with the basic four forces acting against it: applied force (acceleration), resistance (friction), gravity (weight), and surface normal (the ground). Now, let''s assume my object is resting on a slope. The surface normal always presses against the object with the same force as its weight, but the direction vector is going to be at an angle, which means the object will be pushed gradually back down the hill (assuming we disregard friction). I apologize if you can''t see the pictures. Anyway, can somebody give me an example of how I would do the vector calculations to determine how fast my object slides down the incline? A link to a physics document would be great, if you can''t afford an explanation. More questions to come on this subject.

##### Share on other sites
I think you just need to resolve the forces. So if your angle between the slope and the gravity vector is , and P is the force due to gravity, then the force along the slope will be

P.Sin()

So, if there is no slope, is 0, so the force along the slope is zero. Likewise, if is 90 degrees then the force along the slope would be P.

##### Share on other sites
Tom,
Hello, Friend, i won''t be of much help on this topic, sorry but there is a question, actually i''m working on my game engine too or you can say i''ll start working on it. Please let me know the knoweledge basis and which API you are using. Thank You.

Thanks again

##### Share on other sites
Ok, well lets see

There are a few forces acting on the object here,

1) Gravity is accelerating the object down
2) Friction is pushing back (if applies.. )

So for gravity the force = mass * acceleration:

lets let M be the mass of the object, and A be the angle of incline from the horizontal, also lets call the acceleration of gravity g ( = 9.8 m/s/s)..

Therefore the downward force is f = M*g*sin(A)

Since there is no friction in this case, you only have to worry about how fast and what direction the object is moving..

each second the vector will grow by a small amount, this can be determined by the acceleration of he object.

acceleration = force / mass
= M*g*sin(A) / M
= g*sin(A)

So basically all you have to do is take a vector pointing in the direction of the incline and use this as an acceleration vector. It will have a magnetude of g*sin(A), then for each second add it to the velocity vector of the object (this will accelerate it down the hill) and move the object along the velocity vector.

This should work, and to add friction to the formula isn''t too hard. Basically you''ll have a force counteracting the acceleration due to gravity, and the force accelerating the object will look like ( M*g*sin(A) - X ) where X is the force due to friction.

I don''t have my memory with me today, so I forget what exacty is involved in getting the force due to friction... it does invlove a coefficient of friction (different for different materials ) and the force pushing down on the surface.

So basically you''d take the coefficient of friction, F, and the force of gravity on the object pushing down on the plane g*cos(A) and multiply them together (this is where I could be wrong) to get the force of friction - which we''ve labeled X.

This gives an acceleration vector of (M*g*sin(A) - g*cos(A))/M

- well, I could be a little wrong with the friction part, but it''s a start. At least the stuff without friction works and should give you a good start. The important idea is that if you want to simulate friction all you have to do is slow down the acceleration vector a little.

If anybody out there can correct me, I''d be happy because I don''t feel like pulling out my physics book - it''s way too heavy!

Anyway, enjoy

##### Share on other sites
Hi first of all:I can´t remember well how to do it =(.Pick up an Institute(High School?) physics book. I can remeber you have to separate forces between the axes, that is, take vertical and horizontal forces separately. Find the angle between the "new" vertical axis and the "old" one. Do your phisics as always for each axis, BUT multipyling each with the SIN/COS(think SIN for Y, not sure) of the angle i told before.

Sorry for not helping more, but I´m not sure if I know it WELL and it will be worse if a "teach" something wrong. Just pick up a book. Hope to help.

.-If you find phisics articles/links, please email me...I´d like to include more advance phisics to my (not yet started) game engine...

What the hells!

##### Share on other sites
Well I think Flanders is right, to tired to read it properly and think it all through and check, sorry.
Anyway what I will add is a little bit about friction, I think bascily all you need is:-
f=ur
f=frictional force.
u=coefiicient of friction.
r=the normal reaction force.
Altering u will change the roughness/smoothness of the surfaces, allways between 0 and 1 I beilive.
Nice and simple that one.
Sorry if this is wrong, I''m tired. Hmmmmm I allways use that excues.
Anyway hope thats some help.

##### Share on other sites
Thanks for the great replies, everyone.

Sajjad: I''m programming with Visual Basic, using DirectX 7. My knowledge base is simply what I learned in high school physics class, plus whatever I can pick up from all the brains here at the GameDev forums.

Anonypous: Sounds good.

Flanders: Also sounds good. You''re right about the friction formula, but you left out the coefficient in your last equation. If we assume ''f'' is the coefficient of friction, then I think it should look like this:

a = (m * g * sin(A) - f * g * cos(A)) / m

You''ll have to check me on that, because this is just an educated guess.

Grugnorr: I don''t know of any sites describing the type of physics we''re talking about (my search turned up nothing useful), but if you''d like me to compile all my notes to a document and mail it to you, just drop me a letter.

Now, I''d better rephrase my question so it can be answered properly. (You can''t get the right answer until you ask the right question, after all.) I''m more confused on how to combine these vectors. Perhaps a quick run-down on vector math would help me understand.

Grugnorr: Can you provide an example for your explanation?

##### Share on other sites
Diragor: Damn, that''s exactly what I need. Thanks a million.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• ### Forum Statistics

• Total Topics
633368
• Total Posts
3011531
• ### Who's Online (See full list)

There are no registered users currently online

×