航空機と日の出または日没の間の予測最接近時間を計算したい:
飛行機 日の出が近づくと南西方向に飛行 赤い線は飛行機のグレートサークル トラックです。青い丸は飛行機です。 朝日と飛行機が交差する瞬間
1- 太陽 赤緯 (緯度) と交差 経度が既知であり、加えて日の出の半径が約 5450 海里であるため、日の出は既知の中心と半径を持つ円として表示できます。
2- 大円パスを XY 平面に適用できないため、機能しない 2D ベクトル コードを使用しました。
2- 飛行機は湾曲した大円軌道上を飛行しており、緯度の変化は線形ではありません。緯度の変化が一定でない場合、飛行機の速度を速度ベクトルとして使用するにはどうすればよいですか?
/// Va - Velocity of circle A.
Va = new Vector2(450, 0);
私はC#コードを使用しました
/// Calculate the time of closest approach of two moving circles. Also determine if the circles collide.
///
/// Input:
/// Pa - Position of circle A.
/// Pb - Position of circle B.
/// Va - Velocity of circle A.
/// Vb - Velocity of circle B.
/// Ra - Radius of circle A.
/// Rb - Radius of circle B.
// Set up the initial position, velocity, and size of the circles.
Pa = new Vector2(150, 250);
Pb = new Vector2(600, 400);
Va = new Vector2(450, 0);
Vb = new Vector2(-100, -250);
Ra = 60;
Rb = 30;
/// Returns:
/// collision - Returns True if a collision occured, else False.
/// The method returns the time to impact if collision=true, else it returns the time of closest approach.
public float TimeOfClosestApproach(Vector2 Pa, Vector2 Pb, Vector2 Va, Vector2 Vb, float Ra, float Rb, out bool collision)
{
Vector2 Pab = Pa - Pb;
Vector2 Vab = Va - Vb;
float a = Vector2.Dot(Vab, Vab);
float b = 2 * Vector2.Dot(Pab, Vab);
float c = Vector2.Dot(Pab, Pab) - (Ra + Rb) * (Ra + Rb);
// The quadratic discriminant.
float discriminant = b * b - 4 * a * c;
// Case 1:
// If the discriminant is negative, then there are no real roots, so there is no collision. The time of
// closest approach is then given by the average of the imaginary roots, which is: t = -b / 2a
float t;
if (discriminant < 0)
{
t = -b / (2 * a);
collision = false;
}
else
{
// Case 2 and 3:
// If the discriminant is zero, then there is exactly one real root, meaning that the circles just grazed each other. If the
// discriminant is positive, then there are two real roots, meaning that the circles penetrate each other. In that case, the
// smallest of the two roots is the initial time of impact. We handle these two cases identically.
float t0 = (-b + (float)Math.Sqrt(discriminant)) / (2 * a);
float t1 = (-b - (float)Math.Sqrt(discriminant)) / (2 * a);
t = Math.Min(t0, t1);
// We also have to check if the time to impact is negative. If it is negative, then that means that the collision
// occured in the past. Since we're only concerned about future events, we say that no collision occurs if t < 0.
if (t < 0)
collision = false;
else
collision = true;
}
// Finally, if the time is negative, then set it to zero, because, again, we want this function to respond only to future events.
if (t < 0)
t = 0;
return t;
}
どの言語でも、どんな回答でも受け付けます。
JAVA , JS, Objective-C , Swift , C#.
私が探しているのはアルゴリズムだけです。飛行機の速度を Velocity Vector2D または Vector3D として表現する方法。