Name: Anonymous 2010-12-16 12:59
Implementing physics in programs is fuck easy. Let me illustrate:
Each object has an x, y, and z coordinate. Per frame it exists in a particular x,y,z coordinate. To model forces acting on that object, we need two attributes for each coordinate: current velocity (v), and change in velocity per frame aka acceleration (a).
For each frame, using x as an example, do this:
x.v = x.v + x.a
x = x + x.v
When forces act on an object, you have to modify a and v accordingly. Velocites are reduced by division, and directions are reversed by a sign change. So, say object A and B collide, you can model that like this:
A.[coordinate].v = - (A.[coordinate].v / 1.5)
and same for B
You might want to divide by a factor dependent on the objects weight or mass, so you could define that as well, a w or whatever.
Gravity is easy too. Just do something like this per frame
[object].y.v = [object].y.v + .05
for .05 substitue a weight factored value or other value that works depending on the types of objects
IT'S THAT EASY.
------------------------
Can someone elaborate more on this. Or give more examples.
Each object has an x, y, and z coordinate. Per frame it exists in a particular x,y,z coordinate. To model forces acting on that object, we need two attributes for each coordinate: current velocity (v), and change in velocity per frame aka acceleration (a).
For each frame, using x as an example, do this:
x.v = x.v + x.a
x = x + x.v
When forces act on an object, you have to modify a and v accordingly. Velocites are reduced by division, and directions are reversed by a sign change. So, say object A and B collide, you can model that like this:
A.[coordinate].v = - (A.[coordinate].v / 1.5)
and same for B
You might want to divide by a factor dependent on the objects weight or mass, so you could define that as well, a w or whatever.
Gravity is easy too. Just do something like this per frame
[object].y.v = [object].y.v + .05
for .05 substitue a weight factored value or other value that works depending on the types of objects
IT'S THAT EASY.
------------------------
Can someone elaborate more on this. Or give more examples.