[Path / Polygon] improve normalized_form approach to follow documented order
This commit is contained in:
parent
25b8fe8448
commit
5d20a061fd
2 changed files with 18 additions and 10 deletions
|
|
@ -449,11 +449,15 @@ class Path(Shape):
|
||||||
for v in normed_vertices])
|
for v in normed_vertices])
|
||||||
|
|
||||||
# Reorder the vertices so that the one with lowest x, then y, comes first.
|
# Reorder the vertices so that the one with lowest x, then y, comes first.
|
||||||
x_min = rotated_vertices[:, 0].argmin()
|
x_min_val = rotated_vertices[:, 0].min()
|
||||||
if not is_scalar(x_min):
|
x_min_inds = numpy.where(rotated_vertices[:, 0] == x_min_val)[0]
|
||||||
y_min = rotated_vertices[x_min, 1].argmin()
|
if x_min_inds.size > 1:
|
||||||
x_min = cast('Sequence', x_min)[y_min]
|
y_min_val = rotated_vertices[x_min_inds, 1].min()
|
||||||
reordered_vertices = numpy.roll(rotated_vertices, -x_min, axis=0)
|
tie_breaker = numpy.where(rotated_vertices[x_min_inds, 1] == y_min_val)[0][0]
|
||||||
|
start_ind = x_min_inds[tie_breaker]
|
||||||
|
else:
|
||||||
|
start_ind = x_min_inds[0]
|
||||||
|
reordered_vertices = numpy.roll(rotated_vertices, -start_ind, axis=0)
|
||||||
|
|
||||||
width0 = self.width / norm_value
|
width0 = self.width / norm_value
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -417,11 +417,15 @@ class Polygon(Shape):
|
||||||
for v in normed_vertices])
|
for v in normed_vertices])
|
||||||
|
|
||||||
# Reorder the vertices so that the one with lowest x, then y, comes first.
|
# Reorder the vertices so that the one with lowest x, then y, comes first.
|
||||||
x_min = rotated_vertices[:, 0].argmin()
|
x_min_val = rotated_vertices[:, 0].min()
|
||||||
if not is_scalar(x_min):
|
x_min_inds = numpy.where(rotated_vertices[:, 0] == x_min_val)[0]
|
||||||
y_min = rotated_vertices[x_min, 1].argmin()
|
if x_min_inds.size > 1:
|
||||||
x_min = cast('Sequence', x_min)[y_min]
|
y_min_val = rotated_vertices[x_min_inds, 1].min()
|
||||||
reordered_vertices = numpy.roll(rotated_vertices, -x_min, axis=0)
|
tie_breaker = numpy.where(rotated_vertices[x_min_inds, 1] == y_min_val)[0][0]
|
||||||
|
start_ind = x_min_inds[tie_breaker]
|
||||||
|
else:
|
||||||
|
start_ind = x_min_inds[0]
|
||||||
|
reordered_vertices = numpy.roll(rotated_vertices, -start_ind, axis=0)
|
||||||
|
|
||||||
# TODO: normalize mirroring?
|
# TODO: normalize mirroring?
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue