Constructors Summary |
---|
public LeafMotionSegment(LeafMotionSegment prevSegment, float x2, float y2, AnimateMotion motion)Builds a new motion segment for the given previous segment and
end value.
start = prevSegment.end;
end = new float[6][1];
end[4][0] = x2;
end[5][0] = y2;
computeRotate(motion);
|
public LeafMotionSegment(float x1, float y1, float x2, float y2, AnimateMotion motion)Builds a new motion segment for the given start and end
points.
start = new float[6][1];
end = new float[6][1];
start[0][0] = 1;
start[3][0] = 1;
start[4][0] = x1;
start[5][0] = y1;
end[4][0] = x2;
end[5][0] = y2;
computeRotate(motion);
|
Methods Summary |
---|
public void | addToEnd(java.lang.Object[] by)Adds the input value to this Segment's end value.
float[][] add = (float[][]) by;
// Adding motion segments is equivalent to concatenating transforms.
// So the result of adding the input value to the end is equivalent
// to concatenating the by value matrix to the end value matrix.
float[][] tmpEnd = new float[6][1];
tmpEnd[0][0] = end[0][0] * add[0][0] + end[2][0] * add[1][0];
tmpEnd[1][0] = end[1][0] * add[0][0] + end[3][0] * add[1][0];
tmpEnd[2][0] = end[0][0] * add[2][0] + end[2][0] * add[3][0];
tmpEnd[3][0] = end[1][0] * add[2][0] + end[3][0] * add[3][0];
tmpEnd[4][0] = end[0][0] * add[4][0] + end[2][0] * add[5][0]
+ end[4][0];
tmpEnd[5][0] = end[1][0] * add[4][0] + end[3][0] * add[5][0]
+ end[5][0];
end = tmpEnd;
|
public void | collapse(Segment seg, Animation anim)Collapses this segment with the one passed as a parameter.
Note that if the input segment is not of the same class
as this one, an IllegalArgumentException is thrown. The
method also throws an exception if the input segment's
end does not have the same number of components as this
segment's end.
After this method is called, this segment's end value
is the one of the input seg parameter.
LeafMotionSegment mseg = (LeafMotionSegment) seg;
end = mseg.end;
computeRotate((AnimateMotion) anim);
|
public void | compute(float p, float[][] w)Computes an interpolated value for the given penetration in the
segment.
// The rotation component is kept in the end value.
// The translation is an interpolation of the begin and
// end values.
w[0][0] = end[0][0];
w[1][0] = end[1][0];
w[2][0] = end[2][0];
w[3][0] = end[3][0];
w[4][0] = p * end[4][0] + (1 - p) * start[4][0];
w[5][0] = p * end[5][0] + (1 - p) * start[5][0];
|
void | computeRotate(AnimateMotion motion)Computes the rotation component on the end value.
float cosRotate = motion.cosRotate;
float sinRotate = motion.sinRotate;
if (motion.rotateType != AnimateMotion.ROTATE_ANGLE) {
float dx = end[4][0] - start[4][0];
float dy = end[5][0] - start[5][0];
float theta = MathSupport.atan2(dy, dx);
if (motion.rotateType == AnimateMotion.ROTATE_AUTO_REVERSE) {
theta += MathSupport.PI;
}
cosRotate = MathSupport.cos(theta);
sinRotate = MathSupport.sin(theta);
}
end[0][0] = cosRotate;
end[1][0] = sinRotate;
end[2][0] = -sinRotate;
end[3][0] = cosRotate;
|
public java.lang.Object[] | getEnd()
return end;
|
public float | getLength()Computes the 'motion' length for this segment
float dx = end[4][0] - start[4][0];
float dy = end[5][0] - start[5][0];
return MathSupport.sqrt(dx * dx + dy * dy);
|
public java.lang.Object[] | getStart()
return start;
|
public void | initialize()Should be called after the segment's configuration is complete
to give the segment's implementation a chance to initialize
internal data and cache values.
|
public boolean | isAdditive()
return true;
|
public void | setStart(java.lang.Object[] newStart)Sets the start value.
start = (float[][]) newStart;
|
public void | setZeroStart()Sets the start value to its notion of 'zero'
start[4][0] = 0;
start[5][0] = 0;
|