Merge branch smail
This commit is contained in:
+37
-3
@@ -27,6 +27,9 @@ void compute_acceleration_term(Pedestrian *p) {
|
||||
}
|
||||
|
||||
// # 55(N - 1) = 55N - 55 flops
|
||||
//
|
||||
// $\sum_{\beta} \vec{F}_{\alpha\beta}(\vec{e}_{\alpha}, \vec{r}_{\alpha} - \vec{r}_{\beta})$
|
||||
//
|
||||
void compute_repulsive_effects_from_pedestrians(Pedestrian *pedestrians, Pedestrian *p, int N) {
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
@@ -41,38 +44,56 @@ void compute_repulsive_effects_from_pedestrians(Pedestrian *pedestrians, Pedestr
|
||||
// }
|
||||
|
||||
// # 2 ADDs
|
||||
// $\vec{r}_{\alpha\beta}$
|
||||
Vector2d r_ab = p->curr_pos - pedestrians[i].curr_pos;
|
||||
|
||||
// # 4 flops = 1 SQRT, 2 MULTs, 1 ADD
|
||||
// $\Arrowvert \vec{r}_{\alpha \beta} \Arrowvert$
|
||||
double r_ab_norm = r_ab.norm();
|
||||
|
||||
// $\vec{e}_{\beta}$
|
||||
Vector2d e_b = pedestrians[i].e;
|
||||
|
||||
// # 2 MULTs
|
||||
double s_b = pedestrians[i].desired_v0 * delta_t;
|
||||
// $v_\beta \Delta t$
|
||||
double s_b = pedestrians[i].curr_vel.norm() * delta_t;
|
||||
|
||||
// # 4 flops = 2 ADDs, 2 MULTs
|
||||
// $\vec{r}_{\alpha\beta} - \vec{v}_{\beta}\varDelta_{t}\vec{e}_{\beta}$
|
||||
Vector2d r_ab2 = r_ab - (e_b * s_b);
|
||||
|
||||
// # 4 flops = 1 SQRT, 2 MULTs, 1 ADD
|
||||
// $\Arrowvert \vec{r}_{\alpha \beta} - v_\beta \Delta t \vec{e}_\beta \Arrowvert$
|
||||
double r_ab2_norm = r_ab2.norm();
|
||||
|
||||
// # 7 flops = 1 SQRT, 3 ADDs, 2 MULTs, 1 DIV
|
||||
//
|
||||
// $(4):2b = \sqrt{(\Arrowvert \vec{r}_{\alpha \beta} \Arrowvert + \Arrowvert \vec{r}_{\alpha \beta} - v_\beta \Delta t \vec{e}_\beta \Arrowvert)^2 - (v_\beta \Delta t)^2}$
|
||||
//
|
||||
double b = sqrt((r_ab_norm + r_ab2_norm) * (r_ab_norm + r_ab2_norm) - s_b * s_b) / 2;
|
||||
|
||||
// # 12 flops = 6 DIVs, 3 ADDs, 3 MULTs
|
||||
//
|
||||
// $(7):\grad_{\vec{r}_{\alpha \beta}}b = \frac{(\Arrowvert \vec{r}_{\alpha \beta} \Arrowvert + \Arrowvert \vec{r}_{\alpha \beta} - v_\beta \Delta t \vec{e}_\beta \Arrowvert) (\frac{\vec{r}_{\alpha \beta}}{\Arrowvert \vec{r}_{\alpha \beta} \Arrowvert} + \frac{\vec{r}_{\alpha \beta} - v_\beta \Delta t \vec{e}_\beta}{\Arrowvert \vec{r}_{\alpha \beta} - v_\beta \Delta t \vec{e}_\beta \Arrowvert})}{4b}$
|
||||
//
|
||||
Vector2d b_grad = (r_ab / r_ab_norm + r_ab2 / r_ab2_norm) * (r_ab_norm + r_ab2_norm) / (4 * b);
|
||||
|
||||
// # 6 flops = 3 MULTs, 2 DIVs, 1 EXP
|
||||
//
|
||||
// $(5):\vec{f}_{\alpha \beta}(\vec{r}_{\alpha \beta}) = \frac{V^0_{\alpha \beta}}{\sigma}e^{-b / \sigma} \grad_{\vec{r}_{\alpha \beta}}b$
|
||||
//
|
||||
Vector2d f_ped = b_grad * ((V0_AB / SIGMA) * (exp(-b / SIGMA)));
|
||||
|
||||
// # 14 flops: 9 MULTs, 4 ADDs, 1 SQRT
|
||||
//
|
||||
// $(11):\vec{F}_{\alpha\beta}(\vec{e}_{\alpha}, \vec{r}_{\alpha} - \vec{r}_{\beta}) = w(\vec{e}_{\alpha}, -\vec{f}_{\alpha\beta})\vec{f}_{\alpha\beta}(\vec{r}_{\alpha} - \vec{r}_{\beta})$
|
||||
//
|
||||
p->f_i += f_ped * w(p->e, f_ped * -1);
|
||||
}
|
||||
}
|
||||
|
||||
// # Assume that the four borders are also 4 obstacles
|
||||
// # 36 n_obstacles flops = 144 flops
|
||||
// # 48 n_obstacles flops = 192 flops
|
||||
void compute_repulsive_effects_from_borders(Board &board, Pedestrian *p) {
|
||||
|
||||
Obstacle *obstacles = board.obstacles;
|
||||
@@ -83,12 +104,25 @@ void compute_repulsive_effects_from_borders(Board &board, Pedestrian *p) {
|
||||
Obstacle obstacle = obstacles[i];
|
||||
|
||||
// # 17 flops
|
||||
// $\vec{r}_{\alpha B}$
|
||||
Vector2d r_aB = p->curr_pos - obstacle.find_nearest_obstacle_point(p->curr_pos);
|
||||
|
||||
// # 17 flops = 2 DIVs, 1 SQRT, 2 MULTs, 1 ADD, 2 MULTs, 1 DIV, 2 MULTs, 1 EXP, 1 SQRT, 2 MULTs, 1 ADD, 1 DIV
|
||||
//
|
||||
// $\vec{F}_{\alpha B}(\vec{r}_{\alpha B}) = \frac{U^0_{\alpha B}}{R} e^{- \Arrowvert \vec{r}_{\alpha B} \Arrowvert / R} \frac{\vec{r}_{\alpha B}}{\Arrowvert \vec{r}_{\alpha B} \Arrowvert}$
|
||||
//
|
||||
Vector2d f_obst = (r_aB / r_aB.norm()) * (U0_AB / R) * std::exp(-r_aB.norm() / R);
|
||||
|
||||
// # 2 ADDs
|
||||
p->f_i += f_obst;
|
||||
// p->f_i += f_obst; //commented since this version dont takes the field of view / angle to the border into account
|
||||
|
||||
// I have read the paper again and on page 6 they say
|
||||
// However, the formulas above for attractive and repulsive effects only hold for situations that are perceived in the desired direction e_alpha(t) of motion.
|
||||
// I assumed that with formulas above its also meant for equation 8 (even though not explicitly mentioned their)
|
||||
// # 14 flops: 9 MULTs, 4 ADDS, 1 SQRT
|
||||
//
|
||||
// $(12):\vec{F}_{\alpha B}(\vec{e}_{\alpha}, \vec{r}_{\alpha} - \vec{r}_{ B}) = w(\vec{e}_{\alpha}, -\vec{F}_{\alpha B})\vec{F}_{\alpha B}(\vec{r}_{\alpha} - \vec{r}_{ B})$
|
||||
//
|
||||
p->f_i += f_obst * w(p->e, f_obst * -1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user