-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.cpp
More file actions
55 lines (43 loc) · 1.57 KB
/
setup.cpp
File metadata and controls
55 lines (43 loc) · 1.57 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
53
54
55
#include <vector>
#include <cmath>
#include <iostream>
struct cart
{
double x, y, z;
};
struct polar
{
double rho, theta, phi;
};
cart receiver_abs_location(cart reference, polar receiver_rel_location)
{
cart receiver_absolute;
double x_rel = receiver_rel_location.rho * sin(receiver_rel_location.phi) * cos(receiver_rel_location.theta);
double y_rel = receiver_rel_location.rho * sin(receiver_rel_location.phi) * sin(receiver_rel_location.theta);
double z_rel = receiver_rel_location.rho * cos(receiver_rel_location.phi);
receiver_absolute.x = reference.x + x_rel;
receiver_absolute.y = reference.y + y_rel;
receiver_absolute.z = reference.z + z_rel;
return receiver_absolute;
}
int main()
{
cart reference = {0, 0, 0}; // known reference point
int n_recievers = 3;
// Example polar coordinates with values for rho (distance), theta (azimuthal angle in radians), and phi (polar angle in radians)
std::vector<polar> radar_reciever_data = {
{10, 0.785, 1.047}, // rho = 10, theta = 45°, phi = 60°
{15, 1.570, 1.570}, // rho = 15, theta = 90°, phi = 90°
{20, 2.356, 0.785} // rho = 20, theta = 135°, phi = 45°
};
std::vector<cart> absolute_reciever_positions(n_recievers);
for (int i = 0; i < n_recievers; i++)
{
absolute_reciever_positions[i] = receiver_abs_location(reference, radar_reciever_data[i]);
}
for (const auto &pos : absolute_reciever_positions)
{
std::cout << "Receiver Position: (" << pos.x << ", " << pos.y << ", " << pos.z << ")\n";
}
return 0;
}