Commit ab72ce5c authored by Oliver Schmidts's avatar Oliver Schmidts

🎨 🆕 Point.cpp/.h

adding comments and new code for Point
removing getter and setter
others:
correction needed because of removing getter and setter
parent e193f8a8
......@@ -107,8 +107,8 @@ string TrajectoriesJPSV04::WritePed(Pedestrian* ped)
"zPos=\"%.2f\"\t"
"radiusA=\"%.2f\"\tradiusB=\"%.2f\"\t"
"ellipseOrientation=\"%.2f\" ellipseColor=\"%d\"/>\n",
ped->GetID(), (ped->GetPos().GetX()) * FAKTOR,
(ped->GetPos().GetY()) * FAKTOR,(ped->GetElevation()+0.3) * FAKTOR ,a * FAKTOR, b * FAKTOR,
ped->GetID(), (ped->GetPos()._x) * FAKTOR,
(ped->GetPos()._y) * FAKTOR,(ped->GetElevation()+0.3) * FAKTOR ,a * FAKTOR, b * FAKTOR,
phi * RAD2DEG, color);
return string(tmp);
......@@ -353,8 +353,8 @@ void TrajectoriesFLAT::WriteFrame(int frameNr, Building* building)
const vector< Pedestrian* >& allPeds = building->GetAllPedestrians();
for(unsigned int p=0;p<allPeds.size();p++){
Pedestrian* ped = allPeds[p];
double x = ped->GetPos().GetX();
double y = ped->GetPos().GetY();
double x = ped->GetPos()._x;
double y = ped->GetPos()._y;
double z = ped->GetElevation();
sprintf(tmp, "%d\t%d\t%0.2f\t%0.2f\t%0.2f", ped->GetID(), frameNr, x, y,z);
Write(tmp);
......@@ -400,7 +400,7 @@ void TrajectoriesVTK::WriteGeometry(Building* building)
const vector<NavMesh::JVertex*>& vertices= nv->GetVertices() ;
tmp<<"POINTS "<<vertices.size()<<" FLOAT"<<endl;
for (unsigned int v=0; v<vertices.size(); v++) {
tmp<<vertices[v]->pPos.GetX()<<" " <<vertices[v]->pPos.GetY() <<" 0.0"<<endl;
tmp<<vertices[v]->pPos._x<<" " <<vertices[v]->pPos._y <<" 0.0"<<endl;
}
Write(tmp.str());
tmp.str(std::string());
......@@ -566,8 +566,8 @@ void TrajectoriesJPSV06::WriteFrame(int frameNr, Building* building)
"z=\"%.6f\"\t"
"rA=\"%.2f\"\trB=\"%.2f\"\t"
"eO=\"%.2f\" eC=\"%d\"/>\n",
ped->GetID(), (ped->GetPos().GetX()) * FAKTOR,
(ped->GetPos().GetY()) * FAKTOR,(ped->GetElevation()+0.3) * FAKTOR ,a * FAKTOR, b * FAKTOR,
ped->GetID(), (ped->GetPos()._x) * FAKTOR,
(ped->GetPos()._y) * FAKTOR,(ped->GetElevation()+0.3) * FAKTOR ,a * FAKTOR, b * FAKTOR,
phi * RAD2DEG, color);
data.append(tmp1);
......@@ -681,8 +681,8 @@ void TrajectoriesJPSV05::WriteFrame(int frameNr, Building* building)
"z=\"%.6f\"\t"
"rA=\"%.2f\"\trB=\"%.2f\"\t"
"eO=\"%.2f\" eC=\"%d\"/>\n",
ped->GetID(), (ped->GetPos().GetX()) * FAKTOR,
(ped->GetPos().GetY()) * FAKTOR,(ped->GetElevation()+0.3) * FAKTOR ,a * FAKTOR, b * FAKTOR,
ped->GetID(), (ped->GetPos()._x) * FAKTOR,
(ped->GetPos()._y) * FAKTOR,(ped->GetElevation()+0.3) * FAKTOR ,a * FAKTOR, b * FAKTOR,
phi * RAD2DEG, color);
data.append(s);
}
......
......@@ -248,10 +248,10 @@ void Building::AddSurroundingRoom()
{
for (auto&& wall:itr_subroom.second->GetAllWalls())
{
double x1 = wall.GetPoint1().GetX();
double y1 = wall.GetPoint1().GetY();
double x2 = wall.GetPoint2().GetX();
double y2 = wall.GetPoint2().GetY();
double x1 = wall.GetPoint1()._x;
double y1 = wall.GetPoint1()._y;
double x2 = wall.GetPoint2()._x;
double y2 = wall.GetPoint2()._y;
double xmax = (x1 > x2) ? x1 : x2;
double xmin = (x1 > x2) ? x2 : x1;
......@@ -270,10 +270,10 @@ void Building::AddSurroundingRoom()
{
for(auto&& wall: itr_goal.second->GetAllWalls())
{
double x1 = wall.GetPoint1().GetX();
double y1 = wall.GetPoint1().GetY();
double x2 = wall.GetPoint2().GetX();
double y2 = wall.GetPoint2().GetY();
double x1 = wall.GetPoint1()._x;
double y1 = wall.GetPoint1()._y;
double x2 = wall.GetPoint2()._x;
double y2 = wall.GetPoint2()._y;
double xmax = (x1 > x2) ? x1 : x2;
double xmin = (x1 > x2) ? x2 : x1;
......@@ -1037,10 +1037,10 @@ void Building::InitGrid(double cellSize)
{
for (auto&& wall:itr_subroom.second->GetAllWalls())
{
double x1 = wall.GetPoint1().GetX();
double y1 = wall.GetPoint1().GetY();
double x2 = wall.GetPoint2().GetX();
double y2 = wall.GetPoint2().GetY();
double x1 = wall.GetPoint1()._x;
double y1 = wall.GetPoint1()._y;
double x2 = wall.GetPoint2()._x;
double y2 = wall.GetPoint2()._y;
double xmax = (x1 > x2) ? x1 : x2;
double xmin = (x1 > x2) ? x2 : x1;
......
......@@ -118,8 +118,8 @@ void Crossing::WriteToErrorLog() const
{
string s;
char tmp[CLENGTH];
sprintf(tmp, "\t\tCROSS: %d (%f, %f) -- (%f, %f)\n", GetID(), GetPoint1().GetX(),
GetPoint1().GetY(), GetPoint2().GetX(), GetPoint2().GetY());
sprintf(tmp, "\t\tCROSS: %d (%f, %f) -- (%f, %f)\n", GetID(), GetPoint1()._x,
GetPoint1()._y, GetPoint2()._x, GetPoint2()._y);
s.append(tmp);
sprintf(tmp, "\t\t\t\tSubRoom: %d <-> SubRoom: %d\n", GetSubRoom1()->GetSubRoomID(),
GetSubRoom2()->GetSubRoomID());
......@@ -137,13 +137,13 @@ string Crossing::GetDescription() const
geometry.append(tmp);
//geometry.append("\t\t<door color=\"250\">\n");
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\" zPos=\"%.2f\" />\n",
(GetPoint1().GetX()) * FAKTOR,
(GetPoint1().GetY()) * FAKTOR,
(GetPoint1()._x) * FAKTOR,
(GetPoint1()._y) * FAKTOR,
_subRoom1->GetElevation(GetPoint1())*FAKTOR);
geometry.append(tmp);
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\" zPos=\"%.2f\" />\n",
(GetPoint2().GetX()) * FAKTOR,
(GetPoint2().GetY()) * FAKTOR,
(GetPoint2()._x) * FAKTOR,
(GetPoint2()._y) * FAKTOR,
_subRoom1->GetElevation(GetPoint2())*FAKTOR);
geometry.append(tmp);
geometry.append("\t\t</crossing>\n");
......
......@@ -98,7 +98,7 @@ string Goal::Write()
//add the Goal caption
char tmp[CLENGTH];
sprintf(tmp, "\t\t<label centerX=\"%.2f\" centerY=\"%.2f\" centerZ=\"0\" text=\"%s\" color=\"100\" />\n"
, pos.GetX() * FAKTOR, pos.GetY() * FAKTOR, _caption.c_str());
, pos._x * FAKTOR, pos._y * FAKTOR, _caption.c_str());
s.append(tmp);
return s;
......@@ -111,8 +111,8 @@ const vector<Wall>& Goal::GetAllWalls() const
int Goal::WhichQuad(const Point& vertex, const Point& hitPos) const
{
return (vertex.GetX() > hitPos.GetX()) ? ((vertex.GetY() > hitPos.GetY()) ? 1 : 4) :
((vertex.GetY() > hitPos.GetY()) ? 2 : 3);
return (vertex._x > hitPos._x) ? ((vertex._y > hitPos._y) ? 1 : 4) :
((vertex._y > hitPos._y) ? 2 : 3);
}
......@@ -129,8 +129,8 @@ void Goal::SetIsFinalGoal(int isFinalGoal)
// x-Koordinate der Linie von einer Eccke zur nächsten
double Goal::Xintercept(const Point& point1, const Point& point2, double hitY) const
{
return (point2.GetX() - (((point2.GetY() - hitY) * (point1.GetX() - point2.GetX())) /
(point1.GetY() - point2.GetY())));
return (point2._x - (((point2._y - hitY) * (point1._x - point2._x)) /
(point1._y - point2._y)));
}
......@@ -159,7 +159,7 @@ bool Goal::Contains(const Point& ped) const
//WAS CLOCKWISE OR COUNTER
case -2: // US THE X POSITION AT THE HIT POINT TO
// DETERMINE WHICH WAY AROUND
if (Xintercept(_poly[edge], _poly[next], ped.GetY()) > ped.GetX())
if (Xintercept(_poly[edge], _poly[next], ped._y) > ped._x)
delta = -(delta);
break;
case 3: // MOVING 3 QUADS IS LIKE MOVING BACK 1
......@@ -244,10 +244,10 @@ void Goal::ComputeControid()
// For all vertices except last
unsigned int i=0;
for (i=0; i<_poly.size()-1; ++i) {
x0 = _poly[i].GetX();
y0 = _poly[i].GetY();
x1 = _poly[i+1].GetX();
y1 = _poly[i+1].GetY();
x0 = _poly[i]._x;
y0 = _poly[i]._y;
x1 = _poly[i+1]._x;
y1 = _poly[i+1]._y;
a = x0*y1 - x1*y0;
signedArea += a;
px += (x0 + x1)*a;
......@@ -255,10 +255,10 @@ void Goal::ComputeControid()
}
// Do last vertex
x0 = _poly[i].GetX();
y0 = _poly[i].GetY();
x1 = _poly[0].GetX();
y1 = _poly[0].GetY();
x0 = _poly[i]._x;
y0 = _poly[i]._y;
x1 = _poly[0]._x;
y1 = _poly[0]._y;
a = x0*y1 - x1*y0;
signedArea += a;
px += (x0 + x1)*a;
......
......@@ -105,8 +105,8 @@ void Hline::WriteToErrorLog() const
{
string s;
char tmp[CLENGTH];
sprintf(tmp, "\t\tHline: %d (%f, %f) -- (%f, %f)\n", GetID(), GetPoint1().GetX(),
GetPoint1().GetY(), GetPoint2().GetX(), GetPoint2().GetY());
sprintf(tmp, "\t\tHline: %d (%f, %f) -- (%f, %f)\n", GetID(), GetPoint1()._x,
GetPoint1()._y, GetPoint2()._x, GetPoint2()._y);
s.append(tmp);
sprintf(tmp, "\t\t\t\tRoom: %d <-> SubRoom: %d\n", _room1->GetID(),
_subRoom1->GetSubRoomID());
......@@ -123,13 +123,13 @@ string Hline::GetDescription() const
geometry.append(tmp);
//geometry.append("\t\t<door color=\"250\">\n");
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\" zPos=\"%.2f\"/>\n",
(GetPoint1().GetX()) * FAKTOR,
(GetPoint1().GetY()) * FAKTOR,
(GetPoint1()._x) * FAKTOR,
(GetPoint1()._y) * FAKTOR,
_subRoom1->GetElevation(GetPoint1())*FAKTOR);
geometry.append(tmp);
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\" zPos=\"%.2f\"/>\n",
(GetPoint2().GetX()) * FAKTOR,
(GetPoint2().GetY()) * FAKTOR,
(GetPoint2()._x) * FAKTOR,
(GetPoint2()._y) * FAKTOR,
_subRoom1->GetElevation(GetPoint2())*FAKTOR);
geometry.append(tmp);
geometry.append("\t\t</hline>\n");
......
......@@ -109,12 +109,12 @@ string Line::Write() const {
char wall[500] = "";
geometry.append("\t\t<wall color=\"100\">\n");
sprintf(wall, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\"/>\n",
(GetPoint1().GetX()) * FAKTOR,
(GetPoint1().GetY()) * FAKTOR);
(GetPoint1()._x) * FAKTOR,
(GetPoint1()._y) * FAKTOR);
geometry.append(wall);
sprintf(wall, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\"/>\n",
(GetPoint2().GetX()) * FAKTOR,
(GetPoint2().GetY()) * FAKTOR);
(GetPoint2()._x) * FAKTOR,
(GetPoint2()._y) * FAKTOR);
geometry.append(wall);
geometry.append("\t\t</wall>\n");
return geometry;
......@@ -130,11 +130,11 @@ Point Line::NormalVec() const {
double nx, ny, norm;
Point r = GetPoint2() - GetPoint1();
if (r.GetX() == 0.0) {
if (r._x == 0.0) {
nx = 1;
ny = 0;
} else {
nx = -r.GetY() / r.GetX();
nx = -r._y / r._x;
ny = 1;
/* Normieren */
norm = sqrt(nx * nx + ny * ny);
......@@ -286,8 +286,8 @@ int Line::IntersectionWith(const Point &p1, const Point &p2, Point &p3) const {
double denominator = BA.CrossProduct(DC);
double numerator = DC.CrossProduct(AC);
p3.SetX(J_NAN);
p3.SetY(J_NAN);
p3._x = J_NAN;
p3._y = J_NAN;
if (denominator == 0.0) {
// the lines are superposed
......@@ -423,7 +423,7 @@ bool Line::IntersectionWithCircle(const Point &centre, double radius /*cm for pe
// Returns true if pt is on the left side ( from point1 toward point2)
bool Line::IsLeft(const Point &pt) {
double test =
(_point2._x - _point1._x) * (pt.GetY() - _point1._y) - (_point2._y - _point1._y) * (pt.GetX() - _point1._x);
(_point2._x - _point1._x) * (pt._y - _point1._y) - (_point2._y - _point1._y) * (pt._x - _point1._x);
return test > 0.0;
}
......
......@@ -115,7 +115,7 @@ string Obstacle::Write()
// , pos.GetX() * FAKTOR, pos.GetY() * FAKTOR, _caption.c_str());
sprintf(tmp, "\t\t<label centerX=\"%.2f\" centerY=\"%.2f\" centerZ=\"0\" text=\"%d\" color=\"100\" />\n"
, pos.GetX() * FAKTOR, pos.GetY() * FAKTOR, _id);
, pos._x * FAKTOR, pos._y * FAKTOR, _id);
s.append(tmp);
return s;
......@@ -128,9 +128,9 @@ const vector<Wall>& Obstacle::GetAllWalls() const
int Obstacle::WhichQuad(const Point& vertex, const Point& hitPos) const
{
return (vertex.GetX() > hitPos.GetX()) ?
((vertex.GetY() > hitPos.GetY()) ? 1 : 4) :
((vertex.GetY() > hitPos.GetY()) ? 2 : 3);
return (vertex._x > hitPos._x) ?
((vertex._y > hitPos._y) ? 1 : 4) :
((vertex._y > hitPos._y) ? 2 : 3);
// if ((vertex.GetX() - hitPos.GetX())>J_EPS)
// {
......@@ -158,8 +158,8 @@ int Obstacle::WhichQuad(const Point& vertex, const Point& hitPos) const
// x-Koordinate der Linie von einer Eccke zur nächsten
double Obstacle::Xintercept(const Point& point1, const Point& point2, double hitY) const
{
return (point2.GetX() - (((point2.GetY() - hitY) * (point1.GetX() - point2.GetX())) /
(point1.GetY() - point2.GetY())));
return (point2._x- (((point2._y - hitY) * (point1._x - point2._x)) /
(point1._y - point2._y)));
}
......@@ -197,7 +197,7 @@ bool Obstacle::Contains(const Point& ped) const
//WAS CLOCKWISE OR COUNTER
case -2: // US THE X POSITION AT THE HIT POINT TO
// DETERMINE WHICH WAY AROUND
if (Xintercept(_poly[edge], _poly[next], ped.GetY()) > ped.GetX())
if (Xintercept(_poly[edge], _poly[next], ped._y) > ped._x)
delta = -(delta);
break;
case 3: // MOVING 3 QUADS IS LIKE MOVING BACK 1
......@@ -318,10 +318,10 @@ const Point Obstacle::GetCentroid() const
// For all vertices except last
unsigned int i=0;
for (i=0; i<_poly.size()-1; ++i) {
x0 = _poly[i].GetX();
y0 = _poly[i].GetY();
x1 = _poly[i+1].GetX();
y1 = _poly[i+1].GetY();
x0 = _poly[i]._x;
y0 = _poly[i]._y;
x1 = _poly[i+1]._x;
y1 = _poly[i+1]._y;
a = x0*y1 - x1*y0;
signedArea += a;
px += (x0 + x1)*a;
......@@ -329,10 +329,10 @@ const Point Obstacle::GetCentroid() const
}
// Do last vertex
x0 = _poly[i].GetX();
y0 = _poly[i].GetY();
x1 = _poly[0].GetX();
y1 = _poly[0].GetY();
x0 = _poly[i]._x;
y0 = _poly[i]._y;
x1 = _poly[0]._x;
y1 = _poly[0]._y;
a = x0*y1 - x1*y0;
signedArea += a;
px += (x0 + x1)*a;
......
......@@ -40,14 +40,7 @@
/************************************************************
Konstruktoren
************************************************************/
Point::Point() : _x(0), _y(0)
{
}
Point::Point(double x, double y) : _x(x), _y(y)
{
}
//
Point::Point(const Point& orig)
{
_x = orig._x;
......@@ -61,26 +54,6 @@ std::string Point::toString() const
return tmp.str();
}
void Point::SetX(double x)
{
_x = x;
}
void Point::SetY(double y)
{
_y = y;
}
double Point::GetX() const
{
return _x;
}
double Point::GetY() const
{
return _y;
}
double Point::Norm() const
{
return sqrt(NormSquare());
......@@ -269,3 +242,14 @@ const Point operator/(const Point& p, double f)
}
//return Point(p.GetX() / f, p.GetY() / f);
}
std::ostream& Point::SaveToXml(std::ostream& ostream) const
{
ostream << "<vertex px=" << _x << " py=" << _y << " />" << std::endl;
return ostream;;
}
double Distance(const Point& point, const Point& point1)
{
return boost::geometry::distance(point, point1);
}
\ No newline at end of file
/**
* \file Point.h
* \date Sep 30, 2010
* \version v0.7
* \version v0.8
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section License
......@@ -20,7 +20,10 @@
* You should have received a copy of the GNU Lesser General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section Description
* # Description
* Basic 2-d vectorial structure to deal with 2-D points. This class provides interaction for two points with each other
* and fullfills [boost/geometry object model](http://www.boost.org/doc/libs/1_60_0/libs/geometry/doc/html/geometry/examples/example__adapting_a_legacy_geometry_object_model.html)
* for a 2-d point.
*
*
**/
......@@ -29,39 +32,33 @@
#ifndef _POINT_H
#define _POINT_H
#include <string>
#include <math.h>
#include <iostream>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry.hpp>
class Point {
public:
double _x;
double _y;
double _x; //*<x-coordinate of a 2-d point*/
double _y; //*<y-coordinate of a 2-d point*/
public:
// constructors
Point();
Point(double x, double y);
Point(const Point& orig);
/**
* Set/Get the x component
*/
void SetX(double x);
/**
* Set/Get the y component
* **Ctor**
* Constructs a new point with given x and y.
* x and y are 0 if not given.
* @param [in] x: x-coordinate as double
* @param [in] y: y-coordinate as double
*/
void SetY(double y);
Point(double x = 0, double y = 0) : _x(x), _y(y) {};
/**
* Set/Get the x component
* **Copy-Ctor**
* Constructs a new point as copy of the original point.
* @param [in] orig: original point which shall be copied
*/
double GetX() const;
/**
* Set/Get the y component
*/
double GetY() const;
Point(const Point& orig);
/// Norm
double Norm() const;
......@@ -120,8 +117,12 @@ public:
Point& operator+=(const Point& p);
/// nice formating of the point
std::string toString() const;
std::ostream& SaveToXml(std::ostream&) const;
};
BOOST_GEOMETRY_REGISTER_POINT_2D(Point, double, cs::cartesian, _x, _y);
double Distance(const Point&, const Point&);
/// multiplication
const Point operator*(const Point& p, const double f);
/// division
......
......@@ -91,17 +91,17 @@ void SubRoom::SetHelpVariables()
for( i=0; i< _poly.size(); i++)
{
if ( _poly[i].GetY() == _poly[j].GetY() ) //not important
if ( _poly[i]._y == _poly[j]._y ) //not important
{
_poly_help_constatnt.push_back( _poly[i].GetX() ) ;
_poly_help_constatnt.push_back( _poly[i]._x ) ;
_poly_help_multiple.push_back( 0 );
}
else
{
_poly_help_constatnt.push_back( _poly[i].GetX() - ( _poly[i].GetY()*_poly[j].GetX() ) / ( _poly[j].GetY() - _poly[i].GetY())
+ ( _poly[i].GetY()*_poly[i].GetX() )/ ( _poly[j].GetY() - _poly[i].GetY() ) );
_poly_help_constatnt.push_back( _poly[i]._x - ( _poly[i]._y*_poly[j]._x ) / ( _poly[j]._y - _poly[i]._y)
+ ( _poly[i]._y*_poly[i]._x )/ ( _poly[j]._y - _poly[i]._y ) );
_poly_help_multiple.push_back( (_poly[j].GetX()-_poly[i].GetX())/(_poly[j].GetY()-_poly[i].GetY()) );
_poly_help_multiple.push_back( (_poly[j]._x-_poly[i]._x)/(_poly[j]._y-_poly[i]._y) );
}
j=i;
}
......@@ -303,7 +303,7 @@ void SubRoom::CalculateArea()
double sum = 0;
int n = (int) _poly.size();
for (int i = 0; i < n; i++) {
sum += (_poly[i].GetY() + _poly[(i + 1) % n].GetY())*(_poly[i].GetX() - _poly[(i + 1) % n].GetX());
sum += (_poly[i]._y + _poly[(i + 1) % n]._y)*(_poly[i]._x - _poly[(i + 1) % n]._x);
}
_area=(0.5 * fabs(sum));
}
......@@ -322,10 +322,10 @@ Point SubRoom::GetCentroid() const
// For all vertices except last
unsigned int i=0;
for (i=0; i<_poly.size()-1; ++i) {
x0 = _poly[i].GetX();
y0 = _poly[i].GetY();
x1 = _poly[i+1].GetX();
y1 = _poly[i+1].GetY();
x0 = _poly[i]._x;
y0 = _poly[i]._y;
x1 = _poly[i+1]._x;
y1 = _poly[i+1]._y;
a = x0*y1 - x1*y0;
signedArea += a;
px += (x0 + x1)*a;
......@@ -333,10 +333,10 @@ Point SubRoom::GetCentroid() const
}
// Do last vertex
x0 = _poly[i].GetX();
y0 = _poly[i].GetY();
x1 = _poly[0].GetX();
y1 = _poly[0].GetY();
x0 = _poly[i]._x;
y0 = _poly[i]._y;
x1 = _poly[0]._x;
y1 = _poly[0]._y;
a = x0*y1 - x1*y0;
signedArea += a;
px += (x0 + x1)*a;
......@@ -363,8 +363,8 @@ vector<Wall> SubRoom::GetVisibleWalls(const Point & position)
wall_is_vis = IsVisible(w, position);
if(wall_is_vis){
#if DEBUG
printf(" GetVisibleWalls: Wall (%f, %f)--(%f, %f)\n",w.GetPoint1().GetX(), w.GetPoint1().GetY(),w.GetPoint2().GetX(), w.GetPoint2().GetY() );
printf(" GetVisibleWalls: Ped position (%f, %f)\n",position.GetX(), position.GetY());
printf(" GetVisibleWalls: Wall (%f, %f)--(%f, %f)\n",w.GetPoint1()._x, w.GetPoint1()._y,w.GetPoint2()._x, w.GetPoint2()._y );
printf(" GetVisibleWalls: Ped position (%f, %f)\n",position._x, position._y);
printf(" GetVisibleWalls: wall is visible? = %d\n",wall_is_vis);
#endif
visible_walls.push_back(w);
......@@ -381,7 +381,7 @@ vector<Wall> SubRoom::GetVisibleWalls(const Point & position)
bool SubRoom::IsVisible(const Line &wall, const Point &position)
{
// printf("\tEnter wall_is_visible\n");
// printf(" \t Wall (%f, %f)--(%f, %f)\n",wall.GetPoint1().GetX(), wall.GetPoint1().GetY(),wall.GetPoint2().GetX(), wall.GetPoint2().GetY() );
// printf(" \t Wall (%f, %f)--(%f, %f)\n",wall.GetPoint1()._x, wall.GetPoint1()._y,wall.GetPoint2()._x, wall.GetPoint2()._y );
bool wall_is_vis = true;
// Point nearest_point = wall.ShortestPoint(position);
......@@ -389,7 +389,7 @@ bool SubRoom::IsVisible(const Line &wall, const Point &position)
// try with the center. If it is not visible then the wall is definitly not.
const Point& nearest_point = wall.GetCentre();
// printf("\t\t center of wall %f, %f\n",nearest_point.GetX(), nearest_point.GetY());
// printf("\t\t center of wall %f, %f\n",nearest_point._x, nearest_point._y);
Line ped_wall = Line(position, nearest_point);
for (auto& w:_walls)
{
......@@ -397,7 +397,7 @@ bool SubRoom::IsVisible(const Line &wall, const Point &position)
continue;
if(wall_is_vis && ped_wall.IntersectionWith(w))
{
// fprintf (stdout, "\t\t Wall_is_visible: INTERSECTION WALL L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), WALL(%.2f, %.2f)---(%.2f, %.2f)\n", ped_wall.GetPoint1().GetX(),ped_wall.GetPoint1().GetY(), ped_wall.GetPoint2().GetX(), ped_wall.GetPoint2().GetY(), w.GetPoint1().GetX(),w.GetPoint1().GetY(),w.GetPoint2().GetX(),w.GetPoint2().GetY());
// fprintf (stdout, "\t\t Wall_is_visible: INTERSECTION WALL L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), WALL(%.2f, %.2f)---(%.2f, %.2f)\n", ped_wall.GetPoint1()._x,ped_wall.GetPoint1()._y, ped_wall.GetPoint2()._x, ped_wall.GetPoint2()._y, w.GetPoint1()._x,w.GetPoint1()._y,w.GetPoint2()._x,w.GetPoint2()._y);
wall_is_vis = false;
}
}
......@@ -407,7 +407,7 @@ bool SubRoom::IsVisible(const Line &wall, const Point &position)
for(const auto& w: obst->GetAllWalls())
{
if(wall_is_vis && ped_wall.IntersectionWith(w)){
// fprintf (stdout, "\t\t Wall_is_visible INTERSECTION OBS; L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), L2_P1(%.2f, %.2f) L2_P2(%.2f, %.2f)\n", w.GetPoint1().GetX(), w.GetPoint1().GetY(), w.GetPoint2().GetX(), w.GetPoint2().GetY(), ped_wall.GetPoint1().GetX(), ped_wall.GetPoint1().GetY(), ped_wall.GetPoint2().GetX(), ped_wall.GetPoint2().GetY());
// fprintf (stdout, "\t\t Wall_is_visible INTERSECTION OBS; L1_P1(%.2f, %.2f), L1_P2(%.2f, %.2f), L2_P1(%.2f, %.2f) L2_P2(%.2f, %.2f)\n", w.GetPoint1()._x, w.GetPoint1()._y, w.GetPoint2()._x, w.GetPoint2()._y, ped_wall.GetPoint1()._x, ped_wall.GetPoint1()._y, ped_wall.GetPoint2()._x, ped_wall.GetPoint2()._y);
wall_is_vis = false;
}
}
......@@ -803,13 +803,13 @@ string NormalSubRoom::WriteSubRoom() const
char wall[CLENGTH] = "";
geometry.append("\t\t<wall>\n");
sprintf(wall, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\" zPos=\"%.2f\"/>\n",
(w.GetPoint1().GetX()) * FAKTOR,
(w.GetPoint1().GetY()) * FAKTOR,
(w.GetPoint1()._x) * FAKTOR,
(w.GetPoint1()._y) * FAKTOR,
GetElevation(w.GetPoint1())*FAKTOR);
geometry.append(wall);
sprintf(wall, "\t\t\t<point xPos=\"%.2f\" yPos=\"