@@ -19,7 +19,7 @@ class Polygon2(object):
1919 index to the larger index will walk clockwise around the polygon.
2020
2121 .. note::
22-
22+
2323 Polygons should be used as if they were completely immutable to
2424 ensure correctness. All attributes of Polygon2 can be reconstructed
2525 from the points array, and thus cannot be changed on their own and
@@ -205,9 +205,9 @@ def from_regular(cls, sides, length, start_rads = None, start_degs = None, cente
205205
206206 Finally, each vertex is found using ``<radius * cos(angle), radius * sin(angle)>``
207207
208- If the center is not specified, the bounding box of the polygon is calculated while the vertices
209- are being found, and the center of the bounding box is set to the center of the circle. This
210- is never greater than (circumradius, circumradius).
208+ If the center is not specified, the minimum of the bounding box of the
209+ polygon is calculated while the vertices are being found, and the inverse
210+ of that value is offset to the rest of the points in the polygon.
211211
212212 :param sides: the number of sides in the polygon
213213 :type sides: :class:`numbers.Number`
@@ -251,8 +251,6 @@ def from_regular(cls, sides, length, start_rads = None, start_degs = None, cente
251251 pts = []
252252 _minx = 0
253253 _miny = 0
254- _maxx = 0
255- _maxy = 0
256254 for i in range (sides ):
257255 x = center .x + math .cos (angle ) * radius
258256 y = center .y + math .sin (angle ) * radius
@@ -262,13 +260,11 @@ def from_regular(cls, sides, length, start_rads = None, start_degs = None, cente
262260 if _recenter :
263261 _minx = min (_minx , x )
264262 _miny = min (_miny , y )
265- _maxx = max (_maxx , x )
266- _maxy = max (_maxy , y )
267263
268264 if _recenter :
269- _newcenter = vector2 .Vector2 (( _maxx - _minx ) / 2 , ( _maxy - _miny ) / 2 )
265+ _offset = vector2 .Vector2 (- _minx , - _miny )
270266 for i in range (sides ):
271- pts [i ] += _newcenter
267+ pts [i ] += _offset
272268
273269 return cls (pts , suppress_errors = True )
274270
@@ -407,8 +403,8 @@ def contains_point(polygon, offset, point):
407403 :type offset: :class:`pygorithm.geometry.vector2.Vector2` or None
408404 :param point: the point to check
409405 :type point: :class:`pygorithm.geometry.vector2.Vector2`
410- :returns: ( on edge, contained)
411- :rtype: ( bool, bool)
406+ :returns: on edge, contained
407+ :rtype: bool, bool
412408 """
413409
414410 _previous = polygon .points [0 ]
@@ -520,7 +516,7 @@ def _create_link(pts):
520516 :type pts: list of :class:`pygorithm.geometry.vector2.Vector2`
521517 """
522518
523- param0 = "+" .join (('%28{}%2C+{}%29' .format (v .x , v .y )) for v in pts )
519+ param0 = "+" .join (('%28{}%2C+{}%29' .format (round ( v .x , 3 ), round ( v .y , 3 ) )) for v in pts )
524520 xmin = pts [0 ].x
525521 xmax = xmin
526522 ymin = pts [1 ].y
0 commit comments