Define and calculate a tank's weight and center of gravity.
There are three ways to define the center of gravity of a tank object:
A base object can be created without specifying its center of gravity. First, create an empty BaseObject:
Fill it with the identification tag, geometric and weight data:
Now create an empty DerivedObject:
Link it to the respective BaseObject and fill it with position (in relation to the vessel):
To calculate the object's weight and CG, first we create a ShipState object to handle the simulated state:
And then evoke the getWeight method with the state as argument:
Which returns the full tank weight with the CG positioned in the center of the bounding box:
To define a fixed CG, the weight information inside the base object above can be defined as:
So, the getWeight method returns:
To calculate the CG according to the fluid level, a CG mapping needs to be defined in the base object, for example:
If the base state is kept as before (full, or fullness = 1), then the getWeight method yields the total weight with the maximum CG listed in the mapping above:
Now, if the base state is changed to fullness = 0.7, the method will calculate the new weight and interpolate the corresponding CG from the valules listed in the mapping, returning: