11#include "ns3/assert.h" 
   12#include "ns3/fatal-error.h" 
   13#include "ns3/vector.h" 
   22Box::Box(
double _xMin, 
double _xMax, 
double _yMin, 
double _yMax, 
double _zMin, 
double _zMax)
 
 
   45    return position.x <= this->
xMax && position.x >= this->
xMin && position.y <= this->
yMax &&
 
   46           position.y >= this->
yMin && position.z <= this->
zMax && position.z >= this->
zMin;
 
 
   52    double xMinDist = std::abs(position.x - this->xMin);
 
   53    double xMaxDist = std::abs(this->
xMax - position.x);
 
   54    double yMinDist = std::abs(position.y - this->yMin);
 
   55    double yMaxDist = std::abs(this->
yMax - position.y);
 
   56    double zMinDist = std::abs(position.z - this->zMin);
 
   57    double zMaxDist = std::abs(this->
zMax - position.z);
 
   58    double minX = std::min(xMinDist, xMaxDist);
 
   59    double minY = std::min(yMinDist, yMaxDist);
 
   60    double minZ = std::min(zMinDist, zMaxDist);
 
   61    if (minX < minY && minX < minZ)
 
   63        if (xMinDist < xMaxDist)
 
   74        if (yMinDist < yMaxDist)
 
   85        if (zMinDist < zMaxDist)
 
 
  100    double xMaxY = current.y + (this->
xMax - current.x) / speed.x * speed.y;
 
  101    double xMinY = current.y + (this->
xMin - current.x) / speed.x * speed.y;
 
  102    double yMaxX = current.x + (this->
yMax - current.y) / speed.y * speed.x;
 
  103    double yMinX = current.x + (this->
yMin - current.y) / speed.y * speed.x;
 
  104    bool xMaxYOk = (xMaxY <= this->
yMax && xMaxY >= this->
yMin);
 
  105    bool xMinYOk = (xMinY <= this->
yMax && xMinY >= this->
yMin);
 
  106    bool yMaxXOk = (yMaxX <= this->
xMax && yMaxX >= this->
xMin);
 
  107    bool yMinXOk = (yMinX <= this->
xMax && yMinX >= this->
xMin);
 
  108    if (xMaxYOk && speed.x >= 0)
 
  110        return Vector(this->
xMax, xMaxY, 0.0);
 
  112    else if (xMinYOk && speed.x <= 0)
 
  114        return Vector(this->
xMin, xMinY, 0.0);
 
  116    else if (yMaxXOk && speed.y >= 0)
 
  118        return Vector(yMaxX, this->
yMax, 0.0);
 
  120    else if (yMinXOk && speed.y <= 0)
 
  122        return Vector(yMinX, this->
yMin, 0.0);
 
  128        return Vector(0.0, 0.0, 0.0);
 
 
  142    Vector boxSize(0.5 * (this->
xMax - this->
xMin),
 
  145    Vector boxCenter(this->
xMin + boxSize.x, this->yMin + boxSize.y, this->zMin + boxSize.z);
 
  148    Vector lB1(l1.x - boxCenter.x, l1.y - boxCenter.y, l1.z - boxCenter.z);
 
  149    Vector lB2(l2.x - boxCenter.x, l2.y - boxCenter.y, l2.z - boxCenter.z);
 
  152    Vector lMid(0.5 * (lB1.x + lB2.x), 0.5 * (lB1.y + lB2.y), 0.5 * (lB1.z + lB2.z));
 
  153    Vector l(lB1.x - lMid.x, lB1.y - lMid.y, lB1.z - lMid.z);
 
  154    Vector lExt(std::abs(l.x), std::abs(l.y), std::abs(l.z));
 
  161    if (std::abs(lMid.x) > boxSize.x + lExt.x)
 
  165    if (std::abs(lMid.y) > boxSize.y + lExt.y)
 
  169    if (std::abs(lMid.z) > boxSize.z + lExt.z)
 
  174    if (std::abs(lMid.y * l.z - lMid.z * l.y) > (boxSize.y * lExt.z + boxSize.z * lExt.y))
 
  178    if (std::abs(lMid.x * l.z - lMid.z * l.x) > (boxSize.x * lExt.z + boxSize.z * lExt.x))
 
  182    if (std::abs(lMid.x * l.y - lMid.y * l.x) > (boxSize.x * lExt.y + boxSize.y * lExt.x))
 
 
  225    if (c1 != 
'|' || c2 != 
'|' || c3 != 
'|' || c4 != 
'|' || c5 != 
'|')
 
  227        is.setstate(std::ios_base::failbit);
 
 
double yMax
The y coordinate of the top bound of the box.
bool IsInside(const Vector &position) const
double xMin
The x coordinate of the left bound of the box.
Side
Enum class to specify sides of a box.
double yMin
The y coordinate of the bottom bound of the box.
double xMax
The x coordinate of the right bound of the box.
Vector CalculateIntersection(const Vector ¤t, const Vector &speed) const
double zMin
The z coordinate of the down bound of the box.
bool IsIntersect(const Vector &l1, const Vector &l2) const
Checks if a line-segment between position l1 and position l2 intersects a box.
Side GetClosestSide(const Vector &position) const
Box()
Create a zero-sized box located at coordinates (0.0,0.0,0.0)
double zMax
The z coordinate of the up bound of the box.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
std::istream & operator>>(std::istream &is, Angles &a)