X-Git-Url: https://git.ao2.it/flexagon-toolkit.git/blobdiff_plain/0535503e3f96e135b9a478df1a9ea8ef7fd206d5..5f2e900515a64fe483569855b89f26abcc89a441:/src/flexagon/trihexaflexagon.py diff --git a/src/flexagon/trihexaflexagon.py b/src/flexagon/trihexaflexagon.py index d79875e..e3aab5c 100755 --- a/src/flexagon/trihexaflexagon.py +++ b/src/flexagon/trihexaflexagon.py @@ -39,19 +39,19 @@ class Triangle(object): def get_angle_in_plan(self): """The angle of a triangle in the hexaflexagon plan.""" - return - ((self.index + 1) % 2) * pi / 3. + return - ((self.index) % 2) * pi / 3. def get_angle_in_plan_relative_to_hexagon(self): """"Get the angle of the triangle in the plan relative to the rotation of the same triangle in the hexagon.""" - return ((self.index + 4) % 6 // 2) * pi * 2. / 3. + return ((self.index + 5) % 6 // 2) * pi * 2 / 3 - pi / 6 def get_angle_in_hexagon(self): """Get the angle of the triangle in the hexagons. NOTE: the angle is rotated by pi to have the first triangle with the base on the bottom.""" - return pi + self.index * pi / 3. + return pi + pi / 6. + self.index * pi / 3. def __str__(self): return "%d,%d" % (self.hexagon.index, self.index) @@ -88,8 +88,8 @@ class TriHexaflexagon(object): # a pair (h, t), where 'h' is the index of the hexagon, and 't' is the # index of the triangle in that hexagon. plan_map = [ - [(0, 0), (1, 5), (1, 4), (2, 3), (2, 2), (0, 3), (0, 2), (1, 1), (1, 0)], - [(2, 5), (2, 4), (0, 5), (0, 4), (1, 3), (1, 2), (2, 1), (2, 0), (0, 1)] + [(0, 5), (1, 4), (1, 3), (2, 2), (2, 1), (0, 2), (0, 1), (1, 0), (1, 5)], + [(2, 4), (2, 3), (0, 4), (0, 3), (1, 2), (1, 1), (2, 0), (2, 5), (0, 0)] ] # Preallocate a bi-dimensional array for an inverse mapping, this is