Перехват восхода на самолете
Я хочу рассчитать прогнозируемое время ближайшего сближения между самолетом и восходом или заходом солнца с учетом:
Самолет летит в юго-западном направлении по мере приближения восхода солнца Красная линия - это трасса Большого круга на самолете. Синий круг - это Самолет. момент пересечения с восходом и самолетом
1- Склонение Солнца (широта) и пересечение Долгота известны, плюс радиус восхода, который составляет приблизительно 5450 морских миль, поэтому восход солнца может быть показан в виде круга с известным центром и радиусом.
2- Я использовал 2D векторный код, который не работал, так как путь большого круга не может быть применен к плоскости XY.
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#.
Все, что я ищу, это алгоритм. и как изобразить скорость полета самолета как скорость Vector2D или Vector3D.