Esempio n. 1
0
def exercise_basic():
    assert approx_equal(sum(spatial_lib.xrot((1, 2, 3, 4, 5, 6, 7, 8, 9))), 90)
    assert approx_equal(sum(spatial_lib.xtrans((1, 2, 3))), 6)
    assert approx_equal(
        sum(
            spatial_lib.cb_as_spatial_transform(cb=matrix.rt(((1, 2, 3, 4, 5,
                                                               6, 7, 8, 9),
                                                              (1, 2, 3))))),
        90)
    assert approx_equal(sum(spatial_lib.crm((1, 2, 3, 4, 5, 6))), 0)
    assert approx_equal(sum(spatial_lib.crf((1, 2, 3, 4, 5, 6))), 0)
    i_spatial = spatial_lib.mci(m=1.234,
                                c=matrix.col((1, 2, 3)),
                                i=matrix.sym(sym_mat3=(2, 3, 4, 0.1, 0.2,
                                                       0.3)))
    assert approx_equal(sum(i_spatial), 21.306)
    assert approx_equal(
        spatial_lib.kinetic_energy(i_spatial=i_spatial,
                                   v_spatial=matrix.col((1, 2, 3, 4, 5, 6))),
        75.109)
    #
    mass_points = body_lib.mass_points(sites=matrix.col_list([
        (0.949, 2.815, 5.189), (0.405, 3.954, 5.917), (0.779, 5.262, 5.227)
    ]),
                                       masses=[2.34, 3.56, 1.58])
    assert approx_equal(mass_points.sum_of_masses(), 7.48)
    assert approx_equal(mass_points.center_of_mass(),
                        [0.654181818182, 3.87397058824, 5.54350802139])
    assert approx_equal(mass_points._sum_of_masses, 7.48)
    assert approx_equal(
        mass_points.inertia(pivot=matrix.col((0.9, -1.3, 0.4))), [
            404.7677928, 10.04129606, 10.09577652, 10.04129606, 199.7384559,
            -199.3511949, 10.09577652, -199.3511949, 206.8314171
        ])
Esempio n. 2
0
 def spatial_inertia(O, alignment_cb_0b=None):
   center_of_mass = O.center_of_mass()
   inertia = O.inertia(pivot=center_of_mass)
   if (alignment_cb_0b is not None):
     center_of_mass = alignment_cb_0b * center_of_mass
     inertia = alignment_cb_0b.r * inertia * alignment_cb_0b.r.transpose()
   return spatial_lib.mci(m=O._sum_of_masses, c=center_of_mass, i=inertia)
Esempio n. 3
0
def exercise_basic():
  assert approx_equal(sum(spatial_lib.xrot((1,2,3,4,5,6,7,8,9))), 90)
  assert approx_equal(sum(spatial_lib.xtrans((1,2,3))), 6)
  assert approx_equal(
    sum(spatial_lib.cb_as_spatial_transform(
      cb=matrix.rt(((1,2,3,4,5,6,7,8,9), (1,2,3))))), 90)
  assert approx_equal(sum(spatial_lib.crm((1,2,3,4,5,6))), 0)
  assert approx_equal(sum(spatial_lib.crf((1,2,3,4,5,6))), 0)
  i_spatial = spatial_lib.mci(
    m=1.234,
    c=matrix.col((1,2,3)),
    i=matrix.sym(sym_mat3=(2,3,4,0.1,0.2,0.3)))
  assert approx_equal(sum(i_spatial), 21.306)
  assert approx_equal(spatial_lib.kinetic_energy(
    i_spatial=i_spatial, v_spatial=matrix.col((1,2,3,4,5,6))), 75.109)
  #
  mass_points = body_lib.mass_points(
    sites=matrix.col_list([
      (0.949, 2.815, 5.189),
      (0.405, 3.954, 5.917),
      (0.779, 5.262, 5.227)]),
    masses=[2.34, 3.56, 1.58])
  assert approx_equal(mass_points.sum_of_masses(), 7.48)
  assert approx_equal(mass_points.center_of_mass(),
    [0.654181818182, 3.87397058824, 5.54350802139])
  assert approx_equal(mass_points._sum_of_masses, 7.48)
  assert approx_equal(
    mass_points.inertia(pivot=matrix.col((0.9,-1.3,0.4))),
    [404.7677928, 10.04129606, 10.09577652,
     10.04129606, 199.7384559, -199.3511949,
     10.09577652, -199.3511949, 206.8314171])
Esempio n. 4
0
 def spatial_inertia(O, alignment_cb_0b=None):
     center_of_mass = O.center_of_mass()
     inertia = O.inertia(pivot=center_of_mass)
     if (alignment_cb_0b is not None):
         center_of_mass = alignment_cb_0b * center_of_mass
         inertia = alignment_cb_0b.r * inertia * alignment_cb_0b.r.transpose(
         )
     return spatial_lib.mci(m=O._sum_of_masses, c=center_of_mass, i=inertia)