MiXiM  2.3

Rectangle movement model. See NED file for more info. More...

#include <RectangleMobility.h>

Inheritance diagram for RectangleMobility:
Collaboration diagram for RectangleMobility:

List of all members.

Protected Member Functions

virtual void initialize (int stage)
 Initializes mobility model parameters.
virtual void initializePosition ()
 Initializes the position according to the mobility model.
virtual void move ()
 Move the host.

Protected Attributes

double speed
 speed of the host
double d
 distance from (x1,y1), measured clockwise on the perimeter
double corner1
double corner2
double corner3
double corner4

Detailed Description

Rectangle movement model. See NED file for more info.

Author:
Andras Varga

Member Function Documentation

void RectangleMobility::initialize ( int  stage) [protected, virtual]

Initializes mobility model parameters.

If the host is not stationary it calculates a random position on the rectangle.

Reimplemented from MovingMobilityBase.

References MobilityBase::constraintAreaMin, d, speed, and MovingMobilityBase::stationary.

{
    MovingMobilityBase::initialize(stage);
    EV << "initializing RectangleMobility stage " << stage << endl;
    if (stage == 0)
    {
        speed = par("speed");
        stationary = (speed == 0);

        // calculate helper variables
        double dx = constraintAreaMax.x - constraintAreaMin.x;
        double dy = constraintAreaMax.y - constraintAreaMin.y;
        corner1 = dx;
        corner2 = corner1 + dy;
        corner3 = corner2 + dx;
        corner4 = corner3 + dy;

        // determine start position
        double startPos = par("startPos");
        startPos = fmod(startPos, 4);
        if (startPos < 1)
            d = startPos * dx; // top side
        else if (startPos < 2)
            d = corner1 + (startPos - 1) * dy; // right side
        else if (startPos < 3)
            d = corner2 + (startPos - 2) * dx; // bottom side
        else
            d = corner3 + (startPos - 3) * dy; // left side
        WATCH(d);
    }
}

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