Motor Flash Physics: fancy buoyancy

August 30, 2006 on 2:33 pm | In Actionscript, Physics | 2 Comments

Buoyancy is a force that acts on a body which is immersed in a fluid. This force can be divided into a static and a dynamic component. The static component acts on a body that rests in a fluid – it determines if a body floats or sinks and it always points in the opposite direction of gravity, whereas the dynamic component is always directed against the movement of the body, so it can be used for a ship that moves horizontally or a body that drops from a height into the water.

The static force is equal to the weight of the displaced water, which can be calculated by clipping the polygon against the plane that defines the water level. An efficient way of doing this is to triangulate the polygon and clip each triangle to the water plane, which is faster than clipping the complete polygon against the plane. Thanks to Erin Catto for pointing that out.

The dynamic force acts as a damper and is proportional to the velocity of the body in the fluid. To calculate this physically correct would be overkill because you would have to use drag. So its just approximated by using the submerged area. And of course all forces act on the centroid (center of mass).

Since I am still using the slow (non-optimized ;-)) AS2 version of the motor engine I provided a flash-projector for the demo so you can play around with the demo at a descent speed (try to stack the boxes on top of each other). When the AS3 port is finished (hopefully soon) I will recompile and enhance all demos.

Now watch (popup) or download the buoyancy demo!

2 Comments

TrackBack URI

  1. EHhmm cool! Very cool!

    Comment by Snipergen — September, 2 2006 #

  2. Very impressive demo. I can’t wait to see this in as3

    Comment by Oz — September, 6 2006 #

Sorry, the comment form is closed at this time.

Proudly powered by WordPress Theme based upon Pool theme by Borja Fernandez.
Entries and comments feeds.