Browse Source

added test for conversion of 360 degrees to radians as well as corresponding functionality

remotes/origin/feature/feature-trigonometry
fdai7764 12 months ago
parent
commit
ccd7bc3b2e
  1. 2
      src/main/py/trigonometry.py
  2. 6
      src/test/py/test_trigonometry.py

2
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

6
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)

|||||||
100:0
Loading…
Cancel
Save