Point2D.Double x の距離を別の Point2D.Double に近づける最善の方法は何ですか?
編集: 編集しようとしましたが、メンテナンスのためにダウンしました。いいえ、これは宿題ではありません
飛行機 (A) を滑走路 (C) の端に向かって移動させ、正しい方向 (角度 a) に向ける必要があります。
代替テキスト http://img246.imageshack.us/img246/9707/planec.png
これが私がこれまでに持っているものですが、面倒なようです。このようなことをする通常の方法は何ですか?
//coordinate = plane coordinate (Point2D.Double)
//Distance = max distance the plane can travel in this frame
Triangle triangle = new Triangle(coordinate, new Coordinate(coordinate.x, landingCoordinate.y), landingCoordinate);
double angle = 0;
//Above to the left
if (coordinate.x <= landingCoordinate.x && coordinate.y <= landingCoordinate.y)
{
angle = triangle.getAngleC();
coordinate.rotate(angle, distance);
angle = (Math.PI-angle);
}
//Above to the right
else if (coordinate.x >= landingCoordinate.x && coordinate.y <= landingCoordinate.y)
{
angle = triangle.getAngleC();
coordinate.rotate(Math.PI-angle, distance);
angle = (Math.PI*1.5-angle);
}
plane.setAngle(angle);
三角形のクラスは、http://pastebin.com/RtCB2kSZにあります。
飛行機は滑走路ポイントの周りの任意の位置にある可能性があることを念頭に置いてください