1
0
Fork 0

- Jettoo (glazmax) and Alexis: Radar Visibility Calculator.

This commit is contained in:
abory 2008-06-05 19:37:32 +00:00
parent f8f63fcd8d
commit 40d9b0e400

View file

@ -0,0 +1,189 @@
### Radar Visibility Calculator
# Jettoo (glazmax) and xiii (Alexis)
# my_maxrange(myaircraft): finds our own aircraft max radar range in a table.
# Returns my_radarcorr in kilometers.
# radis(i, my_radarcorr): find multiplayer[i], its Radar Cross Section (RCS),
# applies factor upon our altitude, shorter radar detection distance (due to air
# turbulence), then factor upon its altitude above ground, and finaly computes if
# it is detectable given our radar range.
# Returns 1 if detectable, 0 if not.
var FT2M = 0.3048;
var NM2M = 1852;
var my_maxrange = func(myaircraft) {
var myacname = aircraftData[myaircraft];
if (myacname == nil){
myacname = 0;
}
var my_radar_area = radarData[myacname][7];
var my_radar_range = radarData[myacname][5];
return( my_radar_range / my_radar_area);
#var my_plane = radarData[myacname][2];
#print (my_plane);
#print (my_radar_area);
}
var radis = func(i, my_radarcorr) {
# Get the multiplayer aircraft name.
var mpnode_string = "ai/models/multiplayer[" ~ i ~ "]";
var mpnode = props.globals.getNode(mpnode_string);
var mpname_node_string = mpnode_string ~ "/sim/model/path";
var mpname_node = props.globals.getNode(mpname_node_string);
if (mpname_node != nil) {
var mpname = mpname_node.getValue();
if (mpname != nil) {
var splitname = split("/", mpname);
#debug.dump(splitname);
var cutname = splitname[1];
#print (cutname);
# Calculate the rcs detection range,
# if aircraft is not found in list, 0 (generic) will be used.
var acname = aircraftData[cutname];
if (acname == nil) { acname = 0 }
var rcs_4r = radarData[acname][3];
var radartype = radarData[acname][1];
# Add a correction factor for altitude, as lower alt means
# shorter radar distance (due to air turbulence).
var alt_corr = 1;
var alt_ac = mpnode.getNode("position/altitude-ft").getValue();
if (alt_ac <= 1000) {
alt_corr = 0.6;
} elsif ((alt_ac > 1000) and (alt_ac <= 5000)) {
alt_corr = 0.8;
}
# Add a correction factor for altitude AGL.
var agl_corr = 1;
var mp_lon = mpnode.getNode("position/longitude-deg").getValue();
var mp_lat = mpnode.getNode("position/latitude-deg").getValue();
var mp_pos = geo.Coord.new().set_latlon(mp_lat, mp_lon);
var pos_elev = geo.elevation(mp_pos.lat(), mp_pos.lon());
var mp_agl = alt_ac - ( pos_elev / FT2M );
if (mp_agl <= 20) {
agl_corr = 0.03;
} elsif ((mp_agl > 20) and (mp_agl <= 50)) {
agl_corr = 0.08;
} elsif ((mp_agl > 50) and (mp_agl <= 120)) {
agl_corr = 0.8;
}
# Calculate the detection distance.
var det_range = my_radarcorr * rcs_4r * alt_corr * agl_corr;
#print (radartype);
#print (rcs_4r);
#print (det_range);
### Compare if aircraft is in detection range and return.
var act_range = mpnode.getNode("radar/range-nm").getValue();
if ((act_range == nil) or (act_range == 0)) {
act_range = 500;
}
if ((det_range / NM2M) >= act_range) {
return(1);
}
}
}
return(0);
}
### convert aircraft to lookup number for table below:
aircraftData = {
"generic" : "0",
"707" : "1",
"737-300" : "2",
"747" : "3",
"787" : "4","777" : "4",
"A24-Viking" : "5",
"A-10" : "6",
"A300" : "7",
"A320" : "8",
"A380" : "9",
"a4" : "10",
"A-6E" : "11",
"A6M2" : "12",
"Albatross" : "13",
"Aerostar-700" : "14",
"Alouette-II" : "15",
"Alouette-III" : "16",
"Alphajet" : "17",
"an-2" : "18",
"AN-225" : "19",
"apache" : "20",
"ASK21" : "21","asw20" : "21","bocian" : "21",
"b1900d" : "22",
"B-1B" : "23",
"B-2" : "24",
"b29" : "25",
"B-52F" : "26",
"BAC-TSR2" : "27",
"beaufighter" : "28",
"bf109" : "29",
"Buccaneer" : "30",
"c310" : "31","c310u3a" : "31",
"c172" : "32","c172p" : "32","c172r" : "32",
"c182" : "32","c182rg" : "32",
"f-14b" : "33",
"f15" : "34","f15c" : "34",
"f16" : "35",
"Lightning" : "36",
"SR71-Blackbird" : "37",
"Tornado" : "38"
};
### radar lookup table , consisting aircraft name, RCS(m2), 4th root of RCS, radar type, max. radar range(km), max. radar range target seize(RCS)m2, 4th root of radar RCS
radarData = [
[0, "generic", 5, 1.49, "APG-63", 150, 100, 3.16],
[1, "707", 30, 2.34, "none", 0, 0, 0],#guess
[2, "737", 20, 2.11, "none", 0, 0, 0],#guess
[3, "747", 30, 2.34, "none", 0, 0, 0],#guess
[4, "787", 12, 1.86, "none", 0, 0, 0],#guess
[5, "A24-Viking", 2, 1.19, "none", 0, 0, 0],#guess
[6, "A-10", 25, 2.23, "none", 0, 0, 0],
[7, "A300", 25, 2.23, "none", 0, 0, 0],#guess
[8, "A320", 15, 1.96, "none", 0, 0, 0],#guess
[9, "A380", 20, 2.11, "none", 0, 0, 0],#guess
[10, "a4", 10, 1.77, "APG-53", 15, 5, 1.49],
[11, "A-6E", 14, 1.93, "APQ-112", 150, 100, 3.16],
[12, "A6M2", 15, 1.96, "none", 0, 0, 0],#guess
[13, "Albatross", 40, 2.51, "none", 0, 0, 0],#guess
[14, "Aerostar-700", 10, 1.86, "none", 0, 0, 0],#guess
[15, "Alouette-II", 15, 2.51, "none", 0, 0, 0],#guess
[16, "Alouette-III", 20, 2.11, "none", 0, 0, 0],#guess
[17, "Alphajet", 5, 1.49, "none", 0, 0, 0],#guess
[18, "an-2", 2, 1.19, "none", 0, 0, 0],#guess
[19, "AN-225", 45, 2.59, "unknown", 0, 0, 0],#guess
[20, "apache", 30, 2.34, "APG-78", 8, 1, 1],#guess
[21, "ASK21", 1, 1, "none", 0, 0, 0],#guess
[22, "b1900d", 20, 2.11, "wx500", 60, 100, 3.16],#guess
[23, "B-1B", 4, 1.41, "APQ-164", 296, 100, 3.16],
[24, "B-2", 0.0015, 0.19, "APQ-181", 333, 100, 3.16],
[25, "b29", 100, 3.16, "APQ-19", 45, 100, 3.16],
[26, "B-52F", 100, 3.16, "APQ-166", 296, 100, 3.16],
[27, "BAC-TSR2", 10, 1.86, "Blue Parrot", 46, 100, 3.16],
[28, "beaufighter", 9, 1.73, "none", 0, 0, 0],
[29, "bf109", 15, 1.96, "none", 0, 0, 0],
[30, "Buccaneer", 10, 1.77, "Blue Parrot", 46, 100, 3.16],
[31, "c310", 4, 1.41, "none", 0, 0, 0],
[32, "c172", 2, 1.19, "none", 0, 0, 0],
[33, "f-14b", 25, 2.23, "AWG-9", 333, 100, 3.16],
[34, "f-15", 30, 2.34, "APG-70", 185, 100, 3.16],
[35, "f16", 1.5, 1.11, "APG-68", 296, 100, 3.16],
[36, "Lightning", 5, 1.49, "AI-23", 111, 100, 3.16],
[37, "SR71", 0.015, 0.35, "APQ-108", 200, 100, 3.16],#range classified
[38, "Tornado", 7, 1.63, "Foxhunter", 210, 100, 3.16]
];