23 lines
976 B
Python
23 lines
976 B
Python
import math
|
|
|
|
from build123d import extrude
|
|
from engine.profile_geometry import arc_profile, frame
|
|
|
|
|
|
def validate(context, target, params):
|
|
if params['inner_radius'] >= params['outer_radius']:
|
|
return ['RADII: inner radius must be smaller than outer radius']
|
|
return []
|
|
|
|
|
|
def run(context, target, params):
|
|
a, sweep = math.radians(params['start_angle']), math.radians(params['sweep_angle'])
|
|
outer, inner = params['outer_radius'], params['inner_radius']
|
|
point = lambda radius, angle: [radius * math.cos(angle), radius * math.sin(angle)]
|
|
# Split arcs at their midpoint to avoid a full-circle ambiguity.
|
|
points = [point(outer, a), point(outer, a+sweep/2), point(outer, a+sweep),
|
|
point(inner, a+sweep), point(inner, a+sweep/2), point(inner, a)]
|
|
bulge = math.tan(sweep/8)
|
|
profile = arc_profile(points, [bulge, bulge, 0, -bulge, -bulge, 0])
|
|
return frame(params) * extrude(profile, amount=params['thickness'], dir=(0, 0, 1))
|