-
-
Save hyperair/9eb2e89777a3bcef9df0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| module trapezoidal_thread ( | |
| pitch, | |
| length, | |
| upper_angle, | |
| lower_angle, | |
| outer_flat_length, | |
| major_radius, | |
| minor_radius, | |
| internal = false, | |
| n_starts = 1 | |
| ) | |
| { | |
| // trapezoid calculation: | |
| /* | |
| upper flat | |
| ___________________ | |
| /| |\ | |
| / | | \ | |
| left /__|_________________|__\ right | |
| angle| | lower flat | |angle | |
| | | | | | |
| |left |right | |
| flat |flat | |
| */ | |
| // looking at the tooth profile along the upper part of a screw held | |
| // horizontally, which is a trapezoid longer at the bottom flat | |
| tooth_height = major_radius - minor_radius; | |
| left_angle = 90 - upper_angle; | |
| right_angle = 90 - lower_angle; | |
| upper_flat = outer_flat_length; | |
| left_flat = tooth_height / tan (left_angle); | |
| right_flat = tooth_height / tan (right_angle); | |
| lower_flat = upper_flat + left_flat + right_flat; | |
| clearance = 0.3/8 * tooth_height; | |
| function tooth_profile () = [ | |
| [0, 0], | |
| [tooth_height, right_flat], | |
| [tooth_height, right_flat + upper_flat], | |
| [0, lower_flat] | |
| ]; | |
| // facet calculation | |
| facets = $fn > 0 ? $fn : | |
| max (30, min (2 * PI * minor_radius / $fs, 360 / $fa)); | |
| fa = 360 / facets; | |
| slices = length2twist (length) / fa; | |
| // convert length along the tooth profile to angle of twist of the screw | |
| function length2twist (length) = length / pitch * (360 / n_starts); | |
| function twist2length (angle) = angle / (360 / n_starts) * pitch; | |
| path_transforms = [ | |
| for (i=[0:slices + length2twist (pitch) / fa]) | |
| let (a=i * fa) | |
| ( | |
| rotation (axis=[0, 0, a]) * | |
| translation ([0, 0, twist2length (a) - pitch]) * | |
| translation ([minor_radius, 0, 0]) * | |
| rotation ([90, 0, 0]) | |
| ) | |
| ]; | |
| cylinder (r=minor_radius, h=length); | |
| difference () { | |
| for (i=[0:n_starts]) | |
| rotate ([0, 0, i / n_starts * 360]) | |
| sweep (tooth_profile (), path_transforms); | |
| translate ([0, 0, length + pitch / 2]) | |
| cube ([major_radius * 2 + .1, major_radius * 2+ .1, pitch], | |
| center=true); | |
| translate ([0, 0, -pitch / 2]) | |
| cube ([major_radius * 2 + .1, major_radius * 2+ .1, pitch], | |
| center=true); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment