bloodvlad
bloodvlad

Reputation: 13

Counter the slowdown

I have a counter. After N time it increases by one. Which algorithm do I change the number N, to counter increased rapidly at first, and finally slowed down.

Thanks.

UPD: Source code on Java:

currentProcent = 0;
deltaSecond = 3000f / (float) bigProcNumber;    // 3000f - 3 second, is fixed
new Thread(new Runnable() {
   public void run() {
      try {
         while (currentProc != (int) bigProcNumber) {
            Thread.sleep((int) (deltaSecond));
            // UI Change
         }
      } catch (InterruptedException e) {
         e.printStackTrace();
      }
   }
}).start();

I need to change the deltatime, but it is necessary that the sum of all deltatimes was equal to 3000 milliseconds.

Upvotes: 0

Views: 128

Answers (2)

Fred Klingener
Fred Klingener

Reputation: 146

  1. Uppercase 'N' is reserved. Don't use is as a variable name.

  2. It sounds like you want to build a clock counter with a variable rate. Mathematica has a couple of different ways to control clocks, and they have different characteristics. (look at Pause[], the functions related to CreateScheduledTask[] or controlling update intervals in Dynamic e.g.) Give us more hints of what you're trying to do. Example code is good.

  3. Here's an example of a Pause-based timer.

    t = 0;
    Manipulate[
     t += dt;
     Pause[dt]; 
     Graphics[{Circle[], 
     Line[{{0., 0.}, {Cos[t/(2 Pi)], -Sin[t/(2 Pi)]}}]}]
     {{dt, 0.5}, 0.1, 1, 0.1, PopupMenu}
    ]
    
  4. Be careful using timers around Dynamic. Here's an example using Dynamic to control the clock.

    Manipulate[
     DynamicModule[{t = 0},
      Graphics[{
       Circle[], 
       Line[{{0., 0.}, {Cos[#/(2 Pi)], -Sin[#/(2 Pi)]} &@
        Dynamic[t += dt, UpdateInterval -> dt]}]
      }]
     ]
    ,{{dt, 0.5}, 0.1, 1, Appearance -> "Labeled"}
    ]
    

Upvotes: 1

High Performance Mark
High Performance Mark

Reputation: 78364

If I interpret your question correctly you want to find a function which increases rapidly at first and more slowly later, something with a shape like this perhaps ?

enter image description here

I made the graphic using the Log function which would probably be suitable, but there are many others.

Upvotes: 2

Related Questions