示例#1
0
 def _test_force_applied_lateral_to_center_of_mass_rotates_and_moves(self):
     x_offset = 2
     z_offset = -1
     degrees_at_offset = round(degrees(atan2(z_offset, x_offset)), 2)
     force = MutableForce(MutableOffsets(x_offset, 0, 0),
                          MutableOffsets(0, 0, z_offset))
     assert force.diff_yaw_of_force_to_pos() == 90
     assert round(force.delta_yaw, 2) == degrees_at_offset
     self.target.apply_global_force(force)
     pitch, yaw, roll = self.target.spin
     assert (round(pitch, 2), round(yaw, 2), round(roll, 2)) == \
            (0, round(degrees_at_offset / self.target.inertia, 2), 0)
示例#2
0
 def setup(self):
     self.ship_model = model_factory.manufacture("ship",
                                                 position=(10, 0, 10),
                                                 rotation=(0, 45, 0))
     self.target = MutableForce(MutableOffsets(-1, 0, -1),
                                MutableOffsets(0, 0, -1))
     self.ship_model.mutate_force_to_global(self.target)
示例#3
0
文件: base_model.py 项目: frlnx/melee
 def momentum_at(self, local_coordinates: MutableOffsets) -> MutableForce:
     local_coordinates = MutableOffsets(*local_coordinates)
     momentum = self._movement  # * self.mass
     momentum += self.tangent_momentum_at(local_coordinates)
     momentum_at = MutableForce(local_coordinates, momentum)
     return momentum_at
示例#4
0
文件: base_model.py 项目: frlnx/melee
 def apply_global_force(self, force: MutableForce):
     self.mutate_force_to_local(force)
     self.add_movement(*(force.translation_forces() / self.mass))
     self.add_spin(0, force.delta_yaw / self.inertia, 0)
示例#5
0
 def setup(self):
     self.ship_model = model_factory.manufacture("ship",
                                                 position=(10, 0, 10))
     self.target = MutableForce(MutableOffsets(9, 0, 9),
                                MutableOffsets(0, 0, -1))
     self.ship_model.mutate_force_to_local(self.target)
示例#6
0
 def test_force_applied_to_center_of_mass_translates(self):
     force = MutableForce(MutableOffsets(2, 0, 0), MutableOffsets(-1, 0, 0))
     self.target.apply_global_force(force)
     x, y, z = self.target.movement
     assert (round(x, 1), round(y, 1), round(z, 1)) == (-0.1, 0, 0)
示例#7
0
 def test_force_applied_to_center_of_mass_does_not_rotate(self):
     force = MutableForce(MutableOffsets(2, 0, 0), MutableOffsets(-1, 0, 0))
     self.target.apply_global_force(force)
     x, y, z = self.target.spin
     assert (round(x, 2), round(y, 2), round(z, 2)) == (0, 0, 0)