/** * @(#) $RCSfile: RoboMetricsInit.as,v $ $Revision: 1.3 $ $Date: 2003/04/22 14:28:12 $ * * Copyright 2003 Orgdot AS. All Rights Reserved. * http://dev.swfit.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * Init script for the geometric robot. Measure all parts. We work with 4*360 * degrees to a circle when computing sin / cos, or the motion gets choppy. * See TrigonometryTable.as for details. * * @author Olaf Havnes * @version $Revision: 1.3 $ $Date: 2003/04/22 14:28:12 $ * @since SWFIT1.0 */ // Hook up to the ground generator later. GROUND = 80; GROUND_SPEED = -1; // Constants for the downward pull. BODY_ACC = 2.0; LEG_PUSH_ACC = 0.8; BODY_FR = 0.1; body_speed = 0; // Create the necessary legs. i = 1; while (i < body.NUM_PEGS) { leg_name = "leg_" add i; duplicateMovieClip ("leg_0", leg_name, i); i++; } /** * Compute the swing data for the legs. */ // Find the radius of the leg anchor point. leg_center_radius = eval ("/:COS_" add int (body.peg_angle_step_half)) * body.peg_center_radius; // If the legs and pegs had no body, the legs could have swung 180 degrees. But ... peg_leg_dist = Math.sqrt (body.peg_center_radius * body.peg_center_radius - leg_center_radius * leg_center_radius); peg_leg_body = body.peg_radius + leg_0.leg_width / 2; // The asin function returns regular degrees... no_swing_angle = 2 * eval ("/:ASIN_" add int (100 * peg_leg_body / peg_leg_dist)); // ... but we need more trig values to achieve smooth motion. full_swing_angle = (180 - no_swing_angle) * /:DEG_MULT; half_swing_angle = full_swing_angle / 2; no_swing_angle *= /:DEG_MULT;