Created
August 20, 2013 18:42
-
-
Save ityonemo/6285488 to your computer and use it in GitHub Desktop.
somewhat simple code for doing screws 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
//we're going to make a screw | |
//example values: | |
resolution = 200; | |
turns = 5; | |
height = 10; | |
deltathread = height / turns / 2; | |
trivial = 0.01; | |
for(i=[1:resolution]) { | |
rotate(a=[0,0,(turns * 360 * i)/resolution]) //a little bit of turn, depending on the resolution | |
translate([0,0,i * height/resolution]) //move up the appropriate amount. | |
hull(){ | |
//each unit is going to be a skew triangular prism. | |
//this will be defined by taking two really thin triangle prisms (linearly extruded polygons) and | |
//constructing the convex hull between the two. | |
//note that linear extrusion operates in the Z direction, so the triangles will have to be rotated first. | |
//first triangle, this one is simple. | |
rotate([90,0,0]) | |
linear_extrude(height=trivial) | |
polygon([[innerdiameter,deltathread],[innerdiameter,-deltathread],[outerdiameter,0]]); | |
//second triangle. | |
translate([0,0,height/resolution]) //lift it by the appropriate amount. | |
rotate([0,0,turns * 360/resolution]) //rotate it by a single resolution unit; to match with next segment. | |
rotate([90,0,0]) | |
linear_extrude(height=trivial) | |
polygon([[innerdiameter,deltathread],[innerdiameter,-deltathread],[outerdiameter,0]]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment