aboutsummaryrefslogtreecommitdiff
path: root/diplomacy/utils/equilateral_triangle.py
diff options
context:
space:
mode:
Diffstat (limited to 'diplomacy/utils/equilateral_triangle.py')
-rw-r--r--diplomacy/utils/equilateral_triangle.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/diplomacy/utils/equilateral_triangle.py b/diplomacy/utils/equilateral_triangle.py
index d31fe79..6535665 100644
--- a/diplomacy/utils/equilateral_triangle.py
+++ b/diplomacy/utils/equilateral_triangle.py
@@ -16,15 +16,17 @@
# ==============================================================================
# pylint: disable=anomalous-backslash-in-string
""" Helper class to compute intersection of a line (OM) with a side of an equilateral triangle,
- with O the barycenter of the equilateral triangle and M a point outside the triangle.
- A
- / | M
- / O |
- C /______| B
-
- A = top, B = right, C = left
- O = center of triangle
- M = point outside of triangle
+ with O the barycenter of the equilateral triangle and M a point outside the triangle.::
+
+ A
+ / | M
+ / O |
+ C /______| B
+
+ A = top, B = right, C = left
+ O = center of triangle
+ M = point outside of triangle
+
"""
class EquilateralTriangle:
""" Helper class that represent an equilateral triangle.
@@ -53,6 +55,7 @@ class EquilateralTriangle:
def __line_om(self, x_m, y_m):
""" Returns the slope and the intersect of the line between O and M
+
:return: a, b - respectively the slope and the intercept of the line OM
"""
# pylint:disable=invalid-name
@@ -62,6 +65,7 @@ class EquilateralTriangle:
def _intersection_with_ab(self, x_m, y_m):
""" Return coordinates of intersection of line (OM) with line (AB).
+
:param x_m: x coordinate of M
:param y_m: y coordinate of M
:return: coordinates (x, y) of intersection, or (None, None) if either
@@ -85,6 +89,7 @@ class EquilateralTriangle:
def _intersection_with_ac(self, x_m, y_m):
""" Return coordinates of intersection of line (OM) with line (AC).
+
:param x_m: x coordinate of M
:param y_m: y coordinate of M
:return: coordinates (x, y) of intersection, or (None, None) if either
@@ -107,6 +112,7 @@ class EquilateralTriangle:
def _intersection_with_bc(self, x_m, y_m):
""" Return coordinates of intersection of line (OM) with line (BC).
NB: (BC) is an horizontal line.
+
:param x_m: x coordinate of M
:param y_m: y coordinate of M
:return: coordinates (x, y) of intersection, or (None, None) if either
@@ -129,6 +135,7 @@ class EquilateralTriangle:
""" Return coordinates of the intersection of (OM) with equilateral triangle,
with M the point with coordinates (x_m, y_m). Only the intersection with
the side of triangle near M is considered.
+
:param x_m: x coordinate of M
:param y_m: y coordinate of M
:return: a couple (x, y) of floating values.