diff --git a/nhf/joints.py b/nhf/joints.py index b066c77..9cdd0ad 100644 --- a/nhf/joints.py +++ b/nhf/joints.py @@ -8,7 +8,8 @@ def hirth_joint(radius=60, base_height=20, n_tooth=16, tooth_height=16, - tooth_height_inner=2): + tooth_height_inner=2, + tol=0.01): """ Creates a cylindrical Hirth Joint """ @@ -26,14 +27,16 @@ def hirth_joint(radius=60, # triangles. outer = [ (radius * math.tan(theta), 0), + (radius * math.tan(theta) - tol, 0), (0, tooth_height), + (-radius * math.tan(theta) + tol, 0), (-radius * math.tan(theta), 0), ] inner = [ (radius_inner * math.sin(theta), 0), - (radius_inner * math.sin(theta), inner_raise - tooth_height_inner / 2), - (0, inner_raise + tooth_height_inner / 2), - (-radius_inner * math.sin(theta), inner_raise - tooth_height_inner / 2), + (radius_inner * math.sin(theta), inner_raise), + (0, inner_raise + tooth_height_inner), + (-radius_inner * math.sin(theta), inner_raise), (-radius_inner * math.sin(theta), 0), ] tooth = ( @@ -43,13 +46,13 @@ def hirth_joint(radius=60, .workplane(offset=radius - radius_inner) .polyline(outer) .close() - .loft(combine=True) + .loft(ruled=True, combine=True) .val() ) tooth_centre_radius = radius_inner * math.cos(theta) teeth = ( Cq.Workplane('XY') - .polarArray(radius=radius_inner, startAngle=0, angle=360, count=n_tooth) + .polarArray(radius=tooth_centre_radius, startAngle=0, angle=360, count=n_tooth) .eachpoint(lambda loc: tooth.located(loc)) .intersect(Cq.Solid.makeCylinder( height=base_height + tooth_height, @@ -67,7 +70,7 @@ def hirth_joint(radius=60, .clean() ) #base.workplane(offset=tooth_height/2).circle(radius=radius,forConstruction=True).tag("mate") - base.polyline([(0, 0, 0), (0, 0, 1)], forConstruction=True).tag("mate") + base.polyline([(0, 0, base_height), (0, 0, base_height+tooth_height)], forConstruction=True).tag("mate") return base def hirth_assembly(): @@ -90,8 +93,8 @@ def hirth_assembly(): result = ( Cq.Assembly() .add(obj1, name="obj1", color=Cq.Color(0.8,0.8,0.5,0.3)) - .add(obj2, name="obj2", color=Cq.Color(0.5,0.5,0.5,0.3), loc=Cq.Location((0,0,80))) - .constrain("obj1?mate", "obj2?mate", "Axis") + .add(obj2, name="obj2", color=Cq.Color(0.5,0.5,0.5,0.3)) + .constrain("obj1?mate", "obj2?mate", "Plane") .solve() ) return result