diff --git a/src/main/py/trigonometry.py b/src/main/py/trigonometry.py index 3bfddac..a2616b8 100644 --- a/src/main/py/trigonometry.py +++ b/src/main/py/trigonometry.py @@ -15,7 +15,7 @@ def rad2deg(radNumber): return (radNumber * 180) / math.pi def deg2rad(degNumber): - return degNumber + return (degNumber * math.pi) / 180 def sin_approx_bhaskara(radNumber): shallFlipTheResult = False #the bhaskara function can only be used between zero and pi. For the rest of the sin period I simply mirrored the first arch of the curve to match the actual sine wave diff --git a/src/test/py/test_trigonometry.py b/src/test/py/test_trigonometry.py index 9045e49..3a347d4 100644 --- a/src/test/py/test_trigonometry.py +++ b/src/test/py/test_trigonometry.py @@ -40,6 +40,12 @@ class MyTestCase(unittest.TestCase): def test_0_deg_to_rad_should_be_0(self): self.assertEqual(deg2rad(0), 0) + def test_360_deg_to_rad_should_be_2pi(self): + delta = deg2rad(360) - math.pi*2 + if delta < 0: + delta *= -1 + self.assertLess(delta, 0.01) + def test_sin_0_should_be_0(self): self.assertEqual(sin_approx_bhaskara(0), 0)