// Defines the IC abacus with predefined colors. // Last edited on 2003-09-18 21:46:39 by stolfi // Assumes defined the following things: // ic_abacus_width = width (X) of abacus, including frame // ic_abacus_height = height (Z) of abacus, including frame // ic_abacus_frame_width = width of abacus frame, in both directions // ic_abacus_frame_thickness = thickness (Y) of abacus frame // ic_abacus_stick_R = radius of slider-bearing sticks // ic_abacus_slider_angle = angle between slider chamfer and flat face (deg) // ic_abacus_frame_texture = texture for frame (long axis is X axis) // ic_abacus_unit_slider_{texture,interior} = texture and interior for the "units" sliders // ic_abacus_five_slider_{texture,interior} = texture and interior for the "fives" sliders // ic_abacus_stick_texture = texture for the sticks // Defines // ic_abacus = // the whole abacus, centered on the origin and perpendicular // to the Y axis, with sticks parallel to X axis. #include "ic-abacus-slider.inc" #declare ic_abacus_space_width = ic_abacus_width - 2 * ic_abacus_frame_width; #declare ic_abacus_space_height = ic_abacus_height - 2 * ic_abacus_frame_width; #declare ic_abacus_space_HX = ic_abacus_space_width / 2; #declare ic_abacus_space_HZ = ic_abacus_space_height / 2; #declare ic_abacus_slider_scaled_width = (ic_abacus_space_width - ic_abacus_frame_width) / 9; #declare ic_abacus_slider_scale = ic_abacus_slider_scaled_width / (1.02 * ic_abacus_slider_width); #local dx = ic_abacus_slider_scaled_width; #local hx = ic_abacus_space_HX; #local hy = ic_abacus_space_HY; #local hz = ic_abacus_space_HZ; // Properly rotated, scaled, and Y-displaced slider: // (Assumes the abacus is lying flat on a table.) #declare ic_abacus_scaled_slider = object{ic_abacus_slider rotate <0,0,90> scale ic_abacus_slider_scale translate <0, ic_abacus_stick_R - ic_abacus_slider_scale * ic_abacus_slider_hole_R, 0> } #declare ic_abacus_frame_HY = ic_abacus_frame_thickness / 2; #declare ic_abacus_frame_long_side = intersection{ box{ < -(hx + ic_abacus_frame_width), -ic_abacus_frame_HY, -ic_abacus_frame_width >, < +(hx + ic_abacus_frame_width), +ic_abacus_frame_HY, 0 > } plane{<-1,00,+1>, 0 translate <-hx,0,0>} plane{<+1,00,+1>, 0 translate <+hx,0,0>} } #declare ic_abacus_frame_short_side = intersection{ box{ < -(hz + ic_abacus_frame_width), -ic_abacus_frame_HY, -ic_abacus_frame_width >, < +(hz + ic_abacus_frame_width), +ic_abacus_frame_HY, 0 > } plane{<-1,00,+1>, 0 translate <-hz,0,0>} plane{<+1,00,+1>, 0 translate <+hz,0,0>} } #declare ic_abacus_frame_bottom_side = object{ic_abacus_frame_long_side translate <0,0,-hz> texture{ic_abacus_frame_texture} } #declare ic_abacus_frame_top_side = object{ic_abacus_frame_long_side scale <1,1,-1> translate <0,0,+hz> texture{ic_abacus_frame_texture} } #declare ic_abacus_frame_left_side = object{ic_abacus_frame_short_side translate <0,0,-hx> texture{ic_abacus_frame_texture} rotate <0,90,0> } #declare ic_abacus_frame_right_side = object{ic_abacus_frame_short_side scale <1,1,-1> translate <0,0,+hx> texture{ic_abacus_frame_texture} rotate <0,90,0> } #declare ic_abacus_frame_separator_X = - hx + 6 * ic_abacus_slider_scaled_width + ic_abacus_frame_width/2; #declare ic_abacus_frame_separator = box{ < -hz, -ic_abacus_frame_HY, -ic_abacus_frame_width/2 >, < +hz, +ic_abacus_frame_HY, +ic_abacus_frame_width/2 > translate <0,0,ic_abacus_frame_separator_X> texture{ic_abacus_frame_texture} rotate <0,90,0> } #declare ic_abacus_frame = merge{ object{ic_abacus_frame_bottom_side} object{ic_abacus_frame_top_side} object{ic_abacus_frame_left_side} object{ic_abacus_frame_right_side} object{ic_abacus_frame_separator} } #declare ic_abacus_stick = cylinder{ <-(hx + ic_abacus_frame_width/2), 0, 0>, <+(hx + ic_abacus_frame_width/2), 0, 0> ic_abacus_stick_R texture{ic_abacus_stick_texture} } #declare ic_abacus_stick_spacing = ic_abacus_space_height / 4.5; #declare ic_abacus_stick_shift_Y = 0.5*ic_abacus_frame_HY; #local tx1 = texture { ic_abacus_unit_slider_texture } #local in1 = interior { ic_abacus_unit_slider_interior } #local tx5 = texture { ic_abacus_five_slider_texture } #local in5 = interior { ic_abacus_five_slider_interior } // The beads read "1969" - the year when the Computer Science grad course opened. #declare ic_abacus = union{ object{ic_abacus_frame} // Top stick (digit "1"): union{ object{ic_abacus_stick} object{ic_abacus_scaled_slider translate < -hx + 0.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 1.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 2.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 3.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 5.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < +hx - 0.5*dx, 0, 0> texture{ tx5 } interior{ in5 } } object{ic_abacus_scaled_slider translate < +hx - 1.5*dx, 0, 0> texture{ tx5 } interior{ in5 } } translate <0, ic_abacus_stick_shift_Y, +1.5*ic_abacus_stick_spacing> } // Second stick from top (digit "9"): union{ object{ic_abacus_stick} object{ic_abacus_scaled_slider translate < -hx + 0.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 2.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 3.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 4.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 5.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < +hx - 0.5*dx, 0, 0> texture{ tx5 } interior{ in5 } } object{ic_abacus_scaled_slider translate < +hx - 2.5*dx, 0, 0> texture{ tx5 } interior{ in5 } } translate <0, ic_abacus_stick_shift_Y, +0.5*ic_abacus_stick_spacing> } // Third stick from top (digit "6"): union{ object{ic_abacus_stick} object{ic_abacus_scaled_slider translate < -hx + 0.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 1.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 2.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 3.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 5.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < +hx - 0.5*dx, 0, 0> texture{ tx5 } interior{ in5 } } object{ic_abacus_scaled_slider translate < +hx - 2.5*dx, 0, 0> texture{ tx5 } interior{ in5 } } translate <0, ic_abacus_stick_shift_Y, -0.5*ic_abacus_stick_spacing> } // Bottom stick (digit "9"): union{ object{ic_abacus_stick} object{ic_abacus_scaled_slider translate < -hx + 0.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 2.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 3.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 4.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < -hx + 5.5*dx, 0, 0> texture{ tx1 } interior{ in1 } } object{ic_abacus_scaled_slider translate < +hx - 0.5*dx, 0, 0> texture{ tx5 } interior{ in5 } } object{ic_abacus_scaled_slider translate < +hx - 2.5*dx, 0, 0> texture{ tx5 } interior{ in5 } } translate <0, ic_abacus_stick_shift_Y, -1.5*ic_abacus_stick_spacing> } }