Преглед изворни кода

add distance calculation of points for future improved interpolation

phschoen пре 3 месеци
родитељ
комит
5917fe41c3
1 измењених фајлова са 13 додато и 0 уклоњено
  1. 13
    0
      render.py

+ 13
- 0
render.py Прегледај датотеку

@@ -48,6 +48,9 @@ def read_image(filename, path_steps, volume_percent, angle_d):
48 48
     p_max = [points[0][0], points[0][1]]
49 49
 
50 50
     # find center
51
+    dist_min = float('inf')
52
+    dist_max = 0
53
+    p_prev = p_min
51 54
     for segment in path:
52 55
         p = [segment.end.real, segment.end.imag]
53 56
         for i in range(0, 2):
@@ -56,6 +59,15 @@ def read_image(filename, path_steps, volume_percent, angle_d):
56 59
             if p[i] > p_max[i]:
57 60
                 p_max[i] = p[i]
58 61
 
62
+        dist_curr  = (p[0] - p_prev[0]) * (p[0] - p_prev[0])
63
+        dist_curr += (p[1] - p_prev[1]) * (p[1] - p_prev[1])
64
+        dist_curr  = math.sqrt(dist_curr)
65
+        p_prev = p
66
+        if dist_curr > dist_max:
67
+            dist_max = dist_curr
68
+        if dist_curr < dist_min:
69
+            dist_min = dist_curr
70
+
59 71
     p_center = [ p_min[0] + (p_max[0] - p_min[0] )/2  ,  p_min[1] + (p_max[1] - p_min[1] )/2]
60 72
 
61 73
     # find min max for all rotatations
@@ -87,6 +99,7 @@ def read_image(filename, path_steps, volume_percent, angle_d):
87 99
 
88 100
     print("min={} max={}".format(p_min, p_max))
89 101
     print("center={} ".format(p_center))
102
+    print("dist ={} ={} ".format(dist_min, dist_max))
90 103
 
91 104
     data = bytearray()
92 105
 

Loading…
Откажи
Сачувај