@@ -177,8 +177,10 @@ def _enforce_symmetry(self) -> None:
177177 p2 .x = - p1 .x
178178 p2 .y = - p1 .y
179179
180- if count % 2 != 0 :
180+ if count % 2 : # Odd number of points.
181181 self .points [int (count / 2 )] = Point2D (0.0 , 0.0 )
182+ else :
183+ self .points .insert (int (count / 2 ), Point2D (0.0 , 0.0 ))
182184
183185 def _default_points (self ) -> CoordinateList :
184186 return [(- 1.0 , - 1.0 ), (1.0 , 1.0 )]
@@ -254,8 +256,11 @@ def _enforce_symmetry(self) -> None:
254256 p2 .x = - p1 .x
255257 p2 .y = - p1 .y
256258
257- if count % 2 != 0 :
259+ if count % 2 : # Odd number of points.
258260 self .points [int (count / 2 )] = Point2D (0.0 , 0.0 )
261+ else :
262+ self .points .insert (int (count / 2 ), Point2D (0.0 , 0.0 ))
263+ self .z .insert (int (count / 2 ), 0.0 )
259264
260265 def fit (self ) -> None :
261266 """Computes the second derivatives for the control points."""
@@ -408,8 +413,15 @@ def _enforce_symmetry(self) -> None:
408413 if cp1 .handle_right is not None :
409414 cp2 .handle_left = cp2 .center - (cp1 .handle_right - cp1 .center )
410415
411- if count % 2 != 0 :
416+ if count % 2 : # Odd number of points.
412417 self ._control_points [int (count / 2 )].center = Point2D (0.0 , 0.0 )
418+ else :
419+ self ._control_points .insert (
420+ int (count / 2 ),
421+ CubicBezierSpline .ControlPoint (
422+ Point2D (0 , 0 ), Point2D (- 0.05 , 0 ), Point2D (+ 0.05 , 0 )
423+ ),
424+ )
413425
414426 def _default_points (self ) -> CoordinateList :
415427 return [(- 1.0 , - 1.0 ), (- 0.95 , - 0.95 ), (0.95 , 0.95 ), (1.0 , 1.0 )]
0 commit comments