def testRightTriangle(self):
     """
     right triangle: B = 90, a and c vary but avoid poles
     tan C = tan c / sin a
     tan c = (tan a / sinA * sinb)
     with some tweaks to handle the other quadrants
     """
     ang_B = 90.0
     for side_aa in (1.0, 20.0, 45.0, 90, 110.0, 179.0):
         for side_cc in (1.0, 20.0, 45.0, 90.0, 110.0, 179.0):
             ang_A = atan2d(tand(side_aa), sind(side_cc))
             ang_C = atan2d(tand(side_cc), sind(side_aa))
             side_bb = atan2d(tand(side_aa), sind(ang_A) * cosd(side_cc))
             # these tweaks handle other quadrants; they're based on what works, so are somewhat suspect
             if side_bb < 0:
                 side_bb = -side_bb
             if ang_A < 0:
                 ang_A = 180.0 + ang_A
             if ang_C < 0:
                 ang_C = 180.0 + ang_C
             self.checkOne((side_aa, ang_B, side_cc),
                           (ang_A, side_bb, ang_C))
Example #2
0
 def testTrig(self):
     """Test degrees-based trig functions
     """
     for ang in (0, -1, 31.2, -235, 234324):
         angRad = ang * coordConv.RadPerDeg
         self.assertAlmostEqual(coordConv.sind(ang), math.sin(angRad))
         self.assertAlmostEqual(coordConv.cosd(ang), math.cos(angRad))
         self.assertAlmostEqual(coordConv.tand(ang), math.tan(angRad))
         self.assertAlmostEqual(coordConv.atand(ang) * coordConv.RadPerDeg, math.atan(ang))
         for ang2 in (0, 35, -364):
             self.assertAlmostEqual(coordConv.atan2d(ang, ang2) * coordConv.RadPerDeg, math.atan2(ang, ang2))
     
     for val in (-1, -0.34, 0, 0.67, 1):
         self.assertAlmostEqual(coordConv.asind(val) * coordConv.RadPerDeg, math.asin(val))
         self.assertAlmostEqual(coordConv.acosd(val) * coordConv.RadPerDeg, math.acos(val))