Java Reference
In-Depth Information
mGroup based on linear interpolating between a set of specified positions or knots. In
particular, in this interpolator, the interpolated position is used to generate a translation
transform of the local coordinate system. With the first and last knots associated with alpha
values of 0.0f and 1.0f, respectively, an intermediate knot with index k will have an alpha
value larger than those with indices less than k.
In Figure 2, a visual object is programmed to move in an anti-clockwise circular motion
about the z-axis. Lines 13 to 17 specify a loop that gives rise to 18 points uniformly spaced
on a circle of radius 0.5. PositionPathInterpolator is then invoked based on these points so
that the visual object undergoes basically a circular motion.
Note that instead of defining points along a circular path and then using PositionPa-
thInterpolator, rotation can also be achieved by using the RotationInterpolator class, which
will be illustrated in the next section.
rotationInterpolator
This interpolator corresponds to a behavior class through which a visual object can be made
to rotate (Palmer, 2001). The rotation is, by default, about the y-axis.
In the example of Figure 3, a trapezium is made to turn from an initial to a final angle
by using RotationInterpolator. Line 5 specifies a bounding sphere for a live region to allow
for the movement of the object. This is followed by declaring an alpha object on the char-
acteristic of the motion. Both INCREASING_ENABLE and DECREASING_ENABLE
are used so that the rotation is smooth.
Line 13 invokes the RotationInterpolator, with input arguments given by the defined
alpha and the TransformGroup for the visual object. By default, this RotationInterpolator
will rotate the object about the y-axis. In the event that rotation about another axis is needed,
an appropriate Transform3D will have to be supplied for changing the rotation axis.
rotationpathInterpolator
The RotationInterpolator discussed in the last section makes use of a rotation matrix to
effect rotation, which is limited to that about a main coordinate axis. For rotation about
any direction, the class of RotationPathInterpolator can be used.
RotationPathInterpolator uses quaternions in the form q = [ x y z w ] to specify the
rotation needed. Specifically, for rotation by an angle, 2b, about an axis given by (ax, ay,
az), q will be given by
w = cos(b)
x = ax sin(b)
Search WWH ::




Custom Search