summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
51caa21)
Instead of doing some arcane calculation, do what the function is meant
to do: calculate an angle relative to another angle..
This also makes the code more robust in the case the calculation of the
other angles should change for some reason.
Leave the explicit formula in the comment as documentation.
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."""
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."""
- # The meaning of the formula regarding the index is the following:
+ # The explicit formula for this angle would be:
+ #
+ # pi + pi / 6 + (((self.index + 1) % 6) // 2) * pi * 2 / 3
+ #
+ # The meaning of the part regarding the index is the following:
# - rotate the indices by 1
# - group by 2 (because couples of triangles move together in the
# plan)
# - multiply the group by a rotation factor
# - rotate the indices by 1
# - group by 2 (because couples of triangles move together in the
# plan)
# - multiply the group by a rotation factor
- return pi + pi / 6 + (((self.index + 1) % 6) // 2) * pi * 2 / 3
+ #
+ # The explicit formula shows clearly that triangles move in groups of
+ # 2 in the plan.
+ #
+ # However, use an implicit form for robustness, so that if the other
+ # angle functions change this one can be left untouched.
+ return self.get_angle_in_hexagon() - self.get_angle_in_plan()
def get_angle_in_hexagon(self):
"""Get the angle of the triangle in the hexagons.
def get_angle_in_hexagon(self):
"""Get the angle of the triangle in the hexagons.