Beispiel #1
0
    def test_sin(self):
        """
        Test case for  testing sin method
        :return:nothing
        """

        self.assertEqual(0.8414709848078965, MathOperation.sin(1.0))
Beispiel #2
0
 def get_length(radius):
     """
     This static method calculates the length based on the value of alpha
     :param radius:
     :return:float length
     """
     Solution.set_alpha()
     return 2.0 * radius * (1.0 -
                            MathOperation.cos(Solution.get_alpha() / 2))
Beispiel #3
0
 def alpha():
     """
     This static method calculates the value of alpha
     :return:nothing
     """
     alpha = 2
     precision = 6
     pi = MathOperation.pi()
     calculated_decimal_places = 1
     for itr in range(0, precision):
         original = alpha - MathOperation.sin(alpha) - pi / 2
         prime = 1.0 - MathOperation.cos(alpha)
         alpha = alpha - (original / prime)
         if itr >= 1:
             calculated_decimal_places += 3 * (2**(itr - 1))
             if calculated_decimal_places > precision:
                 break
     return alpha
Beispiel #4
0
 def test_pi(self):
     """
     Test case for testing pi method
     :return:nothing
     """
     self.assertEqual(3.141592653589793, MathOperation.pi())
Beispiel #5
0
 def test_cos_negative_value(self):
     """
     Test case for testing cos method against negative value
     :return:nothing
     """
     self.assertEqual(0.5403023058681398, MathOperation.cos(-1.0))
Beispiel #6
0
 def test_cos(self):
     """
     Test case for testing cos method
     :return:nothing
     """
     self.assertEqual(0.5403023058681398, MathOperation.cos(1.0))
Beispiel #7
0
 def test_negative_sin(self):
     """
     Test Case for testing sin method against a negative value
     :return:nothing
     """
     self.assertEqual(-0.8414709848078965, MathOperation.sin(-1.0))