Пример #1
0
    def testRot2D(self):
        """Test rot2D
        """
        def pvtIter():
            for pos in (5, -3):
                for vel in (0.1, 0, -0.3):
                    for tai in (500, 999):
                        yield coordConv.PVT(pos, vel, tai)

        for fromPVTX in pvtIter():
            for fromPVTY in pvtIter():
                for ang in (0, 21, -75.5):
                    for rotTAI in (fromPVTX.t - 200, fromPVTX.t + 5000):
                        toPVTX = coordConv.PVT()
                        toPVTY = coordConv.PVT()
                        coordConv.rot2D(toPVTX, toPVTY, fromPVTX, fromPVTY, ang, rotTAI)

                        for testTAI in (rotTAI, rotTAI + 1010):
                            fromX = fromPVTX.getPos(testTAI)
                            fromY = fromPVTY.getPos(testTAI)
                            predToX, predToY = coordConv.rot2D(fromX, fromY, ang)
                            self.assertAlmostEqual(predToX, toPVTX.getPos(testTAI))
                            self.assertAlmostEqual(predToY, toPVTY.getPos(testTAI))
Пример #2
0
 def testRot2D(self):
     """Test rot2D using various obvious values
     """
     invSqrt2 = 1.0 / math.sqrt(2)
     for inArgs, predOut in (
         ((1, 0, 0), (1, 0)),
         ((1, 0, 90), (0, 1)),
         ((1, 0, -90), (0, -1)),
         ((1, 0, 180), (-1, 0)),
         ((1, 0, -180), (-1, 0)),
         ((1, 0, 45), (invSqrt2, invSqrt2)),
         ((1, 0, -45), (invSqrt2, -invSqrt2)),
         ((1.2345e67, 0, -45), (1.2345e67 * invSqrt2, -1.2345e67 * invSqrt2)),
         ((0, 1, 0), (0, 1)),
         ((0, 1, 90), (-1, 0)),
         ((0, 1, -90), (1, 0)),
         ((0, 1, 180), (0, -1)),
         ((0, 1, -180), (0, -1)),
         ((0, 1, 45), (-invSqrt2, invSqrt2)),
         ((0, 1, -45), (invSqrt2, invSqrt2)),
         ((0, 1.2345e67, -45), (1.2345e67 * invSqrt2, 1.2345e67 * invSqrt2)),
     ):
         out = coordConv.rot2D(*inArgs)
         self.assertTrue(numpy.allclose(out, predOut))