correct distance calculation for train doors

parent 47b8067e
......@@ -675,7 +675,7 @@ double Simulation::RunBody(double maxSimTime)
Trans->UpdateClosingTime( _deltaT);
if(Trans->GetClosingTime() <= _deltaT){
Trans->changeTemporaryState();
Log-> Write("INFO:\tReset state of door %d, Time=%.2f", Trans->GetID(), Pedestrian::GetGlobalTime());
/* Log-> Write("INFO:\tReset state of door %d, Time=%.2f", Trans->GetID(), Pedestrian::GetGlobalTime()); */
}
}// normal transition
}
......@@ -690,7 +690,7 @@ double Simulation::RunBody(double maxSimTime)
if(Trans->IsInLineSegment(tp1) && Trans->IsInLineSegment(tp2))
{
Trans->SetMaxDoorUsage(TrainTypes[train]->nmax);
// SetOutflowRate() in initialisation phase
//todo: SetOutflowRate() to sum of doors of train
Trans->Open();
}
}
......
......@@ -847,7 +847,8 @@ Point DirectionTrain::GetTarget(Room* room, Pedestrian* ped) const
auto TrainTypes = ped->GetBuilding()->GetTrainTypes();
auto TrainTimeTables = ped->GetBuilding()->GetTrainTimeTables();
auto now = ped->GetGlobalTime();
string type_delme="";
// std::cout << ">>> Enter with ped at " << ped->GetPos().toString().c_str() << "\n";
for(auto && t: TrainTimeTables)
{
if(ped->GetRoomID() != t.second->rid) continue;
......@@ -862,15 +863,26 @@ Point DirectionTrain::GetTarget(Room* room, Pedestrian* ped) const
i++;
const Point & d1 = door.GetPoint1();
const Point & d2 = door.GetPoint2();
double dist = (d1*0.5+d2*0.5).Norm();
const Point & c = (d1+d2)*0.5;
double dist = (ped->GetPos()-c).Norm();
// std::cout << "door id: " << door.GetID()<< " dist: " << dist<< "\n";
if(dist <= dist_min)
{
dist_min = dist;
imin=i;
type_delme=t.second->type;
// std::cout << " > imin " << imin << " mindist " << dist_min << "\n";
}
}// doors
p1 = doors[imin].GetPoint1();
p2 = doors[imin].GetPoint2();
// std::cout << "\n>>> train: now " << now << ", type: " << type_delme.c_str() << "\n";
// std::cout << ">>> p1=" << p1.toString().c_str() << ". p2=" << p2.toString().c_str()<< "\n";
// std::cout << ">>> ped at " << ped->GetPos().toString().c_str() << "\n";
// getc(stdin);
}// if time in
}
......
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