Created
January 12, 2012 07:52
-
-
Save matthewSorensen/1599301 to your computer and use it in GitHub Desktop.
A parametric bearing in OpenSCAD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function radius_to_balls(r_ball, r) = 180 / asin(r_ball / r); | |
function ball_to_radius(n, r) = r * sin(180 / n); | |
module Bearing(outer, inner, attempt, gap, hole, height) { | |
n = round(radius_to_balls(attempt, inner)); | |
r = ball_to_radius(n, inner); | |
theta = 360 / n; | |
pinRadius = 0.5 * r; | |
// The pins: | |
for(i = [0 : n]) | |
rotate(a = [0, 0, theta * i]) | |
translate([inner, 0, 0]) | |
union() {/* | |
sphere(r = r - gap, center = true, $fn = 45); */ | |
sphere(r = r - 0.5*gap, center = true, $fn = 45); | |
assign(rad = pinRadius - gap) | |
cylinder(r1 = rad, r2 = rad, h = height, center = true, $fn = 45); | |
} | |
// The inner race: | |
difference() { | |
assign(rad = inner - pinRadius - gap) | |
cylinder(r1 = rad, r2 = rad, h = height, center = true, $fn = 45); | |
rotate_extrude(convexity = 10) | |
translate([inner, 0, 0]) | |
circle(r = r + gap, $fn = 30); | |
cylinder(r1 = hole, r2 = hole, h = height + 5, center = true, $fn = 45); | |
} | |
// The outer race: | |
difference() { | |
cylinder(r1 = outer, r2 = outer, h = height, center = true, $fn = 45); | |
assign(rad = inner + pinRadius + gap) | |
cylinder(r1 = rad, r2 = rad, h = height + 5, center = true, $fn = 45); | |
rotate_extrude(convexity = 10) | |
translate([inner, 0, 0]) | |
circle(r = r + gap, $fn = 45); | |
} | |
} | |
Bearing(outer = 13, inner = 8, attempt = 3, gap = 0.2, height = 10, hole = 1.5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment