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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
#ifndef RECTANGLE_H
9
#define RECTANGLE_H
10
11
#include "ns3/attribute-helper.h"
12
#include "ns3/attribute.h"
13
#include "ns3/vector.h"
14
15
namespace
ns3
16
{
17
18
/**
19
* @ingroup mobility
20
* @brief a 2d rectangle
21
* @see attribute_Rectangle
22
*/
23
class
Rectangle
24
{
25
public
:
26
/**
27
* enum for naming sides
28
*/
29
enum
Side
30
{
31
RIGHTSIDE
= 0,
32
LEFTSIDE
,
33
TOPSIDE
,
34
BOTTOMSIDE
,
35
TOPRIGHTCORNER
,
36
TOPLEFTCORNER
,
37
BOTTOMRIGHTCORNER
,
38
BOTTOMLEFTCORNER
39
};
40
41
/**
42
* @param _xMin x coordinates of left boundary.
43
* @param _xMax x coordinates of right boundary.
44
* @param _yMin y coordinates of bottom boundary.
45
* @param _yMax y coordinates of top boundary.
46
*
47
* Create a rectangle.
48
*/
49
Rectangle
(
double
_xMin,
double
_xMax,
double
_yMin,
double
_yMax);
50
/**
51
* Create a zero-sized rectangle located at coordinates (0.0,0.0)
52
*/
53
Rectangle
();
54
/**
55
* @param position the position to test.
56
* @return true if the input position is located within the rectangle, false otherwise.
57
*
58
* This method compares only the x and y coordinates of the input position.
59
* It ignores the z coordinate.
60
*/
61
bool
IsInside
(
const
Vector& position)
const
;
62
/**
63
* @param position the position to test.
64
* @return true if the input position is located on the rectable border, false otherwise.
65
*
66
* This method compares only the x and y coordinates of the input position.
67
* It ignores the z coordinate.
68
*/
69
bool
IsOnTheBorder
(
const
Vector& position)
const
;
70
/**
71
* @param position the position to test.
72
* @return the side of the rectangle the input position is closest to.
73
*
74
* This method compares only the x and y coordinates of the input position.
75
* It ignores the z coordinate.
76
*
77
* This method assumes assumes a right-handed Cartesian orientation, so that
78
* (xMin, yMin) is the BOTTOMLEFTCORNER, the TOP and BOTTOM sides are parallel to
79
* the x-axis, the LEFT and RIGHT sides are parallel to the y-axis, and the
80
* (xMax, yMax) point is the TOPRIGHTCORNER.
81
*
82
* Beware: the method has an ambiguity in the "center" of the rectangle. Assume
83
* a rectangle between the points (0, 0) and (4, 2), i.e., wider than taller.
84
* All the points on the line between (1, 1) and (3, 1) are equally closer to the
85
* TOP and BOTTOM than to the other sides of the Rectangle.
86
* These points are classified as TOPSIDE by convention.
87
*
88
* Similarly, for a Rectangle taller than wider, the "center" points will be
89
* classified as RIGHTSIDE, and for a square box, the center will return RIGHTSIDE.
90
*/
91
Side
GetClosestSideOrCorner
(
const
Vector& position)
const
;
92
/**
93
* @param current the current position
94
* @param speed the current speed
95
* @return the intersection point between the rectangle and the current+speed vector.
96
*
97
* This method assumes that the current position is located _inside_
98
* the rectangle and checks for this with an assert.
99
* This method compares only the x and y coordinates of the input position
100
* and speed. It ignores the z coordinate.
101
*/
102
Vector
CalculateIntersection
(
const
Vector& current,
const
Vector& speed)
const
;
103
104
double
xMin
;
//!< The x coordinate of the left bound of the rectangle
105
double
xMax
;
//!< The x coordinate of the right bound of the rectangle
106
double
yMin
;
//!< The y coordinate of the bottom bound of the rectangle
107
double
yMax
;
//!< The y coordinate of the top bound of the rectangle
108
};
109
110
std::ostream&
operator<<
(std::ostream& os,
const
Rectangle
& rectangle);
111
std::istream&
operator>>
(std::istream& is,
Rectangle
& rectangle);
112
std::ostream&
operator<<
(std::ostream& os,
const
Rectangle::Side
& side);
113
114
ATTRIBUTE_HELPER_HEADER
(
Rectangle
);
115
116
}
// namespace ns3
117
118
#endif
/* RECTANGLE_H */
ns3::Rectangle
a 2d rectangle
Definition
rectangle.h:24
ns3::Rectangle::yMax
double yMax
The y coordinate of the top bound of the rectangle.
Definition
rectangle.h:107
ns3::Rectangle::GetClosestSideOrCorner
Side GetClosestSideOrCorner(const Vector &position) const
Definition
rectangle.cc:53
ns3::Rectangle::IsInside
bool IsInside(const Vector &position) const
Definition
rectangle.cc:39
ns3::Rectangle::IsOnTheBorder
bool IsOnTheBorder(const Vector &position) const
Definition
rectangle.cc:46
ns3::Rectangle::xMax
double xMax
The x coordinate of the right bound of the rectangle.
Definition
rectangle.h:105
ns3::Rectangle::CalculateIntersection
Vector CalculateIntersection(const Vector ¤t, const Vector &speed) const
Definition
rectangle.cc:141
ns3::Rectangle::Side
Side
enum for naming sides
Definition
rectangle.h:30
ns3::Rectangle::BOTTOMSIDE
@ BOTTOMSIDE
Definition
rectangle.h:34
ns3::Rectangle::TOPSIDE
@ TOPSIDE
Definition
rectangle.h:33
ns3::Rectangle::LEFTSIDE
@ LEFTSIDE
Definition
rectangle.h:32
ns3::Rectangle::BOTTOMLEFTCORNER
@ BOTTOMLEFTCORNER
Definition
rectangle.h:38
ns3::Rectangle::BOTTOMRIGHTCORNER
@ BOTTOMRIGHTCORNER
Definition
rectangle.h:37
ns3::Rectangle::TOPLEFTCORNER
@ TOPLEFTCORNER
Definition
rectangle.h:36
ns3::Rectangle::RIGHTSIDE
@ RIGHTSIDE
Definition
rectangle.h:31
ns3::Rectangle::TOPRIGHTCORNER
@ TOPRIGHTCORNER
Definition
rectangle.h:35
ns3::Rectangle::xMin
double xMin
The x coordinate of the left bound of the rectangle.
Definition
rectangle.h:104
ns3::Rectangle::Rectangle
Rectangle()
Create a zero-sized rectangle located at coordinates (0.0,0.0)
Definition
rectangle.cc:30
ns3::Rectangle::yMin
double yMin
The y coordinate of the bottom bound of the rectangle.
Definition
rectangle.h:106
ATTRIBUTE_HELPER_HEADER
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Definition
attribute-helper.h:397
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:148
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
Definition
angles.cc:172
src
mobility
model
rectangle.h
Generated on Fri Dec 13 2024 18:20:46 for ns-3 by
1.11.0