def test_angles_flat(self): #left flat point_pair = xy_formulas.TwoPoints(0, 0, -10, 0) self.assertEqual(xy_formulas.angle_of(point_pair), 0) #right flat point_pair = xy_formulas.TwoPoints(0, 0, 10, 0) self.assertEqual(xy_formulas.angle_of(point_pair), 180)
def test_invalid_region_below_horizon2(self): point_pair = xy_formulas.TwoPoints(-5, 7, -10, -1) with self.assertRaises(ValueError): xy_formulas.angle_of(point_pair)
def test_same_point(self): point_pair = xy_formulas.TwoPoints(1, 1, 1, 1) with self.assertRaises(ValueError): xy_formulas.angle_of(point_pair)
def test_vertical(self): point_pair = xy_formulas.TwoPoints(1, 0, 1, 20) self.assertEqual(xy_formulas.angle_of(point_pair), 90)
def test_Fortyfive_angles(self): point_pair = xy_formulas.TwoPoints(0, 0, 10, 10) self.assertEqual(xy_formulas.angle_of(point_pair), 135) point_pair = xy_formulas.TwoPoints(0, 0, -10, 10) self.assertEqual(xy_formulas.angle_of(point_pair), 45)
import xy_formulas pivotX = 50 pivotY = -50 for x in range(-100, 200): points = xy_formulas.TwoPoints(pivotX, pivotY, x, 0) print(xy_formulas.angle_of(points), 'degrees, ', xy_formulas.distance_between_points(points), ' km')