// Last edited on 2021-04-30 14:02:28 by jstolfi #macro inertial_balance_beam_labels(axis_h,d1,mass_1_r,d2,mass_2_r) // Labels and arrows for the beam and test masses of the inertial balance. // {axis_h} = height of axis above pivot center. // {d1,d2} = distances of test masses from pivot axis. // {mass_1_r,mass_2_r} = radii of test masses. #local ct = <0, 0, 0>; // Center of pivot. #local lthk = 0.01; // Text thickness. #local labs = union{ #local p1 = +d1*y; // Center of object 1 #local p2 = -d2*y; // Center of object 2 #local ofs = (axis_h + 30)*z; // Displacement of {d1,d2} dim arrows. #local arad = 1.0; // Radius of dim arrows. #local rrad = 1.0; // Radius of ref lines. #local arot = < 90, 0, 90 >; // Label rotation. #local aalign = 0.5; // Position of label along arrow. #local ctgap = axis_h + 10; // Ref line gap at pivot. #local p1gap = mass_1_r + 10; // Ref line gap at object 1. #local p2gap = mass_2_r + 10; // Ref line gap at object 2. #local ext = 15; // Overshoot of ref lines. #local lmag = 25*arad; // Label font magnification. #local arot = < 90, 0, 90 >; // Label rotation. #local dlab_1 = object{ inertial_balance_dim_arrow_label( "d" "1", lmag,arot ) } #local dlab_2 = object{ inertial_balance_dim_arrow_label( "d" "2", lmag,arot ) } #local mlab_1 = object{ inertial_balance_gen_label( "m" "1", lmag,<-2.0,-1.0>,arot ) } #local mlab_2 = object{ inertial_balance_gen_label( "m" "2", lmag,<+3.0,-1.0>,arot ) } object{ labeled_arrow( ct,p1, ofs, arad,rrad, dlab_1,aalign, ctgap,ext, p1gap,ext) } object{ labeled_arrow( p2,ct, ofs, arad,rrad, dlab_2,aalign, p2gap,ext, ctgap,ext) } object{ mlab_1 translate +d1*y } object{ mlab_2 translate -d2*y } texture{ tx_arrow } } labs #end #macro inertial_balance_supp_labels(supp_r,fpos_z) // Labels and arrows for the base and support of the inertial balance. // {supp_r} = radius of support. // {fpos_z} = {Z} distance from point of application of force and pivot center. #local ct = <0, 0, 0>; // Center of pivot. #local lthk = 0.01; // Text thickness. #local labs = union{ #local frad = 2.0; // Radius of force arrow. #local frot = < 90, 0, 180 >; // Forde label rotation. #local falign = 0.5; // Position of label along arrow. #local fhlen = 15*frad; // Length of force arrowhead. #local fmag = 25*frad; // Font magnification for force label. #local fq = < base_dim.x/2 + eps, 0, fpos_z >; // Tip of force arrow. #local fp = fq + 230*x; // Base of force arrow. #local flab = object{ inertial_balance_gen_label( "F","", fmag,<-1.0,-0.2>,frot ) } object{ gen_arrow(fp,fq, frad, 1.0,fhlen, 0,0) } object{ flab translate fp } texture{ tx_force } } labs #end #macro inertial_balance_dim_arrow_label( bas,sub, lmag,lrot ) // Creates a label for a dimension arrow with the letter // {bas} in italic subscripted by the letter {sub} in upright font.. // The font for {bas} will be scaled by {lmag}. // The text will be translated so that the orgin is below // the center of the label. #local txt = object{ inertial_balance_bas_sub_label( bas,sub,lmag ) } #local talign = < 0.5, -0.5 >; // Relative ref point of label. // A digit "0" for reference: #local zthk = 0.01; #local zd = text { ttf "arial.ttf" "0" zthk/lmag, 0 scale lmag translate zthk/2*z} #local zdim = max_extent(zd) - min_extent(zd); #local lobj = object{ align_label(txt, zdim, talign,lrot) } lobj #end #macro inertial_balance_gen_label( bas,sub, lmag,talign,lrot ) // Creates a label for a test mass, force arrow, etc. // with the letter {bas} in italic subscripted by the letter {sub} in upright font. // The font for {bas} will be scaled by {lmag}. // The text will be translated so that the point defined by the 2-vector {talign} // is at the origin, and then it will be rotated by the 3-vector {lrot}. #local txt = object{ inertial_balance_bas_sub_label( bas,sub,lmag ) } // A digit "0" for reference: #local zthk = 0.01; #local zd = text { ttf "arial.ttf" "0" zthk/lmag, 0 scale lmag translate zthk/2*z} #local zdim = max_extent(zd) - min_extent(zd); #local lobj = object{ align_label(txt, zdim, talign,lrot) } lobj #end #macro inertial_balance_bas_sub_label( bas,sub,lmag ) // Creates an object that has the the letter // {bas} in italic subscripted by the letter {sub} in upright font. // The origin will be at the lower left of the {bas} text. // If the subscript is "", omits it. #local lthk = 0.01*lmag; // Label thickness. // Base and subscript text objects in their natural coord system: #local mag_bas = lmag; // Font scaling for {bas} #local thk_bas = lthk/mag_bas; // Thickness of {bas} text before font mag. #local txt_bas = text { ttf "ariali.ttf" bas thk_bas, 0 scale mag_bas translate lthk/2*z } #local dim_bas = max_extent(txt_bas) - min_extent(txt_bas); // Dimensions of base text. #if (sub != "") #local mag_sub = 0.75*lmag; // Font scaling for {sub} #local thk_sub = lthk/mag_sub; // Thickness of {sub} text before font mag. #local txt_sub = text { ttf "arial.ttf" sub thk_sub, 0 scale mag_sub translate lthk/2*z } #local dim_sub = max_extent(txt_sub) - min_extent(txt_sub); // Dimensions of subscript text. #local txt = union{ object{ txt_bas } object{ txt_sub translate 1.05*dim_bas.x*x -0.55*dim_sub.y*y } } #else #local txt = object{ txt_bas } #end txt #end