Browse Source

added test for sin of rad value in the limits of one period of sin as well as corresponding functionality

remotes/origin/feature/feature-trigonometry
fdai7764 11 months ago
parent
commit
068330af98
  1. 4
      src/main/py/trigonometry.py
  2. 5
      src/test/py/test_trigonometry.py

4
src/main/py/trigonometry.py

@ -15,4 +15,6 @@ def rad2deg(radNumber):
return (radNumber * 180) / math.pi
def sin_approx_bhaskara(radNumber):
return radNumber
num = 16 * radNumber * (math.pi - radNumber)
denom = 5 * math.pow(math.pi, 2) - 4 * radNumber * (math.pi - radNumber)
return num/denom

5
src/test/py/test_trigonometry.py

@ -1,5 +1,6 @@
import unittest
from src.main.py.trigonometry import *
import math
class MyTestCase(unittest.TestCase):
@ -39,6 +40,10 @@ class MyTestCase(unittest.TestCase):
def test_sin_0_should_be_0(self):
self.assertEqual(sin_approx_bhaskara(0), 0)
def test_sin_quarter_pi_should_be_point707(self):
delta = sin_approx_bhaskara(0.25*math.pi) - 0.707
self.assertLess(delta, 0.01)
if __name__ == '__main__':
unittest.main()
Loading…
Cancel
Save