mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-12 07:41:55 +02:00
Move Segment to vector.
This commit is contained in:
parent
67c2d98917
commit
0f9a4798f2
3 changed files with 21 additions and 21 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue