A Discrete-Event Network Simulator
API
Public Types | Public Member Functions | Public Attributes | List of all members
ns3::Rectangle Class Reference

a 2d rectangle More...

#include "rectangle.h"

Public Types

enum  Side { RIGHT, LEFT, TOP, BOTTOM }
 enum for naming sides More...
 

Public Member Functions

 Rectangle (double _xMin, double _xMax, double _yMin, double _yMax)
 
 Rectangle ()
 Create a zero-sized rectangle located at coordinates (0.0,0.0) More...
 
Vector CalculateIntersection (const Vector &current, const Vector &speed) const
 
Side GetClosestSide (const Vector &position) const
 
bool IsInside (const Vector &position) const
 

Public Attributes

double xMax
 The x coordinate of the right bound of the rectangle. More...
 
double xMin
 The x coordinate of the left bound of the rectangle. More...
 
double yMax
 The y coordinate of the top bound of the rectangle. More...
 
double yMin
 The y coordinate of the bottom bound of the rectangle. More...
 

Detailed Description

a 2d rectangle

See also
Rectangle Attribute

Definition at line 34 of file rectangle.h.

Member Enumeration Documentation

◆ Side

enum for naming sides

Enumerator
RIGHT 
LEFT 
TOP 
BOTTOM 

Definition at line 40 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 30 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 39 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 89 of file rectangle.cc.

References IsInside(), NS_ASSERT, xMax, xMin, yMax, and yMin.

Referenced by ns3::RandomWalk2dMobilityModel::DoWalk(), and ns3::RandomDirection2dMobilityModel::SetDirectionAndSpeed().

◆ GetClosestSide()

Rectangle::Side ns3::Rectangle::GetClosestSide ( 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.

Definition at line 56 of file rectangle.cc.

References BOTTOM, LEFT, min, RIGHT, TOP, xMax, and yMax.

Referenced by ns3::RandomWalk2dMobilityModel::Rebound(), and ns3::RandomDirection2dMobilityModel::ResetDirectionAndSpeed().

◆ 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 48 of file rectangle.cc.

References xMax, xMin, yMax, and yMin.

Referenced by CalculateIntersection(), ns3::RandomWalk2dMobilityModel::DoSetPosition(), and ns3::RandomWalk2dMobilityModel::DoWalk().

Member Data Documentation

◆ xMax

double ns3::Rectangle::xMax

The x coordinate of the right bound of the rectangle.

Definition at line 89 of file rectangle.h.

Referenced by CalculateIntersection(), GetClosestSide(), IsInside(), ns3::operator<<(), ns3::operator>>(), and ns3::ConstantVelocityHelper::UpdateWithBounds().

◆ xMin

double ns3::Rectangle::xMin

The x coordinate of the left bound of the rectangle.

Definition at line 88 of file rectangle.h.

Referenced by CalculateIntersection(), IsInside(), ns3::operator<<(), ns3::operator>>(), and ns3::ConstantVelocityHelper::UpdateWithBounds().

◆ yMax

double ns3::Rectangle::yMax

The y coordinate of the top bound of the rectangle.

Definition at line 91 of file rectangle.h.

Referenced by CalculateIntersection(), GetClosestSide(), IsInside(), ns3::operator<<(), ns3::operator>>(), and ns3::ConstantVelocityHelper::UpdateWithBounds().

◆ yMin

double ns3::Rectangle::yMin

The y coordinate of the bottom bound of the rectangle.

Definition at line 90 of file rectangle.h.

Referenced by CalculateIntersection(), IsInside(), ns3::operator<<(), ns3::operator>>(), and ns3::ConstantVelocityHelper::UpdateWithBounds().


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