// Last edited on 2011-02-14 02:25:31 by stolfilocal // Processed by remove-cam-lights #macro jumper( L_upp, L_low, L_fot, R_leg, tx_leg, L_bod, R_bod, tx_bod, A_hip_0, A_kne_0, A_ank_0, A_hip_1, A_kne_1, A_ank_1 ) // The jolly jumper. // Parameters: // // {L_upp} = length of upper leg. // {L_low} = length of lower leg. // {L_fot} = length of foot. // {R_leg} = radius of leg. // {tx_leg} = texture of leg. // {L_bod} = length of body. // {R_bod} = radius of body. // {tx_bod} = texture of body. // {A_hip_0,A_hip_1} = angles of upper legs at hip, left and right. // {A_kne_0,A_kne_1} = angles of knees, left and right. // {A_ank_0,A_ank_1} = angles of ankle, left and right. // // The jumper has its lowest point on the Z=0 plane. // That is usually the tip or heel of one foot, but may be otherwise. // The midpoint of the two ankles is on the Z-axis. #local L_fot_fw = 0.8*L_fot; // Lengh of foot forward from ankle point. #local L_fot_bw = L_fot - L_fot_fw; // Lengh of foot backward from ankle point. #local L_bod_up = 0.75*L_bod; // Length of body above hips. #local L_bod_dn = L_bod - L_bod_up; // Length of body below hips. #macro jumper_foot(tx) #local btoe = <0,L_fot_fw,0>; #local heel = <0,-L_fot_bw,0>; union{ sphere{ heel, R_leg } // Heel. cylinder{ heel, btoe, R_leg } // Foot. sphere{ btoe, R_leg } // Toe. texture{ tx } } #end #macro jumper_shin_and_foot(A_ank, tx) #local knee = <0,0,0>; #local ankle = <0,0,-L_low>; union{ union{ sphere{ knee, R_leg } // Knee joint. cylinder{ knee, ankle, R_leg } // Shin. texture{ tx } } object{ jumper_foot(tx) rotate A_ank*x translate ankle } } #end #macro jumper_leg(A_kne,A_ank,tx) #local hip = <0,0,0>; #local knee = <0,0,-L_upp>; union{ union{ sphere{ hip, R_leg } // Hip joint. cylinder{ hip, knee, R_leg } // Thigh. texture{ tx } } object{ jumper_shin_and_foot(A_ank,tx) rotate A_kne*x translate knee } } #end #macro jumper_body(tx) // Body with hips at origin. #local body_top = <0, 0, +L_bod_up>; #local body_bot = <0, 0, -L_bod_dn>; #local body_ctr = (body_top + body_bot)/2; sphere{ <0,0,0>,1 scale < R_bod, R_bod, L_bod/2 > translate body_ctr texture{ tx } } #end #macro jumper_leg_bottom(A_hip, A_kne, A_ank) // Displacement of leg from hip to bottom of ankle. // The X coordinate is zero. // The Y coord is that of the ankle. // The Z coord is that of the lowest point in the entire leg, // excluding foot but including ankle ball. // Inclinations from vertical towards +Y: #local a_thigh = radians(A_hip); #local a_shin = a_thigh + radians(A_kne); // #local a_foot = a_shin + radians(A_ank + 90); // Z heights of leg joints: #local z_knee = -L_upp*cos(a_thigh); #local z_ankle = z_knee - L_low*cos(a_shin); // #local z_btoe = z_ankle - L_fot_fw*cos(a_foot); // #local z_heel = z_ankle + L_fot_bw*cos(a_foot); // #local z_min = min(0, min(z_knee, min(z_ankle, min(z_heel, z_btoe)))) - R_leg; #local z_min = min(0, min(z_knee, z_ankle)) - R_leg; #local y_knee = L_upp*sin(a_thigh); #local y_ankle = y_knee + L_low*sin(a_shin); // result: < 0, y_ankle, z_min > #end #local z_bct = (L_bod_up - L_bod_dn)/2; // Z of body center. #local z_brd = L_bod/2; // Z half-extent of body. #local s_bod = z_bct/z_brd; #local x_leg = R_bod * sqrt(1 - s_bod*s_bod); #local v_leg_0 = jumper_leg_bottom(A_hip_0, A_kne_0, A_ank_0); #local v_leg_1 = jumper_leg_bottom(A_hip_1, A_kne_1, A_ank_1); #local z_lowest = min(v_leg_0.z, v_leg_1.z); #local y_midank = (v_leg_0.y + v_leg_1.y)/2; union{ union{ object{ jumper_body(tx_bod) } object{ jumper_leg(A_kne_0,A_ank_0,tx_leg) rotate A_hip_0*x scale <+1,+1,+1> translate +x_leg*x } object{ jumper_leg(A_kne_1,A_ank_1,tx_leg) rotate A_hip_1*x scale <-1,+1,+1> translate -x_leg*x } // Place the ankle on z-axis, with leg supported by Z=0 plane: translate < 0, -y_midank, -z_lowest > } // eixos(20.0) } #end