Make sure linspace gets an integer number of points
This commit is contained in:
parent
89bd1e6abe
commit
0fa073b488
@ -212,8 +212,9 @@ class Arc(Shape):
|
|||||||
n += [poly_num_points]
|
n += [poly_num_points]
|
||||||
if poly_max_arclen is not None:
|
if poly_max_arclen is not None:
|
||||||
n += [perimeter / poly_max_arclen]
|
n += [perimeter / poly_max_arclen]
|
||||||
thetas_inner = numpy.linspace(a_ranges[0][1], a_ranges[0][0], max(n), endpoint=True)
|
num_points = int(round(max(n)))
|
||||||
thetas_outer = numpy.linspace(a_ranges[1][0], a_ranges[1][1], max(n), endpoint=True)
|
thetas_inner = numpy.linspace(a_ranges[0][1], a_ranges[0][0], num_points, endpoint=True)
|
||||||
|
thetas_outer = numpy.linspace(a_ranges[1][0], a_ranges[1][1], num_points, endpoint=True)
|
||||||
|
|
||||||
sin_th_i, cos_th_i = (numpy.sin(thetas_inner), numpy.cos(thetas_inner))
|
sin_th_i, cos_th_i = (numpy.sin(thetas_inner), numpy.cos(thetas_inner))
|
||||||
sin_th_o, cos_th_o = (numpy.sin(thetas_outer), numpy.cos(thetas_outer))
|
sin_th_o, cos_th_o = (numpy.sin(thetas_outer), numpy.cos(thetas_outer))
|
||||||
|
@ -81,7 +81,8 @@ class Circle(Shape):
|
|||||||
n += [poly_num_points]
|
n += [poly_num_points]
|
||||||
if poly_max_arclen is not None:
|
if poly_max_arclen is not None:
|
||||||
n += [2 * pi * self.radius / poly_max_arclen]
|
n += [2 * pi * self.radius / poly_max_arclen]
|
||||||
thetas = numpy.linspace(2 * pi, 0, max(n), endpoint=False)
|
num_points = int(round(max(n)))
|
||||||
|
thetas = numpy.linspace(2 * pi, 0, num_points, endpoint=False)
|
||||||
xs = numpy.cos(thetas) * self.radius
|
xs = numpy.cos(thetas) * self.radius
|
||||||
ys = numpy.sin(thetas) * self.radius
|
ys = numpy.sin(thetas) * self.radius
|
||||||
xys = numpy.vstack((xs, ys)).T
|
xys = numpy.vstack((xs, ys)).T
|
||||||
|
@ -139,7 +139,8 @@ class Ellipse(Shape):
|
|||||||
n += [poly_num_points]
|
n += [poly_num_points]
|
||||||
if poly_max_arclen is not None:
|
if poly_max_arclen is not None:
|
||||||
n += [perimeter / poly_max_arclen]
|
n += [perimeter / poly_max_arclen]
|
||||||
thetas = numpy.linspace(2 * pi, 0, max(n), endpoint=False)
|
num_points = int(round(max(n)))
|
||||||
|
thetas = numpy.linspace(2 * pi, 0, num_points, endpoint=False)
|
||||||
|
|
||||||
sin_th, cos_th = (numpy.sin(thetas), numpy.cos(thetas))
|
sin_th, cos_th = (numpy.sin(thetas), numpy.cos(thetas))
|
||||||
xs = r0 * cos_th
|
xs = r0 * cos_th
|
||||||
|
Loading…
Reference in New Issue
Block a user