def posveldelta_trs_s(): """""" ref_pos = position.PosVel(np.random.random((6, )) * 6.3e6, system="trs") return position.PosVelDelta(np.random.random((6, )), system="trs", ref_pos=ref_pos)
def test_math(): _pos = position.Position([[1, 2, 3], [4, 5, 6], [7, 8, 9]], system="trs") _pos2 = position.Position([[1, 1, 1], [2, 2, 2], [3, 3, 3]], system="trs") _posdelta = position.PositionDelta( [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9]], system="trs", ref_pos=_pos) _posdelta2 = position.PositionDelta( [[0.1, 0.1, 0.1], [0.4, 0.4, 0.4], [0.7, 0.7, 0.7]], system="trs", ref_pos=_pos) _posvel = position.PosVel([1, 2, 3, 0.1, 0.2, 0.3], system="trs") _posvel2 = position.PosVel([1, 1, 1, 0.1, 0.1, 0.1], system="trs") _posveldelta = position.PosVelDelta([0.1, 0.2, 0.3, 0.01, 0.02, 0.03], system="trs", ref_pos=_posvel) _posveldelta2 = position.PosVelDelta([0.1, 0.1, 0.1, 0.01, 0.01, 0.01], system="trs", ref_pos=_posvel) # Positions new_pos = _pos + _posdelta np.testing.assert_almost_equal(new_pos[0].val, [1.1, 2.2, 3.3]) assert new_pos.cls_name == "PositionArray" new_pos = _posdelta + _pos np.testing.assert_almost_equal(new_pos[0].val, [1.1, 2.2, 3.3]) assert new_pos.cls_name == "PositionArray" new_pos2 = _pos - _pos2 np.testing.assert_almost_equal(new_pos2.val, [[0, 1, 2], [2, 3, 4], [4, 5, 6]]) assert new_pos2.cls_name == "PositionDeltaArray" new_pos3 = _pos - _posdelta np.testing.assert_almost_equal(new_pos3[0].val, [0.9, 1.8, 2.7]) assert new_pos3.cls_name == "PositionArray" new_pos3 = _posdelta - _pos np.testing.assert_almost_equal(new_pos3[0].val, [-0.9, -1.8, -2.7]) assert new_pos3.cls_name == "PositionArray" new_posdelta = _posdelta - _posdelta2 np.testing.assert_almost_equal( new_posdelta.val, [[0, 0.1, 0.2], [0, 0.1, 0.2], [0, 0.1, 0.2]]) assert new_posdelta.cls_name == "PositionDeltaArray" # PosVels new_posvel = _posvel + _posveldelta np.testing.assert_almost_equal(new_posvel.val, [1.1, 2.2, 3.3, 0.11, 0.22, 0.33]) assert new_posvel.cls_name == "PosVelArray" new_posvel = _posveldelta + _posvel np.testing.assert_almost_equal(new_posvel.val, [1.1, 2.2, 3.3, 0.11, 0.22, 0.33]) assert new_posvel.cls_name == "PosVelArray" new_posvel2 = _posvel - _posvel2 np.testing.assert_almost_equal(new_posvel2.val, [0, 1, 2, 0, 0.1, 0.2]) assert new_posvel2.cls_name == "PosVelDeltaArray" new_posvel3 = _posvel - _posveldelta np.testing.assert_almost_equal(new_posvel3.val, [0.9, 1.8, 2.7, 0.09, 0.18, 0.27]) assert new_posvel3.cls_name == "PosVelArray" new_posvel3 = _posveldelta - _posvel np.testing.assert_almost_equal(new_posvel3.val, [-0.9, -1.8, -2.7, -0.09, -0.18, -0.27]) assert new_posvel3.cls_name == "PosVelArray" new_posveldelta = _posveldelta - _posveldelta2 np.testing.assert_almost_equal(new_posveldelta.val, [0, 0.1, 0.2, 0, 0.01, 0.02]) assert new_posveldelta.cls_name == "PosVelDeltaArray"