Exemplo n.º 1
0
  private KeyFrame interpolateRotation(KeyFrame start, KeyFrame end, double timestamp) {
    double startAngle = start.getOrientation();
    double endAngle = end.getOrientation();
    double theta = Angle.getRotationAngle(startAngle, endAngle);
    if (end.useRelativeAngle()) {
      theta = endAngle - startAngle;
    }
    double ds = start.getTimestamp();
    double duration = end.getTimestamp() - ds;
    double d = (timestamp - ds) / duration;
    double angle = startAngle + d * theta;
    Point2D p = start.getPosition();

    KeyFrame frame =
        new KeyFrame(
            TrajectoryMovement.ROTATION,
            0,
            angle,
            0,
            start.getRotationSpeed(),
            p,
            timestamp,
            start.getSourceLine());
    return frame;
  }