A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::Rectangle Class Reference

a 2d rectangle More...

#include "rectangle.h"

+ Collaboration diagram for ns3::Rectangle:

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 &current, 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.
 

Detailed Description

a 2d rectangle

See also
Rectangle Attribute

Definition at line 23 of file rectangle.h.

Member Enumeration Documentation

◆ Side

enum for naming sides

Enumerator
RIGHTSIDE 
LEFTSIDE 
TOPSIDE 
BOTTOMSIDE 
TOPRIGHTCORNER 
TOPLEFTCORNER 
BOTTOMRIGHTCORNER 
BOTTOMLEFTCORNER 

Definition at line 29 of file rectangle.h.

Constructor & Destructor Documentation

◆ Rectangle() [1/2]

ns3::Rectangle::Rectangle ( double _xMin,
double _xMax,
double _yMin,
double _yMax )
Parameters
_xMinx coordinates of left boundary.
_xMaxx coordinates of right boundary.
_yMiny coordinates of bottom boundary.
_yMaxy coordinates of top boundary.

Create a rectangle.

Definition at line 22 of file rectangle.cc.

◆ Rectangle() [2/2]

ns3::Rectangle::Rectangle ( )

Create a zero-sized rectangle located at coordinates (0.0,0.0)

Definition at line 30 of file rectangle.cc.

Member Function Documentation

◆ CalculateIntersection()

Vector ns3::Rectangle::CalculateIntersection ( const Vector & current,
const Vector & speed ) const
Parameters
currentthe current position
speedthe current speed
Returns
the intersection point between the rectangle and the current+speed vector.

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetClosestSideOrCorner()

Rectangle::Side ns3::Rectangle::GetClosestSideOrCorner ( const Vector & position) const
Parameters
positionthe position to test.
Returns
the side of the rectangle the input position is closest to.

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInside()

bool ns3::Rectangle::IsInside ( const Vector & position) const
Parameters
positionthe position to test.
Returns
true if the input position is located within the rectangle, false otherwise.

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().

+ Here is the caller graph for this function:

◆ IsOnTheBorder()

bool ns3::Rectangle::IsOnTheBorder ( const Vector & position) const
Parameters
positionthe position to test.
Returns
true if the input position is located on the rectable border, false otherwise.

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().

+ Here is the caller graph for this function:

Member Data Documentation

◆ xMax

◆ xMin

double ns3::Rectangle::xMin

◆ yMax

◆ yMin

double ns3::Rectangle::yMin

The documentation for this class was generated from the following files: