-
Notifications
You must be signed in to change notification settings - Fork 5
/
VERA.h
53 lines (42 loc) · 1.57 KB
/
VERA.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include "pch.h"
#include "Constants.h"
#include <EuroScopePlugIn.h>
using namespace std;
using namespace EuroScopePlugIn;
class VERA
{
public:
struct VERADataStruct {
int minDistanceSeconds = -1;
double minDistanceNm = -1;
CPosition predictedFirstPos, predictedSecondPos;
};
static VERADataStruct Calculate(CRadarTarget FirstTarget, CRadarTarget SecondTarget, int time_to_extrapolate = 30) {
CPosition Prediction;
CPosition PredictionOther;
CPosition FirstTargetPos = FirstTarget.GetPosition().GetPosition();
CPosition SecondTargetPos = SecondTarget.GetPosition().GetPosition();
VERADataStruct defaultOut;
VERADataStruct out;
double lastDistance = FirstTargetPos.DistanceTo(SecondTargetPos);
for (int i = 30; i <= 60 * time_to_extrapolate; i += 10) {
Prediction = Extrapolate(FirstTargetPos, FirstTarget.GetTrackHeading(),
FirstTarget.GetPosition().GetReportedGS() * 0.000277778 * i);
PredictionOther = Extrapolate(SecondTargetPos, SecondTarget.GetTrackHeading(),
SecondTarget.GetPosition().GetReportedGS() * 0.000277778 * i);
// The distance started to increase, we passed the minimum point
if (Prediction.DistanceTo(PredictionOther) > lastDistance) {
if (lastDistance == FirstTargetPos.DistanceTo(SecondTargetPos))
return defaultOut;
out.minDistanceSeconds = i;
out.minDistanceNm = Prediction.DistanceTo(PredictionOther);
out.predictedFirstPos = Prediction;
out.predictedSecondPos = PredictionOther;
return out;
}
lastDistance = Prediction.DistanceTo(PredictionOther);
}
return defaultOut;
};
};