Compare commits

..

No commits in common. "94a1b3d7937f8ffdfc83f7614c98dcb420ce3cb8" and "73193473df1e4ff31eb6bbb7ea031d982e619c69" have entirely different histories.

View File

@ -20,7 +20,7 @@ class Polygon(Shape):
A polygon, consisting of a bunch of vertices (Nx2 ndarray) which specify an A polygon, consisting of a bunch of vertices (Nx2 ndarray) which specify an
implicitly-closed boundary, and an offset. implicitly-closed boundary, and an offset.
Note that the setter for `Polygon.vertices` creates a copy of the Note that the setter for `Polygon.vertices` may creates a copy of the
passed vertex coordinates. passed vertex coordinates.
A `normalized_form(...)` is available, but can be quite slow with lots of vertices. A `normalized_form(...)` is available, but can be quite slow with lots of vertices.
@ -379,9 +379,8 @@ class Polygon(Shape):
def normalized_form(self, norm_value: float) -> normalized_shape_tuple: def normalized_form(self, norm_value: float) -> normalized_shape_tuple:
# Note: this function is going to be pretty slow for many-vertexed polygons, relative to # Note: this function is going to be pretty slow for many-vertexed polygons, relative to
# other shapes # other shapes
meanv = self.vertices.mean(axis=0) offset = self.vertices.mean(axis=0) + self.offset
zeroed_vertices = self.vertices - meanv zeroed_vertices = self.vertices - offset
offset = meanv + self.offset
scale = zeroed_vertices.std() scale = zeroed_vertices.std()
normed_vertices = zeroed_vertices / scale normed_vertices = zeroed_vertices / scale