Graphics Reference
In-Depth Information
Sine interpolation
One easy way to implement ease-in/ease-out is to use the section of the sine curve from
p /2 to
þp /2
as the ease (t) function. This is done by mapping the parameter values of 0 to
þ
1 into the domain
of
p /2 to
þp /2 and then mapping the corresponding range of the sine functions of
1to
þ
1in
the range 0 to 1. See Equation 3.18 and the corresponding Figure 3.11 .
þ
sin t p 2
1
s ¼ easeðtÞ¼
(3.18)
2
In this function, t is the input that is to be varied uniformly from 0 to 1 (e.g., 0.0, 0.1, 0.2, 0.3,
). The
output, s, also goes from 0 to 1 but does so by starting off slowly, speeding up, and then slowing down.
For example, at t ¼
...
0.8535. With the sine/cosine ease-
in/ease-out function presented here, the “speed” of s with respect to t is never constant over an interval,
rather it is always accelerating or decelerating, as can be seen by the ever-changing slope of the curve.
Notice that the derivative of this ease function is 0 at
0.25, ease ( t )
¼
0.1465, and at t ¼
0.75, ease ( t )
¼
1. Zero derivatives at 0 and 1
indicate a smooth acceleration from a stopped position at the beginning of the motion and a
smooth deceleration to a stop at the end.
t ¼
0 and at
t ¼
Using sinusoidal pieces for acceleration and deceleration
To provide an intermediate section of the distance-time function that has constant speed, pieces of the
sine curve can be constructed at each end of the function with a linear intermediate segment. Care must
be taken so that the tangents of the pieces line up to provide first-order continuity. There are various
ways to approach this, but as an example, assume that the user specifies fragments of the unit interval
that should be devoted to initial acceleration and final deceleration. For example, the user may specify
that acceleration ceases at 0.3 and the deceleration starts at 0.75. That is, acceleration occurs from time
0 to 0.3 and deceleration occurs from time 0.75 to the end of the interval at 1.0. Referring to the
user-specified values as k 1 and k 2 respectively, a sinusoidal curve segment is used to implement an
acceleration from time 0 to k 1 . A sinusoidal curve is also used for velocity to implement deceleration
from time k 2 to 1. Between times k 1 and k 2 , a constant velocity is used.
1
0.8
1
0.6
π
/ 2
0.4
0.2
π / 2
1
0.2
0.4
0.6
0.8
1
Time
Sine curve segment to use as ease-in/ease-out
control
Sine curve segment mapped to useful values
FIGURE 3.11
Using a sine curve segment as the ease-in/ease-out distance-time function.
 
Search WWH ::




Custom Search