@ -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
@ -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)
xxxxxxxxxx
xxxxxxxxxx