<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Bob,
<p>I think what you are asking for is to have a value decay to some arbitrary
limit.&nbsp; You will then need to evaluate the current value at some regular
interval, but you don't know ahead of time what the interval will be.
<p>I guess what I see this working out to be is a curve that at the intial
point of the problem has some derivative that is not zero.&nbsp; At the
final point, its derivative is zero.
<p>What kind of a curve you use to figure this out is dependent on what
kind of motion you want the object to have.
<p>A "simple" deceleration will generate a straight line, the velocity
dropping steadily as you appoach the end point.
<p>More gradual deceleration, more like a car braking with most of the
slowing done in the late part of the path, would be more like a parabola.
<p>This kind of motion is well described in the&nbsp; <a href="http://www.puzzlecraft.com/cm/ClockMod.html">Clock
Mod Tutorial</a> .&nbsp; You should check it out.
<p>Randy
<p>=Bob= wrote:
<blockquote TYPE=CITE>Hi Tor,
<p>Thanks again for helping me. I think either I didn't
<br>explain my needs correctly, or I don't understand
<br>how to implement your suggestions for my case.
<p>Here's my scenario:
<p>I have 62 meters over which I must move an object.
<br>It is currently moving at 1 meter per sec.
<br>I want to come to a complete stop when I get to 62 meters.
<br>I want to gradually slow down for the duration of those 62 meters.
<br>I have no idea how many steps it will take.
<p>The magic number for this example is about 0.008009
<p>As I subtract the magic number from the current
<br>increment value (starting at 1), when I reach the 62
<br>meter mark, the increment value is very close to 0.
<p>Code snippet kluge:
<br>================================
<br>#declare len = 62;
<br>#declare inc = 1;
<br>#declare currpos = 0;
<br>#declare incChg = 0.008009;&nbsp; // how do I calculate this number?
<br>#declare nStepCt = 0;
<p>#while (currpos &lt;= len &amp; inc >= incChg)
<br>&nbsp;&nbsp; #debug concat("CurrPos: ",str(currpos,0,-1),"&nbsp; Inc:
",str(inc,0,-1),"\n")
<br>&nbsp;&nbsp; #declare inc = inc - incChg;
<br>&nbsp;&nbsp; #declare currpos = currpos + inc;
<br>&nbsp;&nbsp; #declare nStepCt = nStepCt + 1;
<br>#end // while
<p>#debug concat("Steps: ",str(nStepCt,0,-1)," incChg: ",str(incChg,0,-1),"\n")
<br>==================================
<br>This takes 124 steps to complete.
<p>How do I calculate the value of "incChg" ?
<br>Maybe there's a better way to do this?
<br>Thanks again for your kind help...
<br>=Bob=</blockquote>
</html>