Gear Cube
A fidget cube of eight meshing bevel gears: one gear sits on each corner axis of a cube, every gear meshes with its three neighbours, and turning any one turns all eight, alternate corners in opposite directions. It works because the corners of a cube split into two sets with no two neighbours in the same set; gears on the three face axes would form rings of three and lock. All pitch cones share the centre of the cube as their apex with a half angle of 35.26 degrees, the teeth are true conical bevel teeth with an involute profile, and the tooth count is a multiple of 3 so that the three meshes of each gear fit. The model checks the mesh at four phases across a tooth pitch, the backlash, that the fixed corner caps clear the turning gears and that each gear is held on its journal between the core and its cap. 17 printed parts: an octahedral core, eight gears and eight cube-corner caps whose triangular pegs push (or glue) into the core through the gears. With the default module 2 and 15 teeth the caps mark a 34 mm cube and the gear rims span 52 x 52 x 52 mm; the print plate is 145 x 123 x 37 mm. Core on a square flat, gears on their large end, caps on their truncated tip with the peg up, no supports. Parameters: module, tooth count, pressure angle, face width, backlash and fits, plus the turn angle shown in the assembled view.
# Gear Cube - eight meshing bevel gears on the corners of a cube; turn one and all eight turn
#
# Eight identical bevel gears sit on the eight corner axes (the body diagonals)
# of a cube. Each gear meshes with the three gears on the neighbouring corners,
# so turning any one of them turns all eight: the four gears on one set of
# alternate corners turn one way, the other four the opposite way. That only
# works because the corners of a cube split into two such sets - gears on the
# three face axes of a cube would form rings of three and lock.
#
# Geometry: two neighbouring diagonals meet at acos(1/3) = 70.53 deg, so every
# pitch cone has the half angle atan(1 / sqrt(2)) = 35.26 deg and all eight
# cones share the centre of the cube as their apex. Neighbouring cones touch
# along the line from the centre to the middle of the cube edge between them.
# The three neighbours of a gear are 120 deg apart around its axis, so the
# tooth count must be a multiple of 3; one set of four gears has a tooth on
# each pitch line, the other set a tooth space (half a pitch of phase).
#
# Teeth: as in a straight bevel gear every tooth edge runs to the apex (a ruled
# loft from the profile at the large end to the same profile scaled toward the
# apex). The profile is the involute of the virtual spur gear with
# z / cos(35.26 deg) teeth (Tredgold approximation), projected onto the flat
# large end, so the gears print on that face.
#
# Parts (17): an octahedral core with eight triangular sockets, eight gears,
# eight corner caps. Each cap is the corner of a cube with a round journal and
# a triangular peg: the peg goes through the gear and is pushed (or glued) into
# the core, so the cap holds the gear on its axle and stays put while the gear
# spins under it. The eight caps are the corners of one cube; the gear rims
# stand out beyond its faces.
# Print (view = "print"): core on one of its square flats, gears on their large
# end, caps on the small flat of their truncated tip with the peg up. No supports.
@param choices:["assembled", "print", "core", "gear", "cap"] desc:"Output: the assembled cube, the print plate, or one part"
$view = "assembled"
@param 0..360 step:1 desc:"Turn of the gears shown in the assembled view (deg)"
$view_angle = 0
@param 1.5..3 step:0.25 group:"Gear" desc:"Module at the large end (mm); pitch diameter = module x teeth"
$m = 2.0
@param 12..24 step:3 group:"Gear" desc:"Teeth per gear (a multiple of 3)"
$z = 15
@param 20..25 step:0.5 group:"Gear" desc:"Pressure angle (deg)"
$pa = 20
@param 0.2..0.33 step:0.01 group:"Gear" desc:"Face width as a fraction of the cone distance"
$face_ratio = 0.3
@param 0.2..0.8 step:0.05 group:"Fit" desc:"Total backlash at the large end (mm)"
$backlash = 0.4
@param 0.15..0.5 step:0.05 group:"Fit" desc:"Running clearance of the gear on its journal, per side (mm)"
$fit = 0.25
@param 0.05..0.2 step:0.01 group:"Fit" desc:"Clearance of the triangular peg in its socket, per side (mm); small = push fit"
$press = 0.1
assert $z % 3 == 0 # three neighbours 120 deg apart
# ---------------------------------------------------------------- pitch cones
$d = atan(1 / sqrt(2)) # pitch cone half angle (deg) = half the angle between two diagonals
$beta = 90 - $d # angle between a diagonal and a cube axis
$r = $m * $z / 2 # pitch radius at the large end
$cone_dist = $r / sin($d) # centre of the cube to the pitch point
$ax = $r / tan($d) # centre of the cube to the large end plane, along the axis
$bface = $face_ratio * $cone_dist
$s1 = 1 - $face_ratio # scale of the small end
$gh = $bface * cos($d) # axial height of a gear
$n = 6
assert (2 * $d) ~ acos(1 / 3) tol:0.0001 # shaft angle = angle between two body diagonals
assert ($z / cos($d)) >= 14 # virtual tooth count: no heavy undercut
# ---------------------------------------------------------------- tooth profile (virtual spur gear on the back cone)
$rv = $r / cos($d)
$rbv = $rv * cos($pa)
$rav = $rv + $m
$rfv = $rv - 1.25 * $m
$r0v = max($rbv, $rfv)
$footv = $rfv - 0.3 * $m
def inv(q) = deg(tan(acos($rbv / q))) - acos($rbv / q)
def hv(q) = 90 * cos($d) / $z + inv($rv) - inv(q) - deg($backlash / 4 / $rv)
def rad3(q) = $r + (q - $rv) * cos($d)
def rad0(q) = rad3(q) * $ax / ($ax - (q - $rv) * sin($d))
def ang(q) = hv(q) * q / rad3(q)
def fq(k) = $r0v + ($rav - $r0v) * k / $n
def pt(q, a, sg, s) = (s * rad0(q) * cos(sg * ang(a)), s * rad0(q) * sin(sg * ang(a)))
def tooth_pts(s) = [pt($footv, $r0v, -1, s)] + [pt(fq(k), fq(k), -1, s) for k in range($n + 1)] + [(s * rad0($rav + 0.02 * $m), 0)] + [pt(fq($n - k), fq($n - k), 1, s) for k in range($n + 1)] + [pt($footv, $r0v, 1, s)]
def tooth(s) = polyline tooth_pts(s)
def gear2d(s) = tooth(s) | polar $z 0 orient:true | union (circle (s * rad0($rfv)))
$tipr = $r + $m * cos($d) # outside radius
$rootr = rad0($rfv)
$lofted = gear2d(1) | loft [gear2d($s1)] $gh ruled:true
$teeth = $lofted * (cylinder $tipr 100)
# ---------------------------------------------------------------- dimensions of core, journal and cap
$cap_r = 0.73 * $r # circumradius of the triangular cap base
$jr = min(4, $cap_r / 2 - $fit - 1) # journal radius; the peg is the triangle inscribed in it
assert $jr >= 2
$play_in = 0.1 # gear to core face
$play_out = 0.3 # gear to cap
$seat = 0.05 # glue line between journal shoulder and core face
$dc = $ax - $gh - $play_in # centre to a core face
$peg_len = min(6, $dc - 0.5 - 1.8 * ($jr + $press)) # the eight sockets stay apart near the centre
assert $peg_len >= 3
$cap_z = $ax + $play_out # centre to the cap base
$cap_h = $cap_r / sqrt(2) # cap base to the cube corner
$a = ($cap_z + $cap_h) / sqrt(3) # half the edge of the cube the caps belong to
$flat_r = $jr # circumradius of the flat the cap prints on
$tip_cut = $flat_r / sqrt(2)
assert $jr + $fit + 1.5 <= $s1 * $rootr # wall around the bore at the small end
assert $cap_r / 2 >= $jr + $fit + 1 # the cap base overhangs the bore all round: the gear cannot come off
# The corners of the cap base point at the neighbouring gears. Seen from the centre of the cube they
# must lie outside the tip cone of those gears (angle from the neighbour's axis, in deg).
$tip_ang = $d + atan($m / $cone_dist)
$cap_ang = acos(($cap_z / 3 + $cap_r * sin(2 * $d)) / sqrt($cap_z ** 2 + $cap_r ** 2))
assert $cap_ang >= $tip_ang + 2
assert $cap_h * sqrt(3) < $a # caps of neighbouring corners stay apart
# ---------------------------------------------------------------- parts in the local frame: axis = +Z, origin = centre of the cube
# gear: large end outward at z = ax, small end toward the centre, a tooth centred on +X
$bore = cylinder ($jr + $fit) ($gh + 2) | floor | translate 0 0 ($ax - $gh - 1)
$gear_solid = $teeth | rotate 180 0 0 | translate 0 0 $ax
$gear = $gear_solid - $bore
assert $gear.solids == 1
assert $gear.bbox.z ~ $gh tol:0.01
assert $gear.bbox.y <= 2 * $tipr + 0.01
assert $gear.bbox.y > 2 * $r
# cap: the corner of the cube |x|,|y|,|z| <= a, turned so that the corner points along +Z
$cube = box (2 * $a) (2 * $a) (2 * $a) | rotate 0 0 -45 | rotate 0 (-$beta) 0
$slab = cylinder 100 ($a * sqrt(3) - $tip_cut - $cap_z) | floor | translate 0 0 $cap_z
$head = $cube * $slab
$journal = cylinder $jr ($cap_z - $dc - $seat + 0.5) | floor | translate 0 0 ($dc + $seat)
$peg = polygon 3 $jr | extrude ($peg_len + 0.5) | translate 0 0 ($dc - $peg_len)
$cap = $head + $journal + $peg
assert $cap.solids == 1
assert $cap.bbox.max[2] ~ ($a * sqrt(3) - $tip_cut) tol:0.01
assert $cap.bbox.min[2] ~ ($dc - $peg_len) tol:0.01
$socket = polygon 3 $jr | offset $press | extrude ($peg_len + 1.5) | translate 0 0 ($dc - $peg_len - 0.5)
# ---------------------------------------------------------------- placing on the eight corners
# k = 0..3: corners (1,1,1), (1,-1,-1), (-1,1,-1), (-1,-1,1); k = 4..7: the same turned 90 deg about Z.
$gx = [0, 180, 0, 0]
$gy = [0, 0, 180, 0]
$gz = [0, 0, 0, 180]
def put(s, k) = s | rotate 0 $beta 0 | rotate 0 0 45 | rotate $gx[k % 4] $gy[k % 4] $gz[k % 4] | rotate 0 0 (90 * (k // 4))
# gear k turned by q about its own axis: the two sets turn opposite ways, half a pitch out of phase
def spin(k, q) = if k < 4 then q else (180 / $z - q)
def gear_in(k, q, dz) = put($gear | rotate 0 0 spin(k, q) | translate 0 0 dz, k)
def gear_at(k, q) = gear_in(k, q, 0)
def cap_at(k) = put($cap, k)
# core: octahedron (one face under every gear) with its six points cut off, eight sockets
$oct_slab = box 200 200 100 | translate 0 0 ($dc - 50)
$oct0 = put($oct_slab, 0) * put($oct_slab, 1)
$oct1 = $oct0 * put($oct_slab, 2) * put($oct_slab, 3)
$oct2 = $oct1 * put($oct_slab, 4) * put($oct_slab, 5)
$oct = $oct2 * put($oct_slab, 6) * put($oct_slab, 7)
$core_cut = 0.72 * $dc * sqrt(3) # half size of the cube that cuts the points off
$core_body = $oct * (box (2 * $core_cut) (2 * $core_cut) (2 * $core_cut))
$sockets = union [put($socket, k) for k in range(8)]
$core = $core_body - $sockets
assert $core.solids == 1
assert $core.bbox.z ~ (2 * $core_cut) tol:0.01
assert $core.faces >= 14 + 8 * 4
# ---------------------------------------------------------------- checks
$q = 360 / $z
# 1. Mesh: gear 0 and its three neighbours (4, 5, 7) are clear across one tooth pitch.
assert clear(gear_at(0, 0), gear_at(4, 0))
assert clear(gear_at(0, $q / 4), gear_at(4, $q / 4))
assert clear(gear_at(0, $q / 2), gear_at(4, $q / 2))
assert clear(gear_at(0, 3 * $q / 4), gear_at(4, 3 * $q / 4))
assert clear(gear_at(0, 0), gear_at(5, 0))
assert clear(gear_at(0, 3 * $q / 4), gear_at(7, 3 * $q / 4))
# ... also with both gears pushed in against the core (the tightest mesh the play allows)
assert clear(gear_in(0, $q / 4, -$play_in), gear_in(4, $q / 4, -$play_in))
# 2. They really mesh: holding gear 4 and turning gear 0 by 1.5 x the half backlash collides, either way.
$lock = 1.5 * deg($backlash / 2 / $r)
assert clear(gear_at(0, $lock), gear_at(4, 0)) == false
assert clear(gear_at(0, -$lock), gear_at(4, 0)) == false
# 3. Gears on the same set of corners never meet.
assert clear(gear_at(0, 0), gear_at(1, 0))
# 4. Retention: the gear is clear of its cap and of the core, but cannot move out or in by more than the play.
assert clear(gear_at(0, 0), cap_at(0))
assert clear(gear_at(0, 0), $core)
assert clear(gear_in(0, 0, $play_out + 0.1), cap_at(0)) == false
assert clear(gear_in(0, 0, -$play_in - 0.1), $core) == false
# 5. The fixed caps are clear of the neighbouring gears while those turn, and of the core.
assert clear(cap_at(0), gear_at(4, 0))
assert clear(cap_at(0), gear_at(4, $q / 2))
assert clear(cap_at(0), gear_at(5, $q / 4))
assert clear(cap_at(0), cap_at(4))
assert clear(cap_at(0), $core)
assert clear(cap_at(4), $core)
print "pitch cone half angle (deg)" $d "cone distance" $cone_dist "pitch dia" (2 * $r) "virtual teeth" ($z / cos($d))
print "cube of the caps, edge (mm)" (2 * $a) "cap corner outside the tip cone by (deg)" ($cap_ang - $tip_ang)
# ---------------------------------------------------------------- layouts
$asm = union ([$core] + [gear_at(k, $view_angle) for k in range(8)] + [cap_at(k) for k in range(8)])
assert $asm.solids == 17
$pg = 2 * $tipr + 4 # pitch of the gears on the plate
$cap_print = $cap | rotate 180 0 0 | floor
$gear_print = $teeth - (cylinder ($jr + $fit) ($gh + 2) | floor | translate 0 0 -1)
$core_print = $core | floor
$pc = 2 * $cap_r + 4 # pitch of the caps
$plate = union ([$core_print | translate (4 * $pc + $core_cut + 4) (-$core_cut - 4) 0] + [$gear_print | translate ($pg * (k % 4) + $pg / 2) ($pg * (k // 4) + $pg / 2) 0 for k in range(8)] + [$cap_print | translate ($pc * (k % 4) + $pc / 2) (-$pc * (k // 4) - $pc / 2 - 2) 0 for k in range(8)])
assert $plate.solids == 17
assert $plate.bbox.min[2] ~ 0 tol:0.01
assert $gear_print.volume ~ $gear.volume tol:0.01%
if $view == "assembled" then $asm else if $view == "print" then $plate else if $view == "core" then $core_print else if $view == "gear" then $gear_print else $cap_print