Fundamental Polygon in Python
First thing first, make config a named tuple. This would seriously improve readability, and obviate the (really unclear) comment.
Factored out the repeated code into a function, e.g.:

def wraparound(coord, matching, twist):
    if 0 &lt; self.location[coord] &lt; self.dimension[coord]:
        return
    if twist:
        self.location[1 - coord] *= -1
    if matching:
        self.location = self.location[::-1]
        self.direction = self.direction[::-1]