-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedge.py
More file actions
33 lines (24 loc) · 840 Bytes
/
edge.py
File metadata and controls
33 lines (24 loc) · 840 Bytes
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
import math
class Edge:
def __init__(self, minYVert, maxYVert):
self.yStart = int(math.ceil(minYVert.get_y()))
self.yEnd = int(math.ceil(maxYVert.get_y()))
self.xStart = int(math.ceil(minYVert.get_x()))
self.xEnd = int(math.ceil(maxYVert.get_x()))
self.xStep = 0
yDist = maxYVert.get_y() - minYVert.get_y()
xDist = maxYVert.get_x() - minYVert.get_x()
yPreStep = self.yStart - minYVert.get_y()
if yDist <= 0.0:
self.xStep = self.xStep
else:
self.xStep = xDist/yDist
self.x = self.xStart + yPreStep * self.xStep
def step(self):
self.x += self.xStep
def get_x(self):
return self.x
def get_y_start(self):
return int(self.yStart)
def get_y_end(self):
return int(self.yEnd)