def flip_facing_h(unit: UnitStruct) -> None: """Mirrors the unit's facing across a horizontal axis (math.pi / 4.0).""" # Mods by tau because the scenario editor seems to place units facing # at radian angles not strictly less than tau. theta = get_facing(unit) % math.tau phi = util.flip_angle_h(theta) set_facing(unit, phi)
def test_flip_angle_h_8(): num_tests = 1000 for __ in range(num_tests): theta = random.uniform(0.0, math.tau) % math.tau double_flip = flip_angle_h(flip_angle_h(theta)) assert_almost_equal(theta, double_flip)
def test_flip_angle_h_7(): theta = 3.0 * math.pi / 2.0 phi = flip_angle_h(theta) expected = math.pi assert_almost_equal(expected, phi)
def test_flip_angle_h_5(): theta = 7.0 * math.pi / 4.0 phi = flip_angle_h(theta) expected = 3.0 * math.pi / 4.0 assert_almost_equal(expected, phi)
def test_flip_angle_h_2(): theta = math.pi / 2.0 phi = flip_angle_h(theta) expected = 0.0 assert_almost_equal(expected, phi)
def test_flip_angle_h_error1(): flip_angle_h(math.tau)
def test_flip_angle_h_error0(): flip_angle_h(-0.0000001)