-
Notifications
You must be signed in to change notification settings - Fork 0
/
planner.py
executable file
·45 lines (35 loc) · 1.16 KB
/
planner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from dataclasses import dataclass
from typing import List
from collections import namedtuple
Margins = namedtuple('Margins', ['top', 'bottom', 'left', 'right'])
@dataclass
class Point:
x: float
y: float
def scaled(self, scale):
return (int(self.x/scale), int(self.y/scale))
@dataclass
class Objective:
width: float
height: float
margins: Margins
@property
def move_x(self) -> float:
return round(self.width - (self.margins.left * self.width) - (self.margins.right * self.width), 2)
@property
def move_y(self) -> float:
return round(self.height - (self.margins.top * self.height) - (self.margins.bottom * self.height), 2)
class Plan:
def __init__(self, objective, overlap=0.3, res=Point):
self.obj = objective
self.overlap = overlap
self.res = res
@property
def step_x(self):
overlap = self.obj.move_x * self.overlap
step_x = round(self.obj.move_x - overlap, 2)
return step_x
@property
def step_y(self):
overlap = self.obj.move_y * self.overlap
return round(self.obj.move_y - overlap, 2)