22 #include "ns3/vector.h" 23 #include "ns3/assert.h" 24 #include "ns3/fatal-error.h" 32 double _yMin,
double _yMax,
33 double _zMin,
double _zMax)
57 position.x <= this->
xMax && position.x >= this->
xMin &&
58 position.y <= this->
yMax && position.y >= this->
yMin &&
59 position.z <= this->
zMax && position.z >= this->
zMin;
65 double xMinDist = std::abs (position.x - this->xMin);
66 double xMaxDist = std::abs (this->
xMax - position.x);
67 double yMinDist = std::abs (position.y - this->yMin);
68 double yMaxDist = std::abs (this->
yMax - position.y);
69 double zMinDist = std::abs (position.z - this->zMin);
70 double zMaxDist = std::abs (this->
zMax - position.z);
71 double minX =
std::min (xMinDist, xMaxDist);
72 double minY =
std::min (yMinDist, yMaxDist);
73 double minZ =
std::min (zMinDist, zMaxDist);
74 if (minX < minY && minX < minZ)
76 if (xMinDist < xMaxDist)
87 if (yMinDist < yMaxDist)
98 if (zMinDist < zMaxDist)
113 double xMaxY = current.y + (this->
xMax - current.x) / speed.x * speed.y;
114 double xMinY = current.y + (this->xMin - current.x) / speed.x * speed.y;
115 double yMaxX = current.x + (this->
yMax - current.y) / speed.y * speed.x;
116 double yMinX = current.x + (this->yMin - current.y) / speed.y * speed.x;
117 bool xMaxYOk = (xMaxY <= this->
yMax && xMaxY >= this->
yMin);
118 bool xMinYOk = (xMinY <= this->
yMax && xMinY >= this->
yMin);
119 bool yMaxXOk = (yMaxX <= this->
xMax && yMaxX >= this->
xMin);
120 bool yMinXOk = (yMinX <= this->
xMax && yMinX >= this->
xMin);
121 if (xMaxYOk && speed.x >= 0)
123 return Vector (this->
xMax, xMaxY, 0.0);
125 else if (xMinYOk && speed.x <= 0)
127 return Vector (this->
xMin, xMinY, 0.0);
129 else if (yMaxXOk && speed.y >= 0)
131 return Vector (yMaxX, this->
yMax, 0.0);
133 else if (yMinXOk && speed.y <= 0)
135 return Vector (yMinX, this->
yMin, 0.0);
141 return Vector (0.0, 0.0, 0.0);
171 char c1, c2, c3, c4, c5;
179 is.setstate (std::ios_base::failbit);
Side
Enum class to specify sides of a box.
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
double zMin
The z coordinate of the down bound of the box.
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
double xMax
The x coordinate of the right bound of the box.
double yMax
The y coordinate of the top bound of the box.
Side GetClosestSide(const Vector &position) const
double yMin
The y coordinate of the bottom bound of the box.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double zMax
The z coordinate of the up bound of the box.
Vector CalculateIntersection(const Vector ¤t, const Vector &speed) const
Box()
Create a zero-sized box located at coordinates (0.0,0.0,0.0)
bool IsInside(const Vector &position) const
double xMin
The x coordinate of the left bound of the box.