Merge remote-tracking branch 'origin/smail' into lbaumberger
This commit is contained in:
@@ -33,7 +33,7 @@ Pedestrian *init_pedestrians(int n_p) {
|
||||
for (int i = 0; i < n_p / 2; i++) {
|
||||
double y = y_gen(gen);
|
||||
Vector2d start_pos = Vector2d(x_gen(gen), y);
|
||||
Vector2d destination = Vector2d(BOARD_LENGTH + 300, BOARD_WIDTH / 2);
|
||||
Vector2d destination = Vector2d(BOARD_LENGTH + 30, BOARD_WIDTH / 2);
|
||||
// double desired_v0 = velocity_gen(gen);
|
||||
double desired_v0;
|
||||
do {
|
||||
@@ -46,7 +46,7 @@ Pedestrian *init_pedestrians(int n_p) {
|
||||
for (int i = n_p / 2; i < n_p; i++) {
|
||||
double y = y_gen(gen);
|
||||
Vector2d start_pos = Vector2d(x_gen(gen), y);
|
||||
Vector2d destination = Vector2d(-300, BOARD_WIDTH / 2);
|
||||
Vector2d destination = Vector2d(-30, BOARD_WIDTH / 2);
|
||||
// double desired_v0 = velocity_gen(gen);
|
||||
double desired_v0;
|
||||
do {
|
||||
@@ -88,7 +88,7 @@ int main(int argc, const char *argv[]) {
|
||||
const int dump_interval = 50; // dump every 5 iterations -> 20 fps (since dt = 0.01)
|
||||
const char *dump_path = (argc >= 4) ? argv[3] : nullptr;
|
||||
|
||||
std::vector<std::tuple<int, int, double, double, int>> samples; // t, id, x, y, color
|
||||
std::vector<std::tuple<int, int, double, double, double, double, int>> samples; // t, id, x, y, e.x, e.y, color
|
||||
if (dump_path)
|
||||
samples.reserve((size_t)n_iter / dump_interval * n_p);
|
||||
|
||||
@@ -137,7 +137,7 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
// # 4 flops = 2 ADDs, 2 MULTs
|
||||
//
|
||||
// $\vec{r}_i^{t+1} += \vec{r}^t_i + v^t_idt$
|
||||
// $\vec{r}_i^{t+1} = \vec{r}^t_i + v^t_idt$
|
||||
//
|
||||
p.curr_pos = p.curr_pos + p.curr_vel * dt;
|
||||
|
||||
@@ -157,9 +157,14 @@ int main(int argc, const char *argv[]) {
|
||||
// p.destination.y = p.curr_pos.y;
|
||||
}
|
||||
|
||||
// # 10 flops = 5 ADDs, 2 DIVs, 1 SQRT, 2 MULTs
|
||||
// p.e = (p.destination - p.curr_pos) / (p.destination - p.curr_pos).norm();
|
||||
// p.e = (p.curr_vel - p.destination) / (p.curr_vel - p.destination).norm();
|
||||
p.e = (p.destination - (p.curr_vel / p.curr_vel.norm())) / (p.destination - (p.curr_vel / p.curr_vel.norm())).norm();
|
||||
|
||||
// if we have a dump path/file we wanna save the data for visualisation
|
||||
if (dump_path && (t % dump_interval == 0)) {
|
||||
samples.emplace_back(t, i, p.curr_pos.x, p.curr_pos.y, p.color);
|
||||
samples.emplace_back(t, i, p.curr_pos.x, p.curr_pos.y, p.e.x, p.e.y, p.color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,9 +187,9 @@ int main(int argc, const char *argv[]) {
|
||||
// now we wanna save the data to a csv
|
||||
if (dump_path) {
|
||||
std::ofstream out(dump_path);
|
||||
out << "time,id,x,y,color\n";
|
||||
for (auto &[t, id, x, y, c] : samples) {
|
||||
out << t << ',' << id << ',' << x << ',' << y << ',' << c << '\n';
|
||||
out << "time,id,x,y,p.e.x,p.e.y,color\n";
|
||||
for (auto &[t, id, x, y, e_x, e_y, c] : samples) {
|
||||
out << t << ',' << id << ',' << x << ',' << y << ',' << e_x << ',' << e_y << ',' << c << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user