20 #include "rectangle.h"
21 #include "ns3/vector.h"
22 #include "ns3/assert.h"
23 #include "ns3/fatal-error.h"
31 double _yMin,
double _yMax)
51 position.
x <= this->xMax && position.
x >= this->xMin &&
52 position.
y <= this->yMax && position.
y >= this->yMin;
58 double xMinDist = std::abs (position.
x - this->xMin);
59 double xMaxDist = std::abs (this->xMax - position.
x);
60 double yMinDist = std::abs (position.
y - this->yMin);
61 double yMaxDist = std::abs (this->yMax - position.
y);
62 double minX = std::min (xMinDist, xMaxDist);
63 double minY = std::min (yMinDist, yMaxDist);
66 if (xMinDist < xMaxDist)
77 if (yMinDist < yMaxDist)
92 double xMaxY = current.
y + (this->xMax - current.
x) / speed.
x * speed.
y;
93 double xMinY = current.
y + (this->xMin - current.
x) / speed.
x * speed.
y;
94 double yMaxX = current.
x + (this->yMax - current.
y) / speed.
y * speed.
x;
95 double yMinX = current.
x + (this->yMin - current.
y) / speed.
y * speed.
x;
96 bool xMaxYOk = (xMaxY <= this->yMax && xMaxY >= this->yMin);
97 bool xMinYOk = (xMinY <= this->yMax && xMinY >= this->yMin);
98 bool yMaxXOk = (yMaxX <= this->xMax && yMaxX >= this->xMin);
99 bool yMinXOk = (yMinX <= this->xMax && yMinX >= this->xMin);
100 if (xMaxYOk && speed.
x >= 0)
102 return Vector (this->xMax, xMaxY, 0.0);
104 else if (xMinYOk && speed.
x <= 0)
106 return Vector (this->xMin, xMinY, 0.0);
108 else if (yMaxXOk && speed.
y >= 0)
110 return Vector (yMaxX, this->yMax, 0.0);
112 else if (yMinXOk && speed.
y <= 0)
114 return Vector (yMinX, this->yMin, 0.0);
120 return Vector (0.0, 0.0, 0.0);
130 os << rectangle.xMin <<
"|" << rectangle.xMax <<
"|" << rectangle.yMin <<
"|" << rectangle.yMax;
134 operator >> (std::istream &is, Rectangle &rectangle)
137 is >> rectangle.xMin >> c1 >> rectangle.xMax >> c2 >> rectangle.yMin >> c3 >> rectangle.yMax;
142 is.setstate (std::ios_base::failbit);
std::istream & operator>>(std::istream &is, Angles &a)
Vector CalculateIntersection(const Vector ¤t, const Vector &speed) const
#define NS_ASSERT(condition)
bool IsInside(const Vector &position) const
std::ostream & operator<<(std::ostream &os, const Angles &a)
#define ATTRIBUTE_HELPER_CPP(type)
Side GetClosestSide(const Vector &position) const