Linear movement model. See NED file for more info. More...
#include <LinearMobility.h>
Inherits BaseMobility.
Public Member Functions | |
virtual void | initialize (int) |
Initializes mobility model parameters. | |
Protected Member Functions | |
virtual void | makeMove () |
Move the host. | |
virtual void | fixIfHostGetsOutside () |
Should be redefined in subclasses. | |
Protected Attributes | |
double | angle |
angle of linear motion | |
double | acceleration |
acceleration of linear motion | |
Coord | stepTarget |
always stores the last step for position display update |
Linear movement model. See NED file for more info.
This mobility module expects a torus as playground ("useTorus" Parameter of BaseWorldUtility module).
NOTE: Does not yet support 3-dimensional movement.
Definition at line 36 of file LinearMobility.h.
void LinearMobility::fixIfHostGetsOutside | ( | ) | [protected, virtual] |
Should be redefined in subclasses.
Should invoke handleIfOutside() and pass the references to the parameters to be modified.
Additional action after border handling (such as choosing a new target position if the BorderPolicy is PLACERANDOMLY) should be implemented here.
Reimplemented from BaseMobility.
Definition at line 56 of file LinearMobility.cc.
References angle, BaseMobility::handleIfOutside(), stepTarget, BaseWorldUtility::use2D(), BaseMobility::world, and BaseMobility::WRAP.
Referenced by makeMove().
{ Coord dummy(world->use2D()); handleIfOutside(WRAP, stepTarget, dummy, dummy, angle); }
void LinearMobility::makeMove | ( | ) | [protected, virtual] |
Move the host.
Move the host if the destination is not reached yet. Otherwise calculate a new random position
Reimplemented from BaseMobility.
Definition at line 67 of file LinearMobility.cc.
References acceleration, angle, fixIfHostGetsOutside(), Move::getSpeed(), Move::getStartPos(), Coord::getX(), Coord::getY(), Coord::info(), Move::info(), BaseMobility::move, Move::setDirectionByTarget(), Move::setSpeed(), Move::setStart(), Coord::setX(), Coord::setY(), stepTarget, and BaseMobility::updateInterval.
{ debugEV << "start makeMove " << move.info() << endl; move.setStart(stepTarget, simTime()); stepTarget.setX(move.getStartPos().getX() + move.getSpeed() * cos(PI * angle / 180) * updateInterval.dbl()); stepTarget.setY(move.getStartPos().getY() + move.getSpeed() * sin(PI * angle / 180) * updateInterval.dbl()); move.setDirectionByTarget(stepTarget); debugEV << "new stepTarget: " << stepTarget.info() << endl; // accelerate move.setSpeed(move.getSpeed() + acceleration * updateInterval.dbl()); fixIfHostGetsOutside(); }