c4dynamics.states.lib.datapoint.datapoint.mass

Contents

c4dynamics.states.lib.datapoint.datapoint.mass#

property datapoint.mass#

Gets and sets the object’s mass.

Default value \(mass = 1\).

Parameters:

mass (float or int) – Mass of the object.

Returns:

out (float or int) – A scalar representing the object’s mass.

Example

  1. datapoint

Two floating balloons of 1kg and 10kg float with total force of L = 0.5N and expreience a side wind of 10k.

Import required packages:

>>> import c4dynamics as c4d
>>> from matplotlib import pyplot as plt
>>> import numpy as np

Settings and initial conditions:

>>> dt = 0.01
>>> tf = 10 + dt
>>> F = [0, 0, .5]
>>> #
>>> bal1 = c4d.datapoint(vx = 10 * c4d.k2ms)
>>> bal1.mass = 1
>>> #
>>> bal10 = c4d.datapoint(vx = 10 * c4d.k2ms)
>>> bal10.mass = 10

Main loop:

>>> for t in np.arange(0, tf, dt):
...   bal1.store(t)
...   bal10.store(t)
...   bal1.X = c4d.eqm.int3(bal1, F, dt)
...   bal10.X = c4d.eqm.int3(bal10, F, dt)
>>> bal1.plot('side')
>>> bal10.plot('side', ax = plt.gca(), color = 'c')
>>> plt.show()
../../../_images/mass_balloon.png
  1. rigidbody

The previous example for a datapoint object is directly applicable to the rigidbody object, as both classes share the same underlying principles concerning translational dynamics. Simply replace c4d.datapoint(vx = 10 * c4d.k2ms) with c4d.rigidbody(vx = 10 * c4d.k2ms).