Commit 14cec38b authored by Arne Graf's avatar Arne Graf

fixed RectGrid-Bug

parent 53ff3e2d
......@@ -810,6 +810,7 @@ bool ArgumentParser::ParseGradientModel(TiXmlElement* xGradient) // @todo: chang
}
Log->Write("INFO: \tfrep_wall mu=%s, a=%0.2f, b=%0.2f c=%0.2f",nu.c_str(),paWall,pbWall,pcWall);
}
//anti_clipping
if (xModelPara->FirstChild("anti_clipping"))
{
if (!xModelPara->FirstChildElement("anti_clipping")->Attribute("slow_down_distance"))
......@@ -827,7 +828,8 @@ bool ArgumentParser::ParseGradientModel(TiXmlElement* xGradient) // @todo: chang
this->GetaPed(), this->GetbPed(), this->GetcPed(),
this->GetNuWall(), this->GetaWall(), this->GetbWall(),
this->GetcWall(),
this->pDeltaH, this->pWallAvoidDistance, this->pUseWallAvoidance));
this->pDeltaH, this->pWallAvoidDistance, this->pUseWallAvoidance,
this->pSlowDownDistance));
return true;
}
......
......@@ -49,7 +49,8 @@ using std::string;
GradientModel::GradientModel(DirectionStrategy* dir, double nuped, double aped, double bped, double cped,
double nuwall, double awall, double bwall, double cwall,
double deltaH, double wallAvoidDistance, bool useWallAvoidance)
double deltaH, double wallAvoidDistance, bool useWallAvoidance,
double slowDownDistance)
{
_direction = dir;
// Force_rep_PED Parameter
......@@ -66,6 +67,8 @@ GradientModel::GradientModel(DirectionStrategy* dir, double nuped, double aped,
_deltaH = deltaH;
_wallAvoidDistance = wallAvoidDistance;
_useWallAvoidance = useWallAvoidance;
// anti clipping
_slowDownDistance = slowDownDistance;
}
......@@ -224,29 +227,31 @@ void GradientModel::ComputeNextTimeStep(double current, double deltaT, Building*
Point toTarget = (_direction->GetTarget(nullptr, ped)).Normalized();
if (toTarget.NormSquare() == 0.) { // @todo:ar.graf: this if overcomes shortcomming of floorfield (neggrad[targetpoints] == Point(0., 0.))
toTarget += ped->GetV().Normalized();
//printf("toTarget %f %f \n", toTarget.GetX(), toTarget.GetY());
//printf("getV %f %f \n", ped->GetV().GetX(), ped->GetV().GetY());
//printf("dist2Target %f \n", ped->GetDistanceToNextTarget());
}
movDirection = (movDirection + toTarget); //*1.2);
movDirection = (movDirection + toTarget);
movDirection = (movDirection.Norm() > 1.) ? movDirection.Normalized() : movDirection;
double desired_speed = ped->GetV0Norm();
Point oldMov = Point(0., 0.);
if (desired_speed > 0.) {
oldMov = ped->GetV() / desired_speed; //@todo: ar.graf
}
//anti jitter //_V0 = _V0 + (new_v0 - _V0)*( 1 - exp(-t/_tau) );
Point oldMov = (ped->GetV().Norm() > 1.)? ped->GetV().Normalized() : ped->GetV();
Point diff = ( oldMov - movDirection) * (.2); // .8 also 80% alte Richtung, 20% neue Richtung
movDirection = ped->GetV() - diff;
oldMov = (oldMov.Norm() > 1.)? oldMov.Normalized() : oldMov; //on the safe side ... should not be necessary as it must be [0, 1]
Point diff = ( oldMov - movDirection) * (.2); // .2 also 80% alte Richtung, 20% neue Richtung
movDirection = oldMov - diff;
movDirection = (movDirection.Norm() > 1.) ? movDirection.Normalized() : movDirection;
//slowdown near wall mechanics:
Point dir2Wall = dynamic_cast<DirectionFloorfield*>(_direction)->GetDir2Wall(ped);
double distance2Wall = dynamic_cast<DirectionFloorfield*>(_direction)->GetDistance2Wall(ped);
double dotProdukt = 0;
if (distance2Wall < .2) {
dotProdukt = dir2Wall.ScalarProduct(movDirection.Normalized());
double dotProduct = 0;
if (distance2Wall < _slowDownDistance) {
dotProduct = dir2Wall.ScalarProduct(movDirection.Normalized());
}
double antiClippingFactor = ( 1 - .5*(dotProdukt + fabs(dotProdukt)) );
double antiClippingFactor = ( 1 - .5*(dotProduct + fabs(dotProduct)) );
......
......@@ -63,6 +63,8 @@ private:
double _wallAvoidDistance;
bool _useWallAvoidance;
double _slowDownDistance;
/**
* Driving force \f$ F_i =\frac{\mathbf{v_0}-\mathbf{v_i}}{\tau}\f$
* This is a duplicate of @see GCFMModel::ForceDriv
......@@ -107,7 +109,8 @@ public:
GradientModel(DirectionStrategy* dir, double nuped, double aped, double bped, double cped,
double nuwall, double awall, double bwall, double cwall,
double deltaH, double wallAvoidDistance, bool useWallAvoidance);
double deltaH, double wallAvoidDistance, bool useWallAvoidance,
double slowDownDistance);
virtual ~GradientModel(void);
DirectionStrategy* GetDirection() const;
......
......@@ -75,7 +75,7 @@ FloorfieldViaFM::FloorfieldViaFM(const Building* const buildingArg, const double
calculateDistanceField(threshold); //negative threshold is ignored, range is believed to be (.4 - ...) at stepsize .0625
//testoutput("AADistanceField.vtk","AADistanceField.txt", dist2Wall);
testoutput("AADistanceField.vtk","AADistanceField.txt", dist2Wall);
//std::cout<< "Test (50/101): " << grid->getKeyAtXY(50., 101.) << " " << grid->get_x_fromKey(grid->getKeyAtXY(50., 101.)) << " " << grid->get_y_fromKey(grid->getKeyAtXY(50., 101.)) << std::endl;
calculateFloorfield(useDistancefield); //use distance2Wall
......@@ -704,7 +704,7 @@ void FloorfieldViaFM::checkNeighborsAndCalcDist2Wall(const long int key) {
dirToWall[key].SetY(-(cost[key]-cost[key-(grid->GetiMax())])/grid->Gethy());
}
} else {
std::cerr << "else in twosided &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
std::cerr << "else in twosided Dist " << std::endl;
}
dirToWall[key] = dirToWall[key].Normalized();
}
......@@ -822,7 +822,7 @@ void FloorfieldViaFM::checkNeighborsAndCalcFloorfield(const long int key) {
neggrad[key].SetY(-(cost[key]-cost[key-(grid->GetiMax())])/grid->Gethy());
}
} else {
std::cerr << "else in twosided &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
std::cerr << "else in twosided Floor " << precheck << " " << row << " " << col << std::endl;
}
}
......
......@@ -134,8 +134,8 @@ class RectGrid
void createGrid(){ // @todo ar.graf : what if cast chops off float, if any changes: get_x_fromKey still correct?
if (!isInitialized) {
iMax = (long int)((xMax-xMin)/hx) + 1;
jMax = (long int)((yMax-yMin)/hy) + 1;
iMax = (long int)((xMax-xMin)/hx) + 2; //check plus 2 (one for ceil, one for starting point)
jMax = (long int)((yMax-yMin)/hy) + 2;
nPoints = iMax * jMax;
//@todo: see if necessary to align xMax/yMax
xMax = xMin + iMax*hx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment