|
@ -48,6 +48,9 @@ def read_image(filename, path_steps, volume_percent, angle_d): |
|
|
p_max = [points[0][0], points[0][1]] |
|
|
p_max = [points[0][0], points[0][1]] |
|
|
|
|
|
|
|
|
# find center |
|
|
# find center |
|
|
|
|
|
dist_min = float('inf') |
|
|
|
|
|
dist_max = 0 |
|
|
|
|
|
p_prev = p_min |
|
|
for segment in path: |
|
|
for segment in path: |
|
|
p = [segment.end.real, segment.end.imag] |
|
|
p = [segment.end.real, segment.end.imag] |
|
|
for i in range(0, 2): |
|
|
for i in range(0, 2): |
|
@ -56,6 +59,15 @@ def read_image(filename, path_steps, volume_percent, angle_d): |
|
|
if p[i] > p_max[i]: |
|
|
if p[i] > p_max[i]: |
|
|
p_max[i] = p[i] |
|
|
p_max[i] = p[i] |
|
|
|
|
|
|
|
|
|
|
|
dist_curr = (p[0] - p_prev[0]) * (p[0] - p_prev[0]) |
|
|
|
|
|
dist_curr += (p[1] - p_prev[1]) * (p[1] - p_prev[1]) |
|
|
|
|
|
dist_curr = math.sqrt(dist_curr) |
|
|
|
|
|
p_prev = p |
|
|
|
|
|
if dist_curr > dist_max: |
|
|
|
|
|
dist_max = dist_curr |
|
|
|
|
|
if dist_curr < dist_min: |
|
|
|
|
|
dist_min = dist_curr |
|
|
|
|
|
|
|
|
p_center = [ p_min[0] + (p_max[0] - p_min[0] )/2 , p_min[1] + (p_max[1] - p_min[1] )/2] |
|
|
p_center = [ p_min[0] + (p_max[0] - p_min[0] )/2 , p_min[1] + (p_max[1] - p_min[1] )/2] |
|
|
|
|
|
|
|
|
# find min max for all rotatations |
|
|
# find min max for all rotatations |
|
@ -87,6 +99,7 @@ def read_image(filename, path_steps, volume_percent, angle_d): |
|
|
|
|
|
|
|
|
print("min={} max={}".format(p_min, p_max)) |
|
|
print("min={} max={}".format(p_min, p_max)) |
|
|
print("center={} ".format(p_center)) |
|
|
print("center={} ".format(p_center)) |
|
|
|
|
|
print("dist ={} ={} ".format(dist_min, dist_max)) |
|
|
|
|
|
|
|
|
data = bytearray() |
|
|
data = bytearray() |
|
|
|
|
|
|
|
|