// Last edited on 2010-05-31 22:46:00 by stolfilocal // LIGHT GAUGE AND ITS HOLDER /////////////////////////////////////////////////////// #declare gauge_ball_rad = 20.00; // Radius of gauge ball (pingpong ball). #declare gauge_cup_hgt = 25.00; // Inside height of cup. #declare gauge_cup_rbot = 22.50; // Bottom inside radius of cup. #declare gauge_cup_rtop = 40.00; // Top inside radius of cup. #declare gauge_cup_thk = 0.25; // Thickness of cup. #declare gauge_cup_rlip = 1.00; // Minor radius of rolled-up lip. #declare gauge_velvet_thk = 2.00; // Thickness of velvet. #declare gauge_foot_rad = 20.00; // Radius of foot. #declare gauge_max_view_angle = 30; // Max angle of view assumed. #macro baffle_base_lining(rout,rint,thk,cut) difference{ cylinder{ <0,0,0>, <0,0,thk-eps>, rout-eps texture{ tx_velvet_black } } cylinder{ <0,0,0-eps>, <0,0,thk+eps>, rint+eps texture{ tx_velvet_black } } cylinder{ <0,0,0-2*eps>, <0,0,0+eps>, rout+2*eps texture{ tx_velvet_verso } } #if (cut) plane{ -x,0 texture{ tx_velvet_black } } #end } #end #macro baffle_wall_lining(hgt,rbot,rtop,thk,explode,cut) #local dr = rtop - rbot; // Diff of radii. #local g = sqrt(dr*dr + thk*thk); // Height along cone surf. #local m = g/dr; // Thickening factor. #local stop = rtop - m*thk; #local sbot = rbot - m*thk; difference{ cone{ <0,0,0>, rbot-eps, <0,0,hgt>, rtop-eps texture{ tx_velvet_verso } } cone{ <0,0,0-eps>, sbot+eps, <0,0,hgt+eps>, stop+eps texture{ tx_velvet_black } } cylinder{ <0,0,0-2*eps>, <0,0,0+0.5*thk>, rtop+2*eps texture{ tx_velvet_black } } cylinder{ <0,0,hgt-eps>, <0,0,hgt+2*eps>, rtop+thk+2*eps texture{ tx_velvet_black } } #if (explode > 0) intersection{ box{ <0,0,0-3*eps>, } box{ <0,-0.5*rtop,0-4*eps>, rotate 3*z } texture{ tx_velvet_black } } #end #if (cut) plane{ -x,0 texture{ tx_velvet_black } } #end } #end #macro baffle_cup(hgt,rbot,rtop,thk,rlip,cut) #local dr = rtop - rbot; // Diff of radii. #local g = sqrt(dr*dr + hgt*hgt); // Height along cone surf. #local m = g/dr; // Thickening factor. #local chgt = hgt - rlip; // Cone height. #local stop = rtop + m*thk; #local sbot = rbot + m*thk; difference{ union{ difference{ cone{ <0,0,0+eps>, sbot-eps, <0,0,chgt+thk-eps>, stop-eps texture{ tx_matte_black } } cone{ <0,0,thk-eps>, rbot+eps, <0,0,chgt+thk+eps>, rtop+eps texture{ tx_aluminum } } } torus{ rtop+rlip-thk, rlip rotate 90*x translate chgt*z texture{ tx_matte_black } } } #if (cut) plane{ -x,0 texture{ tx_aluminum_cut } } #end } #end #macro baffle_foot(hgt,rad,cut) difference{ cylinder{ <0,0,0+eps>, <0,0,hgt-eps>, rad-eps texture{ tx_matte_black } } #if (cut) plane{ -x,0 texture{ tx_wood_grain } } #end } #end #macro gauge_ball(rad,cut) #local ball_thk = 0.75; difference{ sphere{ <0,0,0>, rad-eps texture{ tx_gauge } } sphere{ <0,0,0>, rad-ball_thk+eps texture{ tx_gauge } } #if (cut) plane{ -x,0 texture{ tx_gauge_cut } } #end } #end #macro max_light_inclination(rim_rad,cup_hgt,ball_rad,max_vdeg) // Maximum allowed light inclination from normal in degrees. // ball_rad = Radius of gauge. // rim_rad = Radius of cup's mouth (minus the lining's thickness). // cup_hgt = Height of cup. // max_vdeg = Max inclination of viewing direction from normal. #local r = ball_rad; #local R = rim_rad; #local h = cup_hgt; #local va = radians(max_vdeg); #local zbot = r*(1 - sin(va)); // Height of viewable horizon. #local rbot = r*cos(va); // Radius of viewable horizon. #local dZ = h - zbot; // Z dist from cup's rim to viewable horizon. #local dR = R - rbot; // Radial dist from cup's rim to viewable horizon. #local mang = atan(dR/dZ); // Max light inclination (radians). // debug concat("mang = ", str(degrees(mang),6,1), "\n") (degrees(mang)) #end #macro visibility_cone(rim_rad,cup_hgt,ball_rad,max_vdeg,cut) #local r = ball_rad; #local R = rim_rad; #local h = cup_hgt; #local va = radians(max_vdeg); #local zbot = r*(1 - sin(va)); // Height of viewable horizon. #local rbot = r*cos(va); // Radius of viewable horizon. #debug "\n" #local mang = max_light_inclination(R,h,r,va); // Max light inclination (deg). #debug concat("max light inclination = ", str(mang,6,1), " deg\n") #local ztop = 3*cup_hgt; #local rtop = rbot + (R - rbot)*(ztop - zbot)/(h - zbot); #local thk = 0.1; // Thickness of visibility cone walls. difference{ cone{ <0,0,zbot+eps>, rbot+thk, <0,0,ztop-eps>, rtop+thk } cone{ <0,0,zbot-eps>, rbot-thk, <0,0,ztop+eps>, rtop-thk } texture{ pigment{ color rgb 0.95*< 1.0, 1.0, 0.60 > filter 0.50 } finish{ ambient 1.0 diffuse 0.0 } } } #end #macro gauge_in_baffle(rim_hgt,explode,viscone,cut) #local ball_rad = gauge_ball_rad; // Radius of gauge ball (pingpong ball). #local cup_hgt = gauge_cup_hgt; // Inside height of cup. #local cup_rbot = gauge_cup_rbot; // Bottom inside radius of cup. #local cup_rtop = gauge_cup_rtop; // Top inside radius of cup. #local cup_thk = gauge_cup_thk; // Thickness of cup. #local cup_rlip = gauge_cup_rlip; // Minor radius of cup's lip. #local velvet_thk = gauge_velvet_thk; // Thickness of velvet. #local foot_rad = gauge_foot_rad; // Radius of foot. #local max_vdeg = gauge_max_view_angle; // Max viewing inclination (degrees). #local lining_rhole = 10.00; // Radius of hole on bottom lining. #local foot_hgt = rim_hgt - cup_hgt; // Height of foot. union{ #local dz = 0; object{ baffle_foot(foot_hgt,foot_rad,cut) translate dz*z } #local dz = dz + foot_hgt; #local dz = dz + explode*30; object{ baffle_cup(cup_hgt,cup_rbot,cup_rtop,cup_thk,cup_rlip,cut) translate dz*z } #local dz = dz + cup_thk; #local dz = dz + explode*(cup_hgt + 20); object{ baffle_base_lining(cup_rbot,lining_rhole,velvet_thk,cut) translate dz*z } #local dz = dz + 0; #local dz = dz + explode*(0.50*cup_rbot + 20); object{ baffle_wall_lining(cup_hgt,cup_rbot,cup_rtop,velvet_thk,explode,cut) translate dz*z } #local dz = dz + 0; #local dz = dz + explode*(cup_hgt + 15); #if (viscone) #local rim_rad = cup_rtop - velvet_thk; object{ visibility_cone(rim_rad,cup_hgt,ball_rad,max_vdeg,cut) translate dz*z } #end object{ gauge_ball(ball_rad,cut) translate (dz + ball_rad)*z } #local dz = dz + 2*ball_rad; } #debug "exiting gauge_in_baffle()\n" #end #debug "loaded pst_light_gauge.inc\n"