Crown in OpenSCAD, see http://3dtoday.ru/questions/vopros-po-modelirovaniyu/
Last active
June 22, 2017 15:04
-
-
Save lorf/daa3a5095cc32c3d89b77d42d2316059 to your computer and use it in GitHub Desktop.
Crown 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
// http://3dtoday.ru/questions/vopros-po-modelirovaniyu/ | |
$fn=256; | |
outer_radius=10; | |
inner_radius=7.5; | |
center_height=10; | |
half_tooth_height=5; | |
number_of_teeth=4; | |
// Vertical position of the top surface point depending on it's polar coordinates | |
function curve(rr,tt) = center_height+half_tooth_height*cos(tt*number_of_teeth)*(rr/outer_radius); | |
function points(tt) = [for (aa=[0:360/$fn:360-.001]) [ | |
tt*sin(aa), | |
tt*cos(aa), | |
curve(tt,aa) | |
]]; | |
function zero_z(points) = [for (ii=[0:len(points)-1]) [points[ii].x,points[ii].y,0]]; | |
outerpoints=points(outer_radius); | |
innerpoints=points(inner_radius); | |
outertoppoints=outerpoints; | |
outerbottompoints=zero_z(outerpoints); | |
innertoppoints=innerpoints; | |
innerbottompoints=zero_z(innerpoints); | |
allpoints=concat(outerbottompoints,outertoppoints,innerbottompoints,innertoppoints); | |
outerfaces=[for (ii=[0:$fn-1]) [ii,(ii+1)%$fn,$fn+(ii+1)%$fn,$fn+ii]]; | |
innerfaces=[for (ii=[0:$fn-1]) [2*$fn+ii,2*$fn+(ii+1)%$fn,3*$fn+(ii+1)%$fn,3*$fn+ii]]; | |
bottomface=[concat([for (ii=[0:$fn]) 2*$fn+ii%$fn],[for (ii=[$fn:-1:0]) ii%$fn])]; | |
topfaces1=[for (ii=[0:$fn-1]) [3*$fn+ii,$fn+ii,$fn+(ii+1)%$fn]]; | |
topfaces2=[for (ii=[0:$fn-1]) [$fn+(ii+1)%$fn,3*$fn+(ii+1)%$fn,3*$fn+ii]]; | |
allfaces=concat(outerfaces,innerfaces,bottomface,topfaces1,topfaces2); | |
polyhedron(points=allpoints,faces=allfaces); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment