Move Segment to vector.

This commit is contained in:
Sergey Vartanov 2021-12-14 08:25:50 +03:00
parent 67c2d98917
commit 0f9a4798f2
3 changed files with 21 additions and 21 deletions

View file

@ -232,23 +232,3 @@ class DirectionSector(Tagged):
fill=gradient.get_funciri(),
)
svg.add(path_element)
class Segment:
"""Closed line segment."""
def __init__(self, point_1: np.ndarray, point_2: np.ndarray) -> None:
self.point_1: np.ndarray = point_1
self.point_2: np.ndarray = point_2
difference: np.ndarray = point_2 - point_1
vector: np.ndarray = difference / np.linalg.norm(difference)
self.angle: float = (
np.arccos(np.dot(vector, np.array((0.0, 1.0)))) / np.pi
)
def __lt__(self, other: "Segment") -> bool:
return (
((self.point_1 + self.point_2) / 2.0)[1]
< ((other.point_1 + other.point_2) / 2.0)[1]
) # fmt: skip