-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (40 loc) · 1.36 KB
/
main.cpp
File metadata and controls
52 lines (40 loc) · 1.36 KB
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
// Description : calculates the maximum detection range of a radar using the basic radar range equation.
// Author : hexpad
#include <iostream>
#include <cmath>
class Radar {
private:
double wLength; // meters
double P; // Watts
double G; // linear
double minPw; // Watts
public:
Radar(double wl, double pwr, double g, double minP)
: wLength(wl), P(pwr), G(g), minPw(minP) {}
// Maximum detection range (simple radar equation)
double computeMaxRange(double targetRCS) {
return std::pow((P * pow(G,2) * pow(wLength,2) * targetRCS) /
(pow(4 * M_PI,3) * minPw), 0.25);
}
};
int main() {
double wLength, P, G, minPw, rcs;
std::cout << "Radar wavelength (m): ";
std::cin >> wLength;
std::cout << "Radar transmit power (W): ";
std::cin >> P;
std::cout << "Antenna gain (linear): ";
std::cin >> G;
std::cout << "Minimum detection power (W): ";
std::cin >> minPw;
std::cout << "Target RCS (m^2): ";
std::cin >> rcs;
Radar radar(wLength, P, G, minPw);
double maxRange = radar.computeMaxRange(rcs);
std::cout << "\nMaximum Detection Range: " << maxRange << " meters\n";
if (maxRange > 0)
std::cout << "Target is detectable within this range.\n";
else
std::cout << "Target not detectable.\n";
return 0;
}