-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposition.cpp
More file actions
60 lines (48 loc) · 1.52 KB
/
position.cpp
File metadata and controls
60 lines (48 loc) · 1.52 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
56
57
58
59
60
#include <vector>
#include <cmath>
#include <setup.h>
#include <iostream>
struct cart
{
double x, y, z;
};
struct polar
{
double rho, theta, phi;
};
double euclidian(cart p1, cart p2)
{
return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2) + pow(p1.z - p2.z, 2));
}
cart triangulatePosition(cart reference, cart nozzle, const std::vector<cart> &receivers)
{
for (const auto &receiver : receivers)
{
double dist_ref = euclidian(reference, receiver);
double dist_nozzle = euclidian(nozzle, receiver);
// triangulation stuff
}
cart computed_position = {0.0, 0.0, 0.0}; // Placeholder
return computed_position;
}
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;
}