title screw by XYZ Scientific Applications, Inc.
neutral
sd 1 sp 0 0 0 2            c surface definitions
sd 2 plan 0 0 1 0 0 1
sd 3 plan 0 0 0 0 0 1
sd 4 plan 0 -.3 0 0 1 0
sd 5 plan 0 .3 0 0 1 0
block 1 5 13 21 25;           c part 1 - screw head
      1 5 11 13 15 21 25;
      1 5 9;
      -.7 -.7 0 .7 .7 
      -.5 -.5 -.3 0 .3 .5 .5 
       0 .5 .5
dei 1 2 0 4 5;1 7;2 3;         c delete regions to form the hemisphere
dei 1 5;1 2 0 6 7;2 3;         c and slot
de 2 3 2 4 5 3   
dei 1 2 0 4 5;1 2 0 6 7;1 2;
sfi -1 -5;2 6;1 2;sd 1         c project onto the surfaces
sfi 2 4;-1 -7;1 2;sd 1
sfi 2 4;2 3 0 5 6;-3;sd 1
sf 0 0 2 0 0 2 sd 2 
sf 0 0 1 0 0 1 sd 3
sfi 2 4;-2 -6;2 3;sd 2 
sfi -2 -4;2 3 0 5 6;2 3;sd 2
sf 0 3 0 0 3 0 sd 4
sf 0 5 0 0 5 0 sd 5
c compress the head in the z-direction
z=-.75*z-.2                    
endpart
cylinder 1 2;                  c part 2 - shank just below the head
         1 37;
         1 2 3;
         0 .9 
         0 360 
         -.2 -.1 0
dom 1 1 2 2 2 2
c expand the shank in the z-direction
z=-.1+.2*(j-1)/36              
dom 1 1 3 2 2 3
z=.4*(j-1)/36
endpart
cylinder 1 2 3;                c part 3 - shank with the thread
         1 1081;
         1 2 3;
         0 .9 1.3 
         0 10800 
         0 .2 .4
de 2 0 2 3 0 3                 c remove the region around the theads
c expand the shank in the z-direction
z=z+(j-1)*.4/36                
dom 3 1 1 3 2 1
c move the top part of the thread down
z=z+.09                        
dom 3 1 2 3 2 2
z=z-.09
dom 1 1 1 3 2 3                c move the bottom of the thread up
x=x*min((1+cos(-12.4*z)),1)
endpart
merge
rx 70 zf 3 d 0.6 ry 90 r 0.1 u 0.1 tvv
