01: package prefuse.activity;
02:
03: /**
04: * A pacing function that provides slow-in, slow-out animation, where the
05: * animation begins at a slower rate, speeds up through the middle of the
06: * animation, and then slows down again before stopping.
07: *
08: * This is calculated by using an appropriately phased sigmoid function of
09: * the form 1/(1+exp(-x)).
10: *
11: * @author <a href="http://jheer.org">jeffrey heer</a>
12: */
13: public class SlowInSlowOutPacer implements Pacer {
14:
15: /**
16: * Pacing function providing slow-in, slow-out animation
17: * @see prefuse.activity.Pacer#pace(double)
18: */
19: public double pace(double f) {
20: return (f == 0.0 || f == 1.0 ? f : sigmoid(f));
21: }
22:
23: /**
24: * Computes a normalized sigmoid
25: * @param x input value in the interval [0,1]
26: */
27: private double sigmoid(double x) {
28: x = 12.0 * x - 6.0;
29: return (1.0 / (1.0 + Math.exp(-1.0 * x)));
30: }
31:
32: } // end of class SlowInSlowOutPacer
|