Figuring out normal force.

Started by
7 comments, last by boogyman19946 10 years, 2 months ago

Hello everyone!

I have a question that pertains to figuring out normal force. I seem to have a predicament that involves collision detection.

At the start I first sum all the forces acting on the object at hand. All external forces come from input or collisions that were maybe applied last cycle. Then all the internal forces: friction, gravity, and normal force. Gravity I can figure out, but figure friction requires me to know the normal but for that I have to know if I'm standing on a platform or not. My question is, is there some elegant way to solve this? For example, is it plausible to just omit the normal force on the first cycle, check collisions and apply the normal force on the next? Or should I make a deliberate check if player is standing on a platform?

Yo dawg, don't even trip.

Advertisement

It looks like you are making a step into the Continuous Collision Detection concept.

The idea is simple. You should first detect the collision between the two bodies, platform and player. When this type of collision is made, you mark it them as colliding, thus activating your continuous contact routines, which should apply the normal force. While they are marked as colliding, you should apply the normal, and keep in watch for a break of this contact, that could be caused by several things:

The player jumps

The player goes beyond the platform border

A new force is applied (a bomb, a bullet, a backflip kick from a rhino...)

Any force change (weakening gravity, variable magnetic force)

This is a simplified version of the theory, also notice that it is my own interpretation, but it is quite a complex algorithm and I am searching the Box2D code to understand its implementation myself; so I can't help you further, but if you like to read code, here is a link that can.

You could use a simpler but specialized version. It would probably perform even better.

From your description, it sounds like the platform is not a collision object. If you make the platform a collision object, a collision will result (when appropriate) between the player and the platform, and provide the point of contact and the contact normal. (Many collision engines provide for a planar collision object with a normal, an extent, friction factors, etc.)

Am I understanding your question?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

The normal force minus gravity equals 0 if you are standing on a platform.


N - G = 0 
N = G

"Don't gain the world and lose your soul. Wisdom is better than silver or gold." - Bob Marley

It looks like you are making a step into the Continuous Collision Detection concept.

The idea is simple. You should first detect the collision between the two bodies, platform and player. When this type of collision is made, you mark it them as colliding, thus activating your continuous contact routines, which should apply the normal force. While they are marked as colliding, you should apply the normal, and keep in watch for a break of this contact, that could be caused by several things:

The player jumps

The player goes beyond the platform border

A new force is applied (a bomb, a bullet, a backflip kick from a rhino...)

Any force change (weakening gravity, variable magnetic force)

This is a simplified version of the theory, also notice that it is my own interpretation, but it is quite a complex algorithm and I am searching the Box2D code to understand its implementation myself; so I can't help you further, but if you like to read code, here is a link that can.

You could use a simpler but specialized version. It would probably perform even better.

This seems to be pretty much what I was looking for. I wasn't sure what to look up but I'll have a look at this when I have time and get back to you on that.

From your description, it sounds like the platform is not a collision object. If you make the platform a collision object, a collision will result (when appropriate) between the player and the platform, and provide the point of contact and the contact normal. (Many collision engines provide for a planar collision object with a normal, an extent, friction factors, etc.)

Am I understanding your question?

The platform is a collision object. The entire world in my game is actually made out of discrete objects. My question should have been "how do I know if I'm standing on a platform if I haven't detected collisions yet on this cycle." My physics simulator does things in the following order: sum forces, get acceleration, integrate acceleration and velocity, and with the resulting disposition, check collisions and respond. The problem with this is that I won't know if I'm standing on a platform until I check collisions, but I need to know that when I'm summing forces because of the normal force.

The normal force minus gravity equals 0 if you are standing on a platform.


N - G = 0 
N = G

The question isn't that simple I'm afraid. And I don't want to be a party pooper, but on an inclined surface, N != G.

Yo dawg, don't even trip.

The normal force minus gravity equals 0 if you are standing on a platform.


N - G = 0 
N = G

It is not that simple, I suppose...

As boogyman pointed out, on any inclined surfaces, they'd have different values. The normal would also be in a different direction.

Important to notice, the normal isn't a reaction to gravity, but to everything that forces something against a surface. So, if you are on a rising platform, for example, it could have a normal that is higher than the sole effect of gravity.

As a side note, gravity is actually acceleration while normal is a force, I would try to avoid this kind of misleading comparison...


N - G = 0 
N = G

Oops, seems like I've been lazy with my terminology. I meant to say "force of gravity," or "weight" if you will.

EDIT: Seriously, I give up on quoting mechanism. I fail so hard at it XD

Yo dawg, don't even trip.

On inclined surfaces the normal force will be equal with the sine or cosine of the inclined surface angle * gravity . Am I right?

270px-Freebodydiagram3_pn.svg.png

"Don't gain the world and lose your soul. Wisdom is better than silver or gold." - Bob Marley

On inclined surfaces the normal force will be equal with the sine or cosine of the inclined surface angle * gravity . Am I right?

270px-Freebodydiagram3_pn.svg.png

I always remember it as the negative projection of the gravity force onto the normal vector of the surface where the object is rested.

Yo dawg, don't even trip.

This topic is closed to new replies.

Advertisement