home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / maj / 4352 / minfall.nlr < prev    next >
Text File  |  1993-12-11  |  2KB  |  48 lines

  1. /*
  2.  * An object begins a fall from position (1000,0), sliding along a frictionless
  3.  * guide to position (px,py). It then slides along another guide
  4.  * from (px,py) to position (0,1000).  Find px and py that minimize descent time.
  5.  * The minimum value of the function found by Nonlin is the descent time in
  6.  * seconds.  All coordinates are in centimeters.
  7.  */
  8.     Title "Two segment path for fastest descent";
  9.     Parameter px;        // X coordinate of bend
  10.     Parameter py;        // Y coordinate of bend
  11.     Constrain px=.1,999;    // px must be in range 0 < px < d
  12.     Constrain py=.1,999;    // py must be in range 0 < py < h
  13.     Double G=980;        // Acceleration of gravity = 980 cm/sec^2
  14.     Double sx=0, sy=1000;    // Starting x and y coordinate
  15.     Double ex=1000, ey=0;    // Ending x and y coordinate
  16.     Double d1,d2;        // Length of each segment
  17.     Double a1,a2;        // Acceleration along each segment
  18.     Double t1,t2;        // Fall time along each segment
  19.     Double s1;        // Speed at end of segment 1
  20. /*
  21.  *  Determine length of each segment.
  22.  */
  23.     d1 = sqrt((px-sx)*(px-sx) + (py-sy)*(py-sy));
  24.     d2 = sqrt((px-ex)*(px-ex) + (py-ey)*(py-ey));
  25. /*
  26.  *  Determine acceleration for each segment (proportional to slope).
  27.  */
  28.     a1 = G*(sy-py)/d1;
  29.     a2 = G*(py-ey)/d2;
  30. /*
  31.  *  Determine time for segment 1 (starting speed is 0).
  32.  */
  33.     t1 = sqrt(2.*d1/a1);
  34. /*
  35.  *  Determine speed at end of segment 1.
  36.  */
  37.     s1 = a1 * t1;
  38. /*
  39.  *  Determine time for segment 2 (speed is s1 at start of segment).
  40.  */
  41.     t2 = (sqrt(s1*s1 + 2.*a2*d2) - s1) / a2;
  42. /*
  43.  *  Minimize the total fall time.
  44.  */
  45.     function t1 + t2;
  46.     Data;
  47.  
  48.