import sand3d as s3d
def articulated_lamp():
panel=s3d.at(upright_panel(),x=6.5,y=-14,z=329)
arm=s3d.at(upper_arm(),x=8,y=-414,z=246)
s3d.joint(&class="tok-comment">#39;joint_arm_01_joint_00class="tok-string">39;,arm,on=s3d.local(panel,x=0,y=-44,z=218),kind=39;revoluteclass="tok-string">39;,axis=39;+Z39;,range=(-90,90))
return s3d.assembly(&class="tok-comment">#39;articulated_lamp39;,panel,arm)
def upright_panel(w=139,back=92,h=317,shoulder=218,corner=32,front=15,lower=52,tip=-92):
main=s3d.loft(&class="tok-comment">#39;panel39;,s3d.at(panel_section(w=w,back=back,front=lower,corner=corner),z=0),s3d.at(panel_section(w=w,back=back,front=front,corner=corner),z=70),s3d.at(panel_section(w=w,back=back,front=front,corner=corner),z=shoulder))
cap=s3d.loft(&class="tok-comment">#39;sloped_crown39;,s3d.at(crown_section(w=w,back=back,tip=tip+22),z=shoulder-1),s3d.at(crown_section(w=w,back=back,tip=tip),z=270),s3d.at(crown_section(w=w,back=back,tip=60),z=h))
solid=s3d.join(main,cap)
s3d.material(solid,kind=&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#484b4e39;)
return s3d.group(&class="tok-comment">#39;upright_panel39;,solid)
def panel_section(w,back,front,corner):
return s3d.poly([(-w/2,back),(w/2,back),(w/2,back-corner),(w/2-13,front),(-w/2+13,front),(-w/2,back-corner)])
def crown_section(w,back,tip):
return s3d.poly([(-w/2,back),(w/2,back),(w/2,60),(w/2-13,(tip+60)/2),(15,tip),(-15,tip),(-w/2+13,(tip+60)/2),(-w/2,60)])
def upper_arm(rod=35,end_d=47,pin_d=51,end_y=-357,panel_y=356,end_z=48,panel_z=195,pin_h=106):
solid=s3d.wire(&class="tok-comment">#39;upper_rod39;,path=[(-1,end_y,end_z),(-1,panel_y,panel_z)],d=rod)
end=s3d.at(s3d.cylinder(&class="tok-comment">#39;elbow_pin39;,d=end_d,h=85),x=-1,y=end_y,z=0)
pin=s3d.at(s3d.cylinder(&class="tok-comment">#39;panel_pin39;,d=pin_d,h=pin_h),x=-1,y=panel_y,z=panel_z)
s3d.material(solid,kind=&class="tok-comment">#39;aluminiumclass="tok-string">39;,color=39;#93999c39;)
s3d.material(end,kind=&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#646a6d39;)
s3d.material(pin,kind=&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#646a6d39;)
child=s3d.at(lower_arm(),x=22,y=-7,z=-84)
parent=s3d.group(&class="tok-comment">#39;upper_arm39;,solid,end,pin,child)
s3d.joint(&class="tok-comment">#39;joint_arm_02_joint_00class="tok-string">39;,child,on=s3d.local(parent,x=-1,y=-357,z=1),kind=39;revoluteclass="tok-string">39;,axis=39;+Z39;,range=(-90,90))
return parent
def lower_arm(rod=27,x=23,end_y=-349,tip_y=346,height=39,barrel_d=77,barrel_l=92):
solid=s3d.wire(&class="tok-comment">#39;lower_rod39;,path=[(x,end_y,height),(x,tip_y,height)],d=rod)
barrel=s3d.at(s3d.cylinder(&class="tok-comment">#39;barrel39;,d=barrel_d,h=barrel_l),x=-barrel_l/2,y=end_y,z=height,ry=90)
neck=s3d.at(s3d.cylinder(&class="tok-comment">#39;neck39;,d=47,h=89),x=-23,y=end_y,z=height)
s3d.material(solid,kind=&class="tok-comment">#39;aluminiumclass="tok-string">39;,color=39;#93999c39;)
s3d.material(barrel,kind=&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#646a6d39;)
s3d.material(neck,kind=&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#646a6d39;)
child=s3d.at(curved_band(),x=-94,y=478.5,z=14)
parent=s3d.group(&class="tok-comment">#39;lower_arm39;,solid,barrel,neck,child)
s3d.joint(&class="tok-comment">#39;joint_arm_03_joint_00class="tok-string">39;,child,on=s3d.local(parent,x=23,y=315,z=39),kind=39;revoluteclass="tok-string">39;,axis=39;-Y39;,range=(0,90))
return parent
def curved_band(radius=235,t=11,height=34,cx=117,cy=138.5,z=8,barrel_d=49):
band=s3d.at(s3d.extrude(&class="tok-comment">#39;open_band39;,s3d.stroke(s3d.arc(center=(cx,cy),r=radius,start=180,end=270),t=t),h=height),z=z)
a=s3d.at(s3d.cylinder(&class="tok-comment">#39;end_barrel39;,d=barrel_d,h=51),x=cx-radius-25,y=cy,z=25,ry=90)
b=s3d.at(s3d.cylinder(&class="tok-comment">#39;arm_socket39;,d=barrel_d,h=64),x=cx,y=cy-radius-64,z=25,rx=-90)
s3d.material(band,kind=&class="tok-comment">#39;aluminiumclass="tok-string">39;,color=39;#93999c39;)
s3d.material(a,kind=&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#646a6d39;)
s3d.material(b,kind=&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#646a6d39;)
child=s3d.at(flared_plate(),x=112,y=138.5,z=-151)
parent=s3d.group(&class="tok-comment">#39;curved_band39;,band,a,b,child)
s3d.joint(&class="tok-comment">#39;joint_lamp_01_joint_00class="tok-string">39;,child,on=s3d.local(parent,x=-90,y=139,z=25),kind=39;revoluteclass="tok-string">39;,axis=39;+X39;,range=(-90,90))
return parent
def flared_plate(d=308,cx=48,edge_z=110,rim_h=29,rise=51,skirt_z=154,top_x=-12,top_d=2,pin_x=-138,pin_d=26,pin_h=102,support_l=205,support_w=48):
rim=s3d.at(s3d.cone(&class="tok-comment">#39;outer_rim39;,d=d-28,h=rim_h,d2=d),x=cx,z=edge_z)
shade=s3d.loft(&class="tok-comment">#39;flared_shade39;,s3d.at(s3d.polygon(n=8,d=d),x=cx,z=skirt_z),s3d.at(s3d.circle(d=top_d),x=top_x,z=skirt_z+rise))
support=s3d.loft(&class="tok-comment">#39;hinge_support39;,s3d.at(s3d.rect(w=support_l,d=support_w),x=-100,z=139),s3d.at(s3d.rect(w=support_l,d=2),x=-100,z=205))
pin=s3d.at(s3d.cylinder(&class="tok-comment">#39;projecting_pin39;,d=pin_d,h=pin_h),x=pin_x,z=20)
tip=s3d.at(s3d.cone(&class="tok-comment">#39;pin_tip39;,d=0,h=20,d2=pin_d),x=pin_x,z=0)
s3d.material(rim,kind=&class="tok-comment">#39;aluminiumclass="tok-string">39;,color=39;#b5b9ba39;)
s3d.material(shade,kind=&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#646a6d39;)
s3d.material(support,kind=&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#646a6d39;)
s3d.material(pin,kind=&class="tok-comment">#39;aluminiumclass="tok-string">39;,color=39;#93999c39;)
s3d.material(tip,kind=&class="tok-comment">#39;aluminiumclass="tok-string">39;,color=39;#93999c39;)
return s3d.group(&class="tok-comment">#39;flared_plate39;,rim,shade,support,pin,tip)