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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Dan Broyles <dbroyl01@ku.edu>
7 */
8#ifndef BOX_H
9#define BOX_H
10
11#include "ns3/attribute-helper.h"
12#include "ns3/attribute.h"
13#include "ns3/vector.h"
14
15namespace ns3
16{
17
18/**
19 * \ingroup mobility
20 * \brief a 3d box
21 * \see attribute_Box
22 */
23class Box
24{
25 public:
26 /**
27 * Enum class to specify sides of a box
28 */
38
39 /**
40 * \param _xMin x coordinates of left boundary.
41 * \param _xMax x coordinates of right boundary.
42 * \param _yMin y coordinates of bottom boundary.
43 * \param _yMax y coordinates of top boundary.
44 * \param _zMin z coordinates of down boundary.
45 * \param _zMax z coordinates of up boundary.
46 *
47 * Create a box.
48 */
49 Box(double _xMin, double _xMax, double _yMin, double _yMax, double _zMin, double _zMax);
50 /**
51 * Create a zero-sized box located at coordinates (0.0,0.0,0.0)
52 */
53 Box();
54 /**
55 * \param position the position to test.
56 * \returns true if the input position is located within the box,
57 * false otherwise.
58 *
59 * This method compares the x, y, and z coordinates of the input position.
60 */
61 bool IsInside(const Vector& position) const;
62 /**
63 * \param position the position to test.
64 * \returns the side of the cube the input position is closest to.
65 *
66 * This method compares the x, y, and z coordinates of the input position.
67 */
68 Side GetClosestSide(const Vector& position) const;
69 /**
70 * \param current the current position
71 * \param speed the current speed
72 * \returns the intersection point between the rectangle and the current+speed vector.
73 *
74 * This method assumes that the current position is located _inside_
75 * the cube and checks for this with an assert.
76 * This method compares only the x and y coordinates of the input position
77 * and speed. It ignores the z coordinate.
78 */
79 Vector CalculateIntersection(const Vector& current, const Vector& speed) const;
80 /**
81 * \brief Checks if a line-segment between position l1 and position l2
82 * intersects a box.
83 *
84 * This method considers all the three coordinates, i.e., x, y, and z.
85 * This function was developed by NYU Wireless and is based on the algorithm
86 * described here http://www.3dkingdoms.com/weekly/weekly.php?a=21.
87 * Reference: Menglei Zhang, Michele Polese, Marco Mezzavilla, Sundeep Rangan,
88 * Michele Zorzi. "ns-3 Implementation of the 3GPP MIMO Channel Model for
89 * Frequency Spectrum above 6 GHz". In Proceedings of the Workshop on ns-3
90 * (WNS3 '17). 2017.
91 *
92 * \param l1 position
93 * \param l2 position
94 * \return true if there is a intersection, false otherwise
95 */
96 bool IsIntersect(const Vector& l1, const Vector& l2) const;
97
98 /** The x coordinate of the left bound of the box */
99 double xMin;
100 /** The x coordinate of the right bound of the box */
101 double xMax;
102 /** The y coordinate of the bottom bound of the box */
103 double yMin;
104 /** The y coordinate of the top bound of the box */
105 double yMax;
106 /** The z coordinate of the down bound of the box */
107 double zMin;
108 /** The z coordinate of the up bound of the box */
109 double zMax;
110};
111
112std::ostream& operator<<(std::ostream& os, const Box& box);
113std::istream& operator>>(std::istream& is, Box& box);
114
116
117} // namespace ns3
118
119#endif /* BOX_H */
a 3d box
Definition box.h:24
double yMax
The y coordinate of the top bound of the box.
Definition box.h:105
bool IsInside(const Vector &position) const
Definition box.cc:43
double xMin
The x coordinate of the left bound of the box.
Definition box.h:99
Side
Enum class to specify sides of a box.
Definition box.h:30
@ RIGHT
Definition box.h:31
@ UP
Definition box.h:35
@ DOWN
Definition box.h:36
@ BOTTOM
Definition box.h:34
@ LEFT
Definition box.h:32
@ TOP
Definition box.h:33
double yMin
The y coordinate of the bottom bound of the box.
Definition box.h:103
double xMax
The x coordinate of the right bound of the box.
Definition box.h:101
Vector CalculateIntersection(const Vector &current, const Vector &speed) const
Definition box.cc:97
double zMin
The z coordinate of the down bound of the box.
Definition box.h:107
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:133
Side GetClosestSide(const Vector &position) const
Definition box.cc:50
Box()
Create a zero-sized box located at coordinates (0.0,0.0,0.0)
Definition box.cc:32
double zMax
The z coordinate of the up bound of the box.
Definition box.h:109
#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:148
std::istream & operator>>(std::istream &is, Angles &a)
Definition angles.cc:172