From b1a2babc66a08356f1e2b3dafcda0925ef03909a Mon Sep 17 00:00:00 2001 From: qiancheng xu <q.xu@fz-juelich.de> Date: Fri, 28 Jun 2019 14:15:01 +0200 Subject: [PATCH] 1. fix a bug in GCVMModel 2. AGCVM needs more work --- math/AGCVMModel.cpp | 15 ++++++++++++--- math/GCVMModel.cpp | 6 +++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/math/AGCVMModel.cpp b/math/AGCVMModel.cpp index 1622874d..1a25a7c9 100644 --- a/math/AGCVMModel.cpp +++ b/math/AGCVMModel.cpp @@ -272,8 +272,8 @@ void AGCVMModel::ComputeNextTimeStep(double current, double deltaT, Building* bu Point angle_v = (d_direction.Normalized()-a_direction)/ angle_tau; Point direction = a_direction + angle_v * deltaT; - //When the angle between desired mocing direction and actual direction is bigger than 90 degree. turning to the desired moving direction directly. - if (d_direction.ScalarProduct(a_direction) < 0) { + //When the angle between actual moving direction and initial desired moving direction is bigger than 90 degree. turning to the desired moving direction directly. + if (a_direction.ScalarProduct(inid_direction) < 0) { direction = d_direction; } @@ -465,7 +465,7 @@ my_pair AGCVMModel::GetSpacing(Pedestrian* ped1, Pedestrian* ped2, Point ei, int double a1 = ped1->GetLargerAxis(); Point v = ped1->GetV(); double b1 = ped1->GetSmallerAxis(); - + b1 = ped1->GetEllipse().GetBmin(); //Avoid block B(drill,small tricks)----------------------------------------------------- /* if (fabs(v._x) < J_EPS && fabs(v._y) < J_EPS) // v==0 @@ -567,6 +567,10 @@ my_pair AGCVMModel::GetSpacing(Pedestrian* ped1, Pedestrian* ped2, Point ei, int Point AGCVMModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2, Point e0, int periodic) const { Point F_rep(0.0, 0.0); + // Calculate the velocity difference between two pedestrians + Point vel_ped1 = ped1->GetV(); + Point vel_ped2 = ped2->GetV(); + double Anti_value = (vel_ped1 - vel_ped2).ScalarProduct(vel_ped1); // x- and y-coordinate of the distance between p1 and p2 double x_j = ped2->GetPos()._x; @@ -625,6 +629,10 @@ Point AGCVMModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2, Point e0, int dist = dist > 0 ? dist : 0; R_ij = -_aPed * exp((-dist) / _DPed); F_rep = ep12 * R_ij; + if (Anti_value < 0) + { + F_rep = F_rep*-1; + } } ped2->SetPos(Point(x_j, y_j)); return F_rep; @@ -827,6 +835,7 @@ double AGCVMModel::GetSpacingWall(Pedestrian* ped, const Line& l, Point ei) cons ei_vertical._x = -ei.Normalized()._y; ei_vertical._y = ei.Normalized()._x; double b = ped->GetSmallerAxis(); + b = ped->GetEllipse().GetBmin(); Point A1 = pp + ei_vertical * b; Point A2 = pp - ei_vertical * b; Point p1_A1 = p1 - A1; diff --git a/math/GCVMModel.cpp b/math/GCVMModel.cpp index 97607cd3..26a17293 100644 --- a/math/GCVMModel.cpp +++ b/math/GCVMModel.cpp @@ -272,11 +272,11 @@ void GCVMModel::ComputeNextTimeStep(double current, double deltaT, Building* bui Point angle_v = (d_direction.Normalized()-a_direction)/ angle_tau; Point direction = a_direction + angle_v * deltaT; - //When the angle between desired mocing direction and actual direction is bigger than 90 degree. turning to the desired moving direction directly. - if (d_direction.ScalarProduct(a_direction) < 0) { + //When the angle between actual moving direction and initial desired moving direction is bigger than 90 degree. turning to the desired moving direction directly. + if (a_direction.ScalarProduct(inid_direction) < 0) { direction = d_direction; } - + if (GetGCVMU() == 0) { direction = d_direction;//original method } -- GitLab