Ejemplo n.º 1
0
    def test_indexing(self):
        node = OccupancyOctoNode()
        # Assuming node with dimension 2 and origin 0,0,0
        origin = (0,0,0)

        self.assertEqual( node.index( origin, origin, 2 ), 0 )

        self.assertEqual( node.index( ( 0.5, 0.5, 0.5 ), origin, 2), 0 )
        self.assertEqual( node.index( ( 0, 0.5, 0.5 ), origin, 2), 0 )
        self.assertEqual( node.index( ( 0.5, 0, 0.5 ), origin, 2), 0 )
        self.assertEqual( node.index( ( 0.5, 0.5, 0 ), origin, 2), 0 )

        self.assertEqual( node.index( ( 1.5, 0.5, 0.5 ), origin, 2), 1 )
        self.assertEqual( node.index( ( 1, 0, 0 ), origin, 2), 1 )

        self.assertEqual( node.index( ( 0.5, 1.5, 0.5 ), origin, 2 ), 2)
        self.assertEqual( node.index( ( 0, 1, 0 ), origin, 2 ), 2)

        self.assertEqual( node.index( ( 1.5, 1.5, 0.5 ), origin, 2), 3 )
        self.assertEqual( node.index( ( 1, 1, 0 ), origin, 2), 3 )

        self.assertEqual( node.index( ( 0.5, 0.5, 1.5 ), origin, 2), 4 )
        self.assertEqual( node.index( ( 0, 0, 1 ), origin, 2), 4 )

        self.assertEqual( node.index( ( 1.5, 0.5, 1.5 ), origin, 2), 5 )
        self.assertEqual( node.index( ( 1, 0, 1 ), origin, 2), 5 )

        self.assertEqual( node.index( ( 0.5, 1.5, 1.5 ), origin, 2), 6 )
        self.assertEqual( node.index( ( 0, 1, 1 ), origin, 2), 6 )

        self.assertEqual( node.index( ( 1.5, 1.5, 1.5 ), origin, 2), 7 )
        self.assertEqual( node.index( ( 1, 1, 1 ), origin, 2), 7 )