A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
rectangle.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
#ifndef RECTANGLE_H
20
#define RECTANGLE_H
21
22
#include "ns3/attribute-helper.h"
23
#include "ns3/attribute.h"
24
#include "ns3/vector.h"
25
26
namespace
ns3
27
{
28
29
/**
30
* \ingroup mobility
31
* \brief a 2d rectangle
32
* \see attribute_Rectangle
33
*/
34
class
Rectangle
35
{
36
public
:
37
/**
38
* enum for naming sides
39
*/
40
enum
Side
41
{
42
RIGHTSIDE
= 0,
43
LEFTSIDE
,
44
TOPSIDE
,
45
BOTTOMSIDE
,
46
TOPRIGHTCORNER
,
47
TOPLEFTCORNER
,
48
BOTTOMRIGHTCORNER
,
49
BOTTOMLEFTCORNER
50
};
51
52
/**
53
* \param _xMin x coordinates of left boundary.
54
* \param _xMax x coordinates of right boundary.
55
* \param _yMin y coordinates of bottom boundary.
56
* \param _yMax y coordinates of top boundary.
57
*
58
* Create a rectangle.
59
*/
60
Rectangle
(
double
_xMin,
double
_xMax,
double
_yMin,
double
_yMax);
61
/**
62
* Create a zero-sized rectangle located at coordinates (0.0,0.0)
63
*/
64
Rectangle
();
65
/**
66
* \param position the position to test.
67
* \return true if the input position is located within the rectangle, false otherwise.
68
*
69
* This method compares only the x and y coordinates of the input position.
70
* It ignores the z coordinate.
71
*/
72
bool
IsInside
(
const
Vector& position)
const
;
73
/**
74
* \param position the position to test.
75
* \return true if the input position is located on the rectable border, false otherwise.
76
*
77
* This method compares only the x and y coordinates of the input position.
78
* It ignores the z coordinate.
79
*/
80
bool
IsOnTheBorder
(
const
Vector& position)
const
;
81
/**
82
* \param position the position to test.
83
* \return the side of the rectangle the input position is closest to.
84
*
85
* This method compares only the x and y coordinates of the input position.
86
* It ignores the z coordinate.
87
*
88
* This method assumes assumes a right-handed Cartesian orientation, so that
89
* (xMin, yMin) is the BOTTOMLEFTCORNER, the TOP and BOTTOM sides are parallel to
90
* the x-axis, the LEFT and RIGHT sides are parallel to the y-axis, and the
91
* (xMax, yMax) point is the TOPRIGHTCORNER.
92
*
93
* Beware: the method has an ambiguity in the "center" of the rectangle. Assume
94
* a rectangle between the points (0, 0) and (4, 2), i.e., wider than taller.
95
* All the points on the line between (1, 1) and (3, 1) are equally closer to the
96
* TOP and BOTTOM than to the other sides of the Rectangle.
97
* These points are classified as TOPSIDE by convention.
98
*
99
* Similarly, for a Rectangle taller than wider, the "center" points will be
100
* classified as RIGHTSIDE, and for a square box, the center will return RIGHTSIDE.
101
*/
102
Side
GetClosestSideOrCorner
(
const
Vector& position)
const
;
103
/**
104
* \param current the current position
105
* \param speed the current speed
106
* \return the intersection point between the rectangle and the current+speed vector.
107
*
108
* This method assumes that the current position is located _inside_
109
* the rectangle and checks for this with an assert.
110
* This method compares only the x and y coordinates of the input position
111
* and speed. It ignores the z coordinate.
112
*/
113
Vector
CalculateIntersection
(
const
Vector& current,
const
Vector& speed)
const
;
114
115
double
xMin
;
//!< The x coordinate of the left bound of the rectangle
116
double
xMax
;
//!< The x coordinate of the right bound of the rectangle
117
double
yMin
;
//!< The y coordinate of the bottom bound of the rectangle
118
double
yMax
;
//!< The y coordinate of the top bound of the rectangle
119
};
120
121
std::ostream&
operator<<
(std::ostream& os,
const
Rectangle
& rectangle);
122
std::istream&
operator>>
(std::istream& is,
Rectangle
& rectangle);
123
std::ostream&
operator<<
(std::ostream& os,
const
Rectangle::Side
& side);
124
125
ATTRIBUTE_HELPER_HEADER
(
Rectangle
);
126
127
}
// namespace ns3
128
129
#endif
/* RECTANGLE_H */
ns3::Rectangle
a 2d rectangle
Definition:
rectangle.h:35
ns3::Rectangle::yMax
double yMax
The y coordinate of the top bound of the rectangle.
Definition:
rectangle.h:118
ns3::Rectangle::GetClosestSideOrCorner
Side GetClosestSideOrCorner(const Vector &position) const
Definition:
rectangle.cc:64
ns3::Rectangle::IsInside
bool IsInside(const Vector &position) const
Definition:
rectangle.cc:50
ns3::Rectangle::IsOnTheBorder
bool IsOnTheBorder(const Vector &position) const
Definition:
rectangle.cc:57
ns3::Rectangle::xMax
double xMax
The x coordinate of the right bound of the rectangle.
Definition:
rectangle.h:116
ns3::Rectangle::CalculateIntersection
Vector CalculateIntersection(const Vector ¤t, const Vector &speed) const
Definition:
rectangle.cc:152
ns3::Rectangle::Side
Side
enum for naming sides
Definition:
rectangle.h:41
ns3::Rectangle::BOTTOMSIDE
@ BOTTOMSIDE
Definition:
rectangle.h:45
ns3::Rectangle::TOPSIDE
@ TOPSIDE
Definition:
rectangle.h:44
ns3::Rectangle::LEFTSIDE
@ LEFTSIDE
Definition:
rectangle.h:43
ns3::Rectangle::BOTTOMLEFTCORNER
@ BOTTOMLEFTCORNER
Definition:
rectangle.h:49
ns3::Rectangle::BOTTOMRIGHTCORNER
@ BOTTOMRIGHTCORNER
Definition:
rectangle.h:48
ns3::Rectangle::TOPLEFTCORNER
@ TOPLEFTCORNER
Definition:
rectangle.h:47
ns3::Rectangle::RIGHTSIDE
@ RIGHTSIDE
Definition:
rectangle.h:42
ns3::Rectangle::TOPRIGHTCORNER
@ TOPRIGHTCORNER
Definition:
rectangle.h:46
ns3::Rectangle::xMin
double xMin
The x coordinate of the left bound of the rectangle.
Definition:
rectangle.h:115
ns3::Rectangle::Rectangle
Rectangle()
Create a zero-sized rectangle located at coordinates (0.0,0.0)
Definition:
rectangle.cc:41
ns3::Rectangle::yMin
double yMin
The y coordinate of the bottom bound of the rectangle.
Definition:
rectangle.h:117
ATTRIBUTE_HELPER_HEADER
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Definition:
attribute-helper.h:407
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:159
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
Definition:
angles.cc:183
src
mobility
model
rectangle.h
Generated on Tue May 28 2024 23:38:19 for ns-3 by
1.9.6