a 2d rectangle More...
#include "rectangle.h"
Public Types | |
enum | Side { RIGHTSIDE = 0 , LEFTSIDE , TOPSIDE , BOTTOMSIDE , TOPRIGHTCORNER , TOPLEFTCORNER , BOTTOMRIGHTCORNER , BOTTOMLEFTCORNER } |
enum for naming sides More... | |
Public Member Functions | |
Rectangle () | |
Create a zero-sized rectangle located at coordinates (0.0,0.0) | |
Rectangle (double _xMin, double _xMax, double _yMin, double _yMax) | |
Vector | CalculateIntersection (const Vector ¤t, const Vector &speed) const |
Side | GetClosestSideOrCorner (const Vector &position) const |
bool | IsInside (const Vector &position) const |
bool | IsOnTheBorder (const Vector &position) const |
Public Attributes | |
double | xMax |
The x coordinate of the right bound of the rectangle. | |
double | xMin |
The x coordinate of the left bound of the rectangle. | |
double | yMax |
The y coordinate of the top bound of the rectangle. | |
double | yMin |
The y coordinate of the bottom bound of the rectangle. | |
enum ns3::Rectangle::Side |
enum for naming sides
Enumerator | |
---|---|
RIGHTSIDE | |
LEFTSIDE | |
TOPSIDE | |
BOTTOMSIDE | |
TOPRIGHTCORNER | |
TOPLEFTCORNER | |
BOTTOMRIGHTCORNER | |
BOTTOMLEFTCORNER |
Definition at line 29 of file rectangle.h.
_xMin | x coordinates of left boundary. |
_xMax | x coordinates of right boundary. |
_yMin | y coordinates of bottom boundary. |
_yMax | y coordinates of top boundary. |
Create a rectangle.
Definition at line 22 of file rectangle.cc.
ns3::Rectangle::Rectangle | ( | ) |
Create a zero-sized rectangle located at coordinates (0.0,0.0)
Definition at line 30 of file rectangle.cc.
Vector ns3::Rectangle::CalculateIntersection | ( | const Vector & | current, |
const Vector & | speed ) const |
current | the current position |
speed | the current speed |
This method assumes that the current position is located inside the rectangle and checks for this with an assert. This method compares only the x and y coordinates of the input position and speed. It ignores the z coordinate.
Definition at line 141 of file rectangle.cc.
References IsInside(), NS_ASSERT, xMax, xMin, yMax, and yMin.
Referenced by ns3::RandomWalk2dMobilityModel::DoWalk(), ns3::RandomWalk2dOutdoorMobilityModel::DoWalk(), and ns3::RandomDirection2dMobilityModel::SetDirectionAndSpeed().
Rectangle::Side ns3::Rectangle::GetClosestSideOrCorner | ( | const Vector & | position | ) | const |
position | the position to test. |
This method compares only the x and y coordinates of the input position. It ignores the z coordinate.
This method assumes assumes a right-handed Cartesian orientation, so that (xMin, yMin) is the BOTTOMLEFTCORNER, the TOP and BOTTOM sides are parallel to the x-axis, the LEFT and RIGHT sides are parallel to the y-axis, and the (xMax, yMax) point is the TOPRIGHTCORNER.
Beware: the method has an ambiguity in the "center" of the rectangle. Assume a rectangle between the points (0, 0) and (4, 2), i.e., wider than taller. All the points on the line between (1, 1) and (3, 1) are equally closer to the TOP and BOTTOM than to the other sides of the Rectangle. These points are classified as TOPSIDE by convention.
Similarly, for a Rectangle taller than wider, the "center" points will be classified as RIGHTSIDE, and for a square box, the center will return RIGHTSIDE.
Definition at line 53 of file rectangle.cc.
References BOTTOMLEFTCORNER, BOTTOMRIGHTCORNER, BOTTOMSIDE, IsInside(), LEFTSIDE, NS_ASSERT, NS_FATAL_ERROR, RIGHTSIDE, TOPLEFTCORNER, TOPRIGHTCORNER, TOPSIDE, xMax, and yMax.
Referenced by ns3::RandomWalk2dOutdoorMobilityModel::CalculateIntersectionFromOutside(), RectangleClosestBorderTestCase::DoRun(), ns3::RandomWalk2dMobilityModel::DrawRandomVelocityAndDistance(), ns3::RandomWalk2dMobilityModel::Rebound(), ns3::RandomWalk2dOutdoorMobilityModel::Rebound(), and ns3::RandomDirection2dMobilityModel::ResetDirectionAndSpeed().
bool ns3::Rectangle::IsInside | ( | const Vector & | position | ) | const |
position | the position to test. |
This method compares only the x and y coordinates of the input position. It ignores the z coordinate.
Definition at line 39 of file rectangle.cc.
References xMax, xMin, yMax, and yMin.
Referenced by ns3::RandomWalk2dOutdoorMobilityModel::AvoidBuilding(), CalculateIntersection(), ns3::RandomWalk2dMobilityModel::DoSetPosition(), ns3::RandomWalk2dOutdoorMobilityModel::DoSetPosition(), ns3::RandomWalk2dMobilityModel::DoWalk(), ns3::RandomWalk2dOutdoorMobilityModel::DoWalk(), and GetClosestSideOrCorner().
bool ns3::Rectangle::IsOnTheBorder | ( | const Vector & | position | ) | const |
position | the position to test. |
This method compares only the x and y coordinates of the input position. It ignores the z coordinate.
Definition at line 46 of file rectangle.cc.
References xMax, xMin, yMax, and yMin.
Referenced by ns3::RandomWalk2dMobilityModel::DrawRandomVelocityAndDistance().
double ns3::Rectangle::xMax |
The x coordinate of the right bound of the rectangle.
Definition at line 105 of file rectangle.h.
Referenced by RectangleClosestBorderTestCase::BuildNameString(), CalculateIntersection(), GetClosestSideOrCorner(), IsInside(), IsOnTheBorder(), ns3::operator<<(), ns3::operator>>(), and ns3::ConstantVelocityHelper::UpdateWithBounds().
double ns3::Rectangle::xMin |
The x coordinate of the left bound of the rectangle.
Definition at line 104 of file rectangle.h.
Referenced by RectangleClosestBorderTestCase::BuildNameString(), CalculateIntersection(), IsInside(), IsOnTheBorder(), ns3::operator<<(), ns3::operator>>(), and ns3::ConstantVelocityHelper::UpdateWithBounds().
double ns3::Rectangle::yMax |
The y coordinate of the top bound of the rectangle.
Definition at line 107 of file rectangle.h.
Referenced by RectangleClosestBorderTestCase::BuildNameString(), CalculateIntersection(), GetClosestSideOrCorner(), IsInside(), IsOnTheBorder(), ns3::operator<<(), ns3::operator>>(), and ns3::ConstantVelocityHelper::UpdateWithBounds().
double ns3::Rectangle::yMin |
The y coordinate of the bottom bound of the rectangle.
Definition at line 106 of file rectangle.h.
Referenced by RectangleClosestBorderTestCase::BuildNameString(), CalculateIntersection(), IsInside(), IsOnTheBorder(), ns3::operator<<(), ns3::operator>>(), and ns3::ConstantVelocityHelper::UpdateWithBounds().