A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
box.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 Dan Broyles
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Dan Broyles <dbroyl01@ku.edu>
18 */
19#ifndef BOX_H
20#define BOX_H
21
22#include "ns3/attribute-helper.h"
23#include "ns3/attribute.h"
24#include "ns3/vector.h"
25
26namespace ns3
27{
28
29/**
30 * \ingroup mobility
31 * \brief a 3d box
32 * \see attribute_Box
33 */
34class Box
35{
36 public:
37 /**
38 * Enum class to specify sides of a box
39 */
40 enum Side
41 {
47 DOWN
48 };
49
50 /**
51 * \param _xMin x coordinates of left boundary.
52 * \param _xMax x coordinates of right boundary.
53 * \param _yMin y coordinates of bottom boundary.
54 * \param _yMax y coordinates of top boundary.
55 * \param _zMin z coordinates of down boundary.
56 * \param _zMax z coordinates of up boundary.
57 *
58 * Create a box.
59 */
60 Box(double _xMin, double _xMax, double _yMin, double _yMax, double _zMin, double _zMax);
61 /**
62 * Create a zero-sized box located at coordinates (0.0,0.0,0.0)
63 */
64 Box();
65 /**
66 * \param position the position to test.
67 * \returns true if the input position is located within the box,
68 * false otherwise.
69 *
70 * This method compares the x, y, and z coordinates of the input position.
71 */
72 bool IsInside(const Vector& position) const;
73 /**
74 * \param position the position to test.
75 * \returns the side of the cube the input position is closest to.
76 *
77 * This method compares the x, y, and z coordinates of the input position.
78 */
79 Side GetClosestSide(const Vector& position) const;
80 /**
81 * \param current the current position
82 * \param speed the current speed
83 * \returns the intersection point between the rectangle and the current+speed vector.
84 *
85 * This method assumes that the current position is located _inside_
86 * the cube and checks for this with an assert.
87 * This method compares only the x and y coordinates of the input position
88 * and speed. It ignores the z coordinate.
89 */
90 Vector CalculateIntersection(const Vector& current, const Vector& speed) const;
91 /**
92 * \brief Checks if a line-segment between position l1 and position l2
93 * intersects a box.
94 *
95 * This method considers all the three coordinates, i.e., x, y, and z.
96 * This function was developed by NYU Wireless and is based on the algorithm
97 * described here http://www.3dkingdoms.com/weekly/weekly.php?a=21.
98 * Reference: Menglei Zhang, Michele Polese, Marco Mezzavilla, Sundeep Rangan,
99 * Michele Zorzi. "ns-3 Implementation of the 3GPP MIMO Channel Model for
100 * Frequency Spectrum above 6 GHz". In Proceedings of the Workshop on ns-3
101 * (WNS3 '17). 2017.
102 *
103 * \param l1 position
104 * \param l2 position
105 * \return true if there is a intersection, false otherwise
106 */
107 bool IsIntersect(const Vector& l1, const Vector& l2) const;
108
109 /** The x coordinate of the left bound of the box */
110 double xMin;
111 /** The x coordinate of the right bound of the box */
112 double xMax;
113 /** The y coordinate of the bottom bound of the box */
114 double yMin;
115 /** The y coordinate of the top bound of the box */
116 double yMax;
117 /** The z coordinate of the down bound of the box */
118 double zMin;
119 /** The z coordinate of the up bound of the box */
120 double zMax;
121};
122
123std::ostream& operator<<(std::ostream& os, const Box& box);
124std::istream& operator>>(std::istream& is, Box& box);
125
127
128} // namespace ns3
129
130#endif /* BOX_H */
a 3d box
Definition: box.h:35
double yMax
The y coordinate of the top bound of the box.
Definition: box.h:116
bool IsInside(const Vector &position) const
Definition: box.cc:54
double xMin
The x coordinate of the left bound of the box.
Definition: box.h:110
Side
Enum class to specify sides of a box.
Definition: box.h:41
@ RIGHT
Definition: box.h:42
@ UP
Definition: box.h:46
@ DOWN
Definition: box.h:47
@ BOTTOM
Definition: box.h:45
@ LEFT
Definition: box.h:43
@ TOP
Definition: box.h:44
double yMin
The y coordinate of the bottom bound of the box.
Definition: box.h:114
double xMax
The x coordinate of the right bound of the box.
Definition: box.h:112
Vector CalculateIntersection(const Vector &current, const Vector &speed) const
Definition: box.cc:108
double zMin
The z coordinate of the down bound of the box.
Definition: box.h:118
bool IsIntersect(const Vector &l1, const Vector &l2) const
Checks if a line-segment between position l1 and position l2 intersects a box.
Definition: box.cc:144
Side GetClosestSide(const Vector &position) const
Definition: box.cc:61
Box()
Create a zero-sized box located at coordinates (0.0,0.0,0.0)
Definition: box.cc:43
double zMax
The z coordinate of the up bound of the box.
Definition: box.h:120
#define ATTRIBUTE_HELPER_HEADER(type)
Declare 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)
Definition: angles.cc:159
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:183