def limit_cyl(arc, xmin=0.0, xmax=0.0, ymin=0.0, ymax=0.0): new_arc = Shape(name='arc') new_arc.sld = arc.sld new_arc.sldi = arc.sldi new_arc.theta_start = arc.theta_start new_arc.theta_end = arc.theta_end #new_arc.area = arc.area for point in arc.points: if (point[0] >= xmin) and (point[0] <= xmax) and (point[1] >=ymin) and (point[1] <= ymax): new_arc.points.append(point) if len(new_arc.points) < 3: new_arc.area = 0.0 else: new_arc.area = (len(new_arc.points) - 2) / 360.0 * arc.area return new_arc
def arc(r, theta_start, theta_end, x_center, y_center, theta_step=1.0, close=True, sld=0.0, sldi=0.0, ): a = Shape(name='arc') a.theta_start = theta_start a.theta_end = theta_end a.area = pi * r**2 * abs(theta_end - theta_start)/360.0 if close == True: a.points.append([x_center, y_center]) # center point numpoints = (theta_end - theta_start) / theta_step + 1 thetas = linspace(theta_start, theta_end, numpoints) * pi/180 # to radians for th in thetas: a.points.append([r*cos(th) + x_center, r*sin(th) + y_center]) a.sld = sld a.sldi = sldi return a