Calculating and applying forces

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

Recommended Posts

I am working on the way forces are used in my physics engine and was hoping possible someone could comment if this was general idea (it seems to be from what I gathered from other physics engine/docs)

[color="#000000"][font="Arial"]Apply Gravity to total forces[/font]
[color="#000000"]
[color="#000000"][font="Arial"]Calculate Collisions (using total force + velocity for detecting collision)[/font]
[color="#000000"][font="Arial"]- If there is a friction, add the friction force to total force[/font]
[color="#000000"][font="Arial"]- If there is resting, subtract out the gravity from total force[/font]
[color="#000000"]
[color="#000000"][font="Arial"]Calculate acceleration as “acceleration = total force/mass”[/font]
[color="#000000"][font="Arial"]Calculate velocity as “velocity += acceleration * dt[/font]
[color="#000000"][font="Arial"]Calculate new position as “new position = current position + velocity”[/font]
[color="#000000"]
[color="#000000"][font="Arial"]Set total forces to zero, set acceleration to zero.

Edit: corrected my acceleration formula
[/font]

Share on other sites
I think you want acceleration to be calculated using total force/mass, but apart from that everything else looks fine.

Share on other sites
You almost got it. The below scheme is simpe, effective and widely used. It's called the symplectic Euler integration algorithm.

calculate forces

acceleration = force / mass
velocity += acceleration * dt
position += velocity * dt

reset forces and start all over

Share on other sites

I think you want acceleration to be calculated using total force/mass, but apart from that everything else looks fine.

Ah yes, that is what I meant.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633661
• Total Posts
3013219
×