def dashed_line(self, coordinates, dash_length, dash_width ):
#estimate the curve length to generate a segment count which will approximate the
# desired dash length
est_curve_len = (self.vector_len(coordinates[:,2] - coordinates[:,0] ) +
self.vector_len(coordinates[:,1] - coordinates[:,0] ) +
self.vector_len(coordinates[:,2] - coordinates[:,1] ) )/2
segments = int(est_curve_len/dash_length)
if self.debug:
print(est_curve_len)
print(segments)
x, y = bezier_curve(coordinates[0, :],
coordinates[1, :], segments)
dash_line = np.array([x, y])
if self.debug:
print('dashed line center coordinates')
print(dash_line[:,:self.debug])
#initializing empty indices
rrr = np.empty(0, dtype=int)
ccc = np.empty(0, dtype=int)
for dash in range( int(segments/2) ):
offset = .5*dash_width * self.perpendicular(dash_line[:,dash*2]-dash_line[:,dash*2+1])
d_path = np.array( [ dash_line[:,dash*2] + offset,
dash_line[:,dash*2 +1] + offset,
dash_line[:,dash*2 +1] - offset,
dash_line[:,dash*2] - offset,
dash_line[:,dash*2] + offset] )
dd_path = self.xz_to_xy(np.array([d_path[:, 0], d_path[:, 1] ]) )
rr, cc = polygon(dd_path.astype(int)[1], dd_path.astype(int)[0],
(self.view_res[0], self.view_res[1]) )
rrr = np.append(rrr, rr)
ccc = np.append(ccc, cc)
return rrr, ccc
#Makes randomly shaped polygon noise to screw with the learning algorithm
评论列表
文章目录