replace Position and Speed by Vector
This commit is contained in:
@@ -41,7 +41,7 @@ int main (int argc, char *argv[])
|
||||
Ptr<Object> object = *j;
|
||||
Ptr<MobilityModel> position = object->QueryInterface<MobilityModel> (MobilityModel::iid);
|
||||
NS_ASSERT (position != 0);
|
||||
Position pos = position->GetPosition ();
|
||||
Vector pos = position->GetPosition ();
|
||||
std::cout << "x=" << pos.x << ", y=" << pos.y << ", z=" << pos.z << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ using namespace ns3;
|
||||
static void
|
||||
CourseChange (const TraceContext &context, Ptr<const MobilityModel> position)
|
||||
{
|
||||
Position pos = position->GetPosition ();
|
||||
Vector pos = position->GetPosition ();
|
||||
std::cout << Simulator::Now () << ", pos=" << position << ", x=" << pos.x << ", y=" << pos.y
|
||||
<< ", z=" << pos.z << std::endl;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ using namespace ns3;
|
||||
static void
|
||||
CourseChange (ns3::TraceContext const&, Ptr<const MobilityModel> mobility)
|
||||
{
|
||||
Position pos = mobility->GetPosition ();
|
||||
Speed vel = mobility->GetSpeed ();
|
||||
Vector pos = mobility->GetPosition ();
|
||||
Vector vel = mobility->GetSpeed ();
|
||||
std::cout << Simulator::Now () << ", model=" << mobility << ", POS: x=" << pos.x << ", y=" << pos.y
|
||||
<< ", z=" << pos.z << "; VEL:" << vel.dx << ", y=" << vel.dy
|
||||
<< ", z=" << vel.dz << std::endl;
|
||||
<< ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
|
||||
<< ", z=" << vel.z << std::endl;
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
|
||||
@@ -46,7 +46,7 @@ GridTopology::LayoutOneRowFirst (Ptr<Object> object, uint32_t i)
|
||||
Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_positionClassId,
|
||||
MobilityModel::iid);
|
||||
object->AddInterface (mobility);
|
||||
mobility->SetPosition (Position (x, y, 0.0));
|
||||
mobility->SetPosition (Vector (x, y, 0.0));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -58,7 +58,7 @@ GridTopology::LayoutOneColumnFirst (Ptr<Object> object, uint32_t i)
|
||||
Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_positionClassId,
|
||||
MobilityModel::iid);
|
||||
object->AddInterface (mobility);
|
||||
mobility->SetPosition (Position (x, y, 0.0));
|
||||
mobility->SetPosition (Vector (x, y, 0.0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,34 +56,34 @@ HierarchicalMobilityModel::GetParent (void) const
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
Position
|
||||
Vector
|
||||
HierarchicalMobilityModel::DoGetPosition (void) const
|
||||
{
|
||||
Position parentPosition = m_parent->GetPosition ();
|
||||
Position childPosition = m_child->GetPosition ();
|
||||
return Position (parentPosition.x + childPosition.x,
|
||||
Vector parentPosition = m_parent->GetPosition ();
|
||||
Vector childPosition = m_child->GetPosition ();
|
||||
return Vector (parentPosition.x + childPosition.x,
|
||||
parentPosition.y + childPosition.y,
|
||||
parentPosition.z + childPosition.z);
|
||||
}
|
||||
void
|
||||
HierarchicalMobilityModel::DoSetPosition (const Position &position)
|
||||
HierarchicalMobilityModel::DoSetPosition (const Vector &position)
|
||||
{
|
||||
// This implementation of DoSetPosition is really an arbitraty choice.
|
||||
// anything else would have been ok.
|
||||
Position parentPosition = m_parent->GetPosition ();
|
||||
Position childPosition (position.x - parentPosition.x,
|
||||
Vector parentPosition = m_parent->GetPosition ();
|
||||
Vector childPosition (position.x - parentPosition.x,
|
||||
position.y - parentPosition.y,
|
||||
position.z - parentPosition.z);
|
||||
m_child->SetPosition (childPosition);
|
||||
}
|
||||
Speed
|
||||
Vector
|
||||
HierarchicalMobilityModel::DoGetSpeed (void) const
|
||||
{
|
||||
Speed parentSpeed = m_parent->GetSpeed ();
|
||||
Speed childSpeed = m_child->GetSpeed ();
|
||||
Speed speed (parentSpeed.dx + childSpeed.dx,
|
||||
parentSpeed.dy + childSpeed.dy,
|
||||
parentSpeed.dz + childSpeed.dz);
|
||||
Vector parentSpeed = m_parent->GetSpeed ();
|
||||
Vector childSpeed = m_child->GetSpeed ();
|
||||
Vector speed (parentSpeed.x + childSpeed.x,
|
||||
parentSpeed.y + childSpeed.y,
|
||||
parentSpeed.z + childSpeed.z);
|
||||
return speed;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,9 @@ public:
|
||||
Ptr<MobilityModel> GetParent (void) const;
|
||||
|
||||
private:
|
||||
virtual Position DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Position &position);
|
||||
virtual Speed DoGetSpeed (void) const;
|
||||
virtual Vector DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Vector &position);
|
||||
virtual Vector DoGetSpeed (void) const;
|
||||
|
||||
void ParentChanged (const TraceContext &context, Ptr<const MobilityModel> model);
|
||||
void ChildChanged (const TraceContext &context, Ptr<const MobilityModel> model);
|
||||
|
||||
@@ -33,19 +33,19 @@ MobilityModel::MobilityModel ()
|
||||
MobilityModel::~MobilityModel ()
|
||||
{}
|
||||
|
||||
Position
|
||||
Vector
|
||||
MobilityModel::GetPosition (void) const
|
||||
{
|
||||
return DoGetPosition ();
|
||||
}
|
||||
Speed
|
||||
Vector
|
||||
MobilityModel::GetSpeed (void) const
|
||||
{
|
||||
return DoGetSpeed ();
|
||||
}
|
||||
|
||||
void
|
||||
MobilityModel::SetPosition (const Position &position)
|
||||
MobilityModel::SetPosition (const Vector &position)
|
||||
{
|
||||
DoSetPosition (position);
|
||||
}
|
||||
@@ -53,8 +53,8 @@ MobilityModel::SetPosition (const Position &position)
|
||||
double
|
||||
MobilityModel::GetDistanceFrom (Ptr<const MobilityModel> other) const
|
||||
{
|
||||
Position oPosition = other->DoGetPosition ();
|
||||
Position position = DoGetPosition ();
|
||||
Vector oPosition = other->DoGetPosition ();
|
||||
Vector position = DoGetPosition ();
|
||||
return CalculateDistance (position, oPosition);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
#define MOBILITY_MODEL_H
|
||||
|
||||
#include "ns3/object.h"
|
||||
#include "position.h"
|
||||
#include "speed.h"
|
||||
#include "vector.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -43,15 +42,15 @@ public:
|
||||
/**
|
||||
* \returns the current position
|
||||
*/
|
||||
Position GetPosition (void) const;
|
||||
Vector GetPosition (void) const;
|
||||
/**
|
||||
* \param position the position to set.
|
||||
*/
|
||||
void SetPosition (const Position &position);
|
||||
void SetPosition (const Vector &position);
|
||||
/**
|
||||
* \returns the current position.
|
||||
*/
|
||||
Speed GetSpeed (void) const;
|
||||
Vector GetSpeed (void) const;
|
||||
/**
|
||||
* \param position a reference to another mobility model
|
||||
* \returns the distance between the two objects. Unit is meters.
|
||||
@@ -70,21 +69,21 @@ private:
|
||||
* Concrete subclasses of this base class must
|
||||
* implement this method.
|
||||
*/
|
||||
virtual Position DoGetPosition (void) const = 0;
|
||||
virtual Vector DoGetPosition (void) const = 0;
|
||||
/**
|
||||
* \param position the position to set.
|
||||
*
|
||||
* Concrete subclasses of this base class must
|
||||
* implement this method.
|
||||
*/
|
||||
virtual void DoSetPosition (const Position &position) = 0;
|
||||
virtual void DoSetPosition (const Vector &position) = 0;
|
||||
/**
|
||||
* \returns the current speed.
|
||||
*
|
||||
* Concrete subclasses of this base class must
|
||||
* implement this method.
|
||||
*/
|
||||
virtual Speed DoGetSpeed (void) const = 0;
|
||||
virtual Vector DoGetSpeed (void) const = 0;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
@@ -97,7 +97,7 @@ Ns2MobilityFileTopology::LayoutObjectStore (const ObjectStore &store) const
|
||||
{
|
||||
double value = ReadDouble (line.substr (endNodeId + 9, std::string::npos));
|
||||
std::string coordinate = line.substr (endNodeId + 6, 1);
|
||||
Position position = model->GetPosition ();
|
||||
Vector position = model->GetPosition ();
|
||||
if (coordinate == "X")
|
||||
{
|
||||
position.x = value;
|
||||
@@ -129,7 +129,7 @@ Ns2MobilityFileTopology::LayoutObjectStore (const ObjectStore &store) const
|
||||
double zSpeed = ReadDouble (line.substr (ySpeedEnd + 1, std::string::npos));
|
||||
NS_LOG_DEBUG ("at=" << at << "xSpeed=" << xSpeed << ", ySpeed=" << ySpeed << ", zSpeed=" << zSpeed);
|
||||
Simulator::Schedule (Seconds (at), &StaticSpeedMobilityModel::SetSpeed, model,
|
||||
Speed (xSpeed, ySpeed, zSpeed));
|
||||
Vector (xSpeed, ySpeed, zSpeed));
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "position.h"
|
||||
#include <cmath>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
Position::Position (double _x, double _y, double _z)
|
||||
: x (_x),
|
||||
y (_y),
|
||||
z (_z)
|
||||
{}
|
||||
|
||||
Position::Position ()
|
||||
: x (0.0),
|
||||
y (0.0),
|
||||
z (0.0)
|
||||
{}
|
||||
|
||||
double
|
||||
CalculateDistance (const Position &a, const Position &b)
|
||||
{
|
||||
double dx = b.x - a.x;
|
||||
double dy = b.y - a.y;
|
||||
double dz = b.z - a.z;
|
||||
double distance = std::sqrt (dx * dx + dy * dy + dz * dz);
|
||||
return distance;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,63 +0,0 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef POSITION_H
|
||||
#define POSITION_H
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \brief a 3d cartesian position vector
|
||||
*
|
||||
* Unit is meters.
|
||||
*/
|
||||
class Position
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \param _x x coordinate of position vector
|
||||
* \param _y y coordinate of position vector
|
||||
* \param _z z coordinate of position vector
|
||||
*
|
||||
* Create position vector (_x, _y, _z)
|
||||
*/
|
||||
Position (double _x, double _y, double _z);
|
||||
/**
|
||||
* Create position vector (0.0, 0.0, 0.0)
|
||||
*/
|
||||
Position ();
|
||||
/**
|
||||
* x coordinate of position vector
|
||||
*/
|
||||
double x;
|
||||
/**
|
||||
* y coordinate of position vector
|
||||
*/
|
||||
double y;
|
||||
/**
|
||||
* z coordinate of position vector
|
||||
*/
|
||||
double z;
|
||||
};
|
||||
|
||||
double CalculateDistance (const Position &a, const Position &b);
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* POSITION_H */
|
||||
@@ -153,12 +153,12 @@ RandomDirection2dMobilityModel::SetDirectionAndSpeed (double direction)
|
||||
{
|
||||
NS_LOG_FUNCTION;
|
||||
double speed = m_parameters->m_speedVariable->GetValue ();
|
||||
const Speed vector (std::cos (direction) * speed,
|
||||
std::sin (direction) * speed,
|
||||
0.0);
|
||||
Position position = m_helper.GetCurrentPosition (m_parameters->m_bounds);
|
||||
const Vector vector (std::cos (direction) * speed,
|
||||
std::sin (direction) * speed,
|
||||
0.0);
|
||||
Vector position = m_helper.GetCurrentPosition (m_parameters->m_bounds);
|
||||
m_helper.Reset (vector);
|
||||
Position next = m_parameters->m_bounds.CalculateIntersection (position, vector);
|
||||
Vector next = m_parameters->m_bounds.CalculateIntersection (position, vector);
|
||||
Time delay = Seconds (CalculateDistance (position, next) / speed);
|
||||
m_event = Simulator::Schedule (delay,
|
||||
&RandomDirection2dMobilityModel::BeginPause, this);
|
||||
@@ -169,7 +169,7 @@ RandomDirection2dMobilityModel::ResetDirectionAndSpeed (void)
|
||||
{
|
||||
double direction = UniformVariable::GetSingleValue (0, PI);
|
||||
|
||||
Position position = m_helper.GetCurrentPosition (m_parameters->m_bounds);
|
||||
Vector position = m_helper.GetCurrentPosition (m_parameters->m_bounds);
|
||||
switch (m_parameters->m_bounds.GetClosestSide (position))
|
||||
{
|
||||
case Rectangle::RIGHT:
|
||||
@@ -187,19 +187,19 @@ RandomDirection2dMobilityModel::ResetDirectionAndSpeed (void)
|
||||
}
|
||||
SetDirectionAndSpeed (direction);
|
||||
}
|
||||
Position
|
||||
Vector
|
||||
RandomDirection2dMobilityModel::DoGetPosition (void) const
|
||||
{
|
||||
return m_helper.GetCurrentPosition (m_parameters->m_bounds);
|
||||
}
|
||||
void
|
||||
RandomDirection2dMobilityModel::DoSetPosition (const Position &position)
|
||||
RandomDirection2dMobilityModel::DoSetPosition (const Vector &position)
|
||||
{
|
||||
m_helper.InitializePosition (position);
|
||||
Simulator::Remove (m_event);
|
||||
m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this);
|
||||
}
|
||||
Speed
|
||||
Vector
|
||||
RandomDirection2dMobilityModel::DoGetSpeed (void) const
|
||||
{
|
||||
return m_helper.GetSpeed ();
|
||||
|
||||
@@ -106,9 +106,9 @@ class RandomDirection2dMobilityModel : public MobilityModel
|
||||
void SetDirectionAndSpeed (double direction);
|
||||
void InitializeDirectionAndSpeed (void);
|
||||
virtual void DoDispose (void);
|
||||
virtual Position DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Position &position);
|
||||
virtual Speed DoGetSpeed (void) const;
|
||||
virtual Vector DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Vector &position);
|
||||
virtual Vector DoGetSpeed (void) const;
|
||||
|
||||
static const double PI;
|
||||
Ptr<RandomDirection2dMobilityModelParameters> m_parameters;
|
||||
|
||||
@@ -91,12 +91,12 @@ RandomRectanglePosition::~RandomRectanglePosition ()
|
||||
m_x = 0;
|
||||
m_y = 0;
|
||||
}
|
||||
Position
|
||||
Vector
|
||||
RandomRectanglePosition::Get (void) const
|
||||
{
|
||||
double x = m_x->GetValue ();
|
||||
double y = m_y->GetValue ();
|
||||
return Position (x, y, 0.0);
|
||||
return Vector (x, y, 0.0);
|
||||
}
|
||||
|
||||
RandomDiscPosition::RandomDiscPosition ()
|
||||
@@ -120,7 +120,7 @@ RandomDiscPosition::~RandomDiscPosition ()
|
||||
m_theta = 0;
|
||||
m_rho = 0;
|
||||
}
|
||||
Position
|
||||
Vector
|
||||
RandomDiscPosition::Get (void) const
|
||||
{
|
||||
double theta = m_theta->GetValue ();
|
||||
@@ -128,7 +128,7 @@ RandomDiscPosition::Get (void) const
|
||||
double x = m_x + std::cos (theta) * rho;
|
||||
double y = m_y + std::sin (theta) * rho;
|
||||
NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y);
|
||||
return Position (x, y, 0.0);
|
||||
return Vector (x, y, 0.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/component-manager.h"
|
||||
#include "position.h"
|
||||
#include "vector.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
/**
|
||||
* \returns the next randomly-choosen position.
|
||||
*/
|
||||
virtual Position Get (void) const = 0;
|
||||
virtual Vector Get (void) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
RandomRectanglePosition (const RandomVariable &x,
|
||||
const RandomVariable &y);
|
||||
virtual ~RandomRectanglePosition ();
|
||||
virtual Position Get (void) const;
|
||||
virtual Vector Get (void) const;
|
||||
private:
|
||||
RandomVariable *m_x;
|
||||
RandomVariable *m_y;
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
const RandomVariable &rho,
|
||||
double x, double y);
|
||||
virtual ~RandomDiscPosition ();
|
||||
virtual Position Get (void) const;
|
||||
virtual Vector Get (void) const;
|
||||
private:
|
||||
RandomVariable *m_theta;
|
||||
RandomVariable *m_rho;
|
||||
|
||||
@@ -70,7 +70,7 @@ RandomTopology::LayoutOne (Ptr<Object> object)
|
||||
Ptr<MobilityModel> mobility = ComponentManager::Create<MobilityModel> (m_mobilityModel,
|
||||
MobilityModel::iid);
|
||||
object->AddInterface (mobility);
|
||||
Position position = m_positionModel->Get ();
|
||||
Vector position = m_positionModel->Get ();
|
||||
mobility->SetPosition (position);
|
||||
}
|
||||
|
||||
|
||||
@@ -143,9 +143,9 @@ RandomWalk2dMobilityModel::Start (void)
|
||||
{
|
||||
double speed = m_parameters->m_speed->GetValue ();
|
||||
double direction = m_parameters->m_direction->GetValue ();
|
||||
Speed vector (std::cos (direction) * speed,
|
||||
std::sin (direction) * speed,
|
||||
0.0);
|
||||
Vector vector (std::cos (direction) * speed,
|
||||
std::sin (direction) * speed,
|
||||
0.0);
|
||||
m_helper.Reset (vector);
|
||||
|
||||
Time delayLeft;
|
||||
@@ -163,11 +163,11 @@ RandomWalk2dMobilityModel::Start (void)
|
||||
void
|
||||
RandomWalk2dMobilityModel::DoWalk (Time delayLeft)
|
||||
{
|
||||
Position position = m_helper.GetCurrentPosition ();
|
||||
Speed speed = m_helper.GetSpeed ();
|
||||
Position nextPosition = position;
|
||||
nextPosition.x += speed.dx * delayLeft.GetSeconds ();
|
||||
nextPosition.y += speed.dy * delayLeft.GetSeconds ();
|
||||
Vector position = m_helper.GetCurrentPosition ();
|
||||
Vector speed = m_helper.GetSpeed ();
|
||||
Vector nextPosition = position;
|
||||
nextPosition.x += speed.x * delayLeft.GetSeconds ();
|
||||
nextPosition.y += speed.y * delayLeft.GetSeconds ();
|
||||
if (m_parameters->m_bounds.IsInside (nextPosition))
|
||||
{
|
||||
m_event = Simulator::Schedule (delayLeft, &RandomWalk2dMobilityModel::Start, this);
|
||||
@@ -175,7 +175,7 @@ RandomWalk2dMobilityModel::DoWalk (Time delayLeft)
|
||||
else
|
||||
{
|
||||
nextPosition = m_parameters->m_bounds.CalculateIntersection (position, speed);
|
||||
Time delay = Seconds ((nextPosition.x - position.x) / speed.dx);
|
||||
Time delay = Seconds ((nextPosition.x - position.x) / speed.x);
|
||||
m_event = Simulator::Schedule (delay, &RandomWalk2dMobilityModel::Rebound, this,
|
||||
delayLeft - delay);
|
||||
}
|
||||
@@ -185,17 +185,17 @@ RandomWalk2dMobilityModel::DoWalk (Time delayLeft)
|
||||
void
|
||||
RandomWalk2dMobilityModel::Rebound (Time delayLeft)
|
||||
{
|
||||
Position position = m_helper.GetCurrentPosition (m_parameters->m_bounds);
|
||||
Speed speed = m_helper.GetSpeed ();
|
||||
Vector position = m_helper.GetCurrentPosition (m_parameters->m_bounds);
|
||||
Vector speed = m_helper.GetSpeed ();
|
||||
switch (m_parameters->m_bounds.GetClosestSide (position))
|
||||
{
|
||||
case Rectangle::RIGHT:
|
||||
case Rectangle::LEFT:
|
||||
speed.dx = - speed.dx;
|
||||
speed.x = - speed.x;
|
||||
break;
|
||||
case Rectangle::TOP:
|
||||
case Rectangle::BOTTOM:
|
||||
speed.dy = - speed.dy;
|
||||
speed.y = - speed.y;
|
||||
break;
|
||||
}
|
||||
m_helper.Reset (speed);
|
||||
@@ -209,20 +209,20 @@ RandomWalk2dMobilityModel::DoDispose (void)
|
||||
// chain up
|
||||
MobilityModel::DoDispose ();
|
||||
}
|
||||
Position
|
||||
Vector
|
||||
RandomWalk2dMobilityModel::DoGetPosition (void) const
|
||||
{
|
||||
return m_helper.GetCurrentPosition (m_parameters->m_bounds);
|
||||
}
|
||||
void
|
||||
RandomWalk2dMobilityModel::DoSetPosition (const Position &position)
|
||||
RandomWalk2dMobilityModel::DoSetPosition (const Vector &position)
|
||||
{
|
||||
NS_ASSERT (m_parameters->m_bounds.IsInside (position));
|
||||
m_helper.InitializePosition (position);
|
||||
Simulator::Remove (m_event);
|
||||
m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::Start, this);
|
||||
}
|
||||
Speed
|
||||
Vector
|
||||
RandomWalk2dMobilityModel::DoGetSpeed (void) const
|
||||
{
|
||||
return m_helper.GetSpeed ();
|
||||
|
||||
@@ -132,9 +132,9 @@ class RandomWalk2dMobilityModel : public MobilityModel
|
||||
void Rebound (Time timeLeft);
|
||||
void DoWalk (Time timeLeft);
|
||||
virtual void DoDispose (void);
|
||||
virtual Position DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Position &position);
|
||||
virtual Speed DoGetSpeed (void) const;
|
||||
virtual Vector DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Vector &position);
|
||||
virtual Vector DoGetSpeed (void) const;
|
||||
|
||||
StaticSpeedHelper m_helper;
|
||||
EventId m_event;
|
||||
|
||||
@@ -117,15 +117,15 @@ RandomWaypointMobilityModel::RandomWaypointMobilityModel (Ptr<RandomWaypointMobi
|
||||
void
|
||||
RandomWaypointMobilityModel::BeginWalk (void)
|
||||
{
|
||||
Position m_current = m_helper.GetCurrentPosition ();
|
||||
Position destination = m_parameters->m_position->Get ();
|
||||
Vector m_current = m_helper.GetCurrentPosition ();
|
||||
Vector destination = m_parameters->m_position->Get ();
|
||||
double speed = m_parameters->m_speed->GetValue ();
|
||||
double dx = (destination.x - m_current.x);
|
||||
double dy = (destination.y - m_current.y);
|
||||
double dz = (destination.z - m_current.z);
|
||||
double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
|
||||
|
||||
m_helper.Reset (Speed (k*dx, k*dy, k*dz));
|
||||
m_helper.Reset (Vector (k*dx, k*dy, k*dz));
|
||||
Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed);
|
||||
m_event = Simulator::Schedule (travelDelay,
|
||||
&RandomWaypointMobilityModel::Start, this);
|
||||
@@ -141,19 +141,19 @@ RandomWaypointMobilityModel::Start (void)
|
||||
m_event = Simulator::Schedule (pause, &RandomWaypointMobilityModel::BeginWalk, this);
|
||||
}
|
||||
|
||||
Position
|
||||
Vector
|
||||
RandomWaypointMobilityModel::DoGetPosition (void) const
|
||||
{
|
||||
return m_helper.GetCurrentPosition ();
|
||||
}
|
||||
void
|
||||
RandomWaypointMobilityModel::DoSetPosition (const Position &position)
|
||||
RandomWaypointMobilityModel::DoSetPosition (const Vector &position)
|
||||
{
|
||||
m_helper.InitializePosition (position);
|
||||
Simulator::Remove (m_event);
|
||||
Simulator::ScheduleNow (&RandomWaypointMobilityModel::Start, this);
|
||||
}
|
||||
Speed
|
||||
Vector
|
||||
RandomWaypointMobilityModel::DoGetSpeed (void) const
|
||||
{
|
||||
return m_helper.GetSpeed ();
|
||||
|
||||
@@ -98,9 +98,9 @@ public:
|
||||
private:
|
||||
void Start (void);
|
||||
void BeginWalk (void);
|
||||
virtual Position DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Position &position);
|
||||
virtual Speed DoGetSpeed (void) const;
|
||||
virtual Vector DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Vector &position);
|
||||
virtual Vector DoGetSpeed (void) const;
|
||||
|
||||
StaticSpeedHelper m_helper;
|
||||
Ptr<RandomWaypointMobilityModelParameters> m_parameters;
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "rectangle.h"
|
||||
#include "position.h"
|
||||
#include "speed.h"
|
||||
#include "vector.h"
|
||||
#include "ns3/assert.h"
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
@@ -42,7 +41,7 @@ Rectangle::Rectangle ()
|
||||
{}
|
||||
|
||||
bool
|
||||
Rectangle::IsInside (const Position &position) const
|
||||
Rectangle::IsInside (const Vector &position) const
|
||||
{
|
||||
return
|
||||
position.x <= this->xMax && position.x >= this->xMin &&
|
||||
@@ -50,7 +49,7 @@ Rectangle::IsInside (const Position &position) const
|
||||
}
|
||||
|
||||
Rectangle::Side
|
||||
Rectangle::GetClosestSide (const Position &position) const
|
||||
Rectangle::GetClosestSide (const Vector &position) const
|
||||
{
|
||||
double xMinDist = std::abs (position.x - this->xMin);
|
||||
double xMaxDist = std::abs (this->xMax - position.x);
|
||||
@@ -82,38 +81,38 @@ Rectangle::GetClosestSide (const Position &position) const
|
||||
}
|
||||
}
|
||||
|
||||
Position
|
||||
Rectangle::CalculateIntersection (const Position ¤t, const Speed &speed) const
|
||||
Vector
|
||||
Rectangle::CalculateIntersection (const Vector ¤t, const Vector &speed) const
|
||||
{
|
||||
double xMaxY = current.y + (this->xMax - current.x) / speed.dx * speed.dy;
|
||||
double xMinY = current.y + (this->xMin - current.x) / speed.dx * speed.dy;
|
||||
double yMaxX = current.x + (this->yMax - current.y) / speed.dy * speed.dx;
|
||||
double yMinX = current.x + (this->yMin - current.y) / speed.dy * speed.dx;
|
||||
double xMaxY = current.y + (this->xMax - current.x) / speed.x * speed.y;
|
||||
double xMinY = current.y + (this->xMin - current.x) / speed.x * speed.y;
|
||||
double yMaxX = current.x + (this->yMax - current.y) / speed.y * speed.x;
|
||||
double yMinX = current.x + (this->yMin - current.y) / speed.y * speed.x;
|
||||
bool xMaxYOk = (xMaxY <= this->yMax && xMaxY >= this->yMin);
|
||||
bool xMinYOk = (xMinY <= this->yMax && xMinY >= this->yMin);
|
||||
bool yMaxXOk = (yMaxX <= this->xMax && yMaxX >= this->xMin);
|
||||
bool yMinXOk = (yMinX <= this->xMax && yMinX >= this->xMin);
|
||||
if (xMaxYOk && speed.dx >= 0)
|
||||
if (xMaxYOk && speed.x >= 0)
|
||||
{
|
||||
return Position (this->xMax, xMaxY, 0.0);
|
||||
return Vector (this->xMax, xMaxY, 0.0);
|
||||
}
|
||||
else if (xMinYOk && speed.dx <= 0)
|
||||
else if (xMinYOk && speed.x <= 0)
|
||||
{
|
||||
return Position (this->xMin, xMinY, 0.0);
|
||||
return Vector (this->xMin, xMinY, 0.0);
|
||||
}
|
||||
else if (yMaxXOk && speed.dy >= 0)
|
||||
else if (yMaxXOk && speed.y >= 0)
|
||||
{
|
||||
return Position (yMaxX, this->yMax, 0.0);
|
||||
return Vector (yMaxX, this->yMax, 0.0);
|
||||
}
|
||||
else if (yMinXOk && speed.dy <= 0)
|
||||
else if (yMinXOk && speed.y <= 0)
|
||||
{
|
||||
return Position (yMinX, this->yMin, 0.0);
|
||||
return Vector (yMinX, this->yMin, 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ASSERT (false);
|
||||
// quiet compiler
|
||||
return Position (0.0, 0.0, 0.0);
|
||||
return Vector (0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Position;
|
||||
class Speed;
|
||||
class Vector;
|
||||
|
||||
/**
|
||||
* \brief a 2d rectangle
|
||||
@@ -51,9 +50,9 @@ public:
|
||||
* Create a zero-sized rectangle located at coordinates (0.0,0.0)
|
||||
*/
|
||||
Rectangle ();
|
||||
bool IsInside (const Position &position) const;
|
||||
Side GetClosestSide (const Position &position) const;
|
||||
Position CalculateIntersection (const Position ¤t, const Speed &speed) const;
|
||||
bool IsInside (const Vector &position) const;
|
||||
Side GetClosestSide (const Vector &position) const;
|
||||
Vector CalculateIntersection (const Vector ¤t, const Vector &speed) const;
|
||||
|
||||
double xMin;
|
||||
double xMax;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "speed.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Speed::Speed (double _dx, double _dy, double _dz)
|
||||
: dx (_dx),
|
||||
dy (_dy),
|
||||
dz (_dz)
|
||||
{}
|
||||
|
||||
Speed::Speed ()
|
||||
: dx (0.0),
|
||||
dy (0.0),
|
||||
dz (0.0)
|
||||
{}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,61 +0,0 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef SPEED_H
|
||||
#define SPEED_H
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \brief keep track of 3d cartesian speed vectors
|
||||
*
|
||||
* Unit is meters/s.
|
||||
*/
|
||||
class Speed
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \param _dx x coordinate of speed vector
|
||||
* \param _dy y coordinate of speed vector
|
||||
* \param _dz z coordinate of speed vector
|
||||
*
|
||||
* Create speed vector (_dx, _dy, _dz)
|
||||
*/
|
||||
Speed (double _dx, double _dy, double _dz);
|
||||
/**
|
||||
* Create speed vector (0.0, 0.0, 0.0)
|
||||
*/
|
||||
Speed ();
|
||||
/**
|
||||
* x coordinate of speed vector
|
||||
*/
|
||||
double dx;
|
||||
/**
|
||||
* y coordinate of speed vector
|
||||
*/
|
||||
double dy;
|
||||
/**
|
||||
* z coordinate of speed vector
|
||||
*/
|
||||
double dz;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* SPEED_H */
|
||||
@@ -28,7 +28,7 @@ StaticMobilityModel::StaticMobilityModel ()
|
||||
{
|
||||
SetInterfaceId (StaticMobilityModel::iid);
|
||||
}
|
||||
StaticMobilityModel::StaticMobilityModel (const Position &position)
|
||||
StaticMobilityModel::StaticMobilityModel (const Vector &position)
|
||||
: m_position (position)
|
||||
{
|
||||
SetInterfaceId (StaticMobilityModel::iid);
|
||||
@@ -36,21 +36,21 @@ StaticMobilityModel::StaticMobilityModel (const Position &position)
|
||||
StaticMobilityModel::~StaticMobilityModel ()
|
||||
{}
|
||||
|
||||
Position
|
||||
Vector
|
||||
StaticMobilityModel::DoGetPosition (void) const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
void
|
||||
StaticMobilityModel::DoSetPosition (const Position &position)
|
||||
StaticMobilityModel::DoSetPosition (const Vector &position)
|
||||
{
|
||||
m_position = position;
|
||||
NotifyCourseChange ();
|
||||
}
|
||||
Speed
|
||||
Vector
|
||||
StaticMobilityModel::DoGetSpeed (void) const
|
||||
{
|
||||
return Speed ();
|
||||
return Vector (0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
@@ -44,15 +44,15 @@ public:
|
||||
* Create a position located at coordinates (x,y,z).
|
||||
* Unit is meters
|
||||
*/
|
||||
StaticMobilityModel (const Position &position);
|
||||
StaticMobilityModel (const Vector &position);
|
||||
virtual ~StaticMobilityModel ();
|
||||
|
||||
private:
|
||||
virtual Position DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Position &position);
|
||||
virtual Speed DoGetSpeed (void) const;
|
||||
virtual Vector DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Vector &position);
|
||||
virtual Vector DoGetSpeed (void) const;
|
||||
|
||||
Position m_position;
|
||||
Vector m_position;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
@@ -25,40 +25,40 @@ namespace ns3 {
|
||||
|
||||
StaticSpeedHelper::StaticSpeedHelper ()
|
||||
{}
|
||||
StaticSpeedHelper::StaticSpeedHelper (const Position &position)
|
||||
StaticSpeedHelper::StaticSpeedHelper (const Vector &position)
|
||||
: m_position (position)
|
||||
{}
|
||||
StaticSpeedHelper::StaticSpeedHelper (const Position &position,
|
||||
const Speed &speed)
|
||||
StaticSpeedHelper::StaticSpeedHelper (const Vector &position,
|
||||
const Vector &speed)
|
||||
: m_position (position),
|
||||
m_speed (speed),
|
||||
m_paused (true)
|
||||
{}
|
||||
void
|
||||
StaticSpeedHelper::InitializePosition (const Position &position)
|
||||
StaticSpeedHelper::InitializePosition (const Vector &position)
|
||||
{
|
||||
m_position = position;
|
||||
m_speed.dx = 0.0;
|
||||
m_speed.dy = 0.0;
|
||||
m_speed.dz = 0.0;
|
||||
m_speed.x = 0.0;
|
||||
m_speed.y = 0.0;
|
||||
m_speed.z = 0.0;
|
||||
m_lastUpdate = Simulator::Now ();
|
||||
m_paused = true;
|
||||
}
|
||||
|
||||
Position
|
||||
Vector
|
||||
StaticSpeedHelper::GetCurrentPosition (void) const
|
||||
{
|
||||
Update ();
|
||||
return m_position;
|
||||
}
|
||||
|
||||
Speed
|
||||
Vector
|
||||
StaticSpeedHelper::GetSpeed (void) const
|
||||
{
|
||||
return m_paused? Speed (0, 0, 0) : m_speed;
|
||||
return m_paused? Vector (0.0, 0.0, 0.0) : m_speed;
|
||||
}
|
||||
void
|
||||
StaticSpeedHelper::SetSpeed (const Speed &speed)
|
||||
StaticSpeedHelper::SetSpeed (const Vector &speed)
|
||||
{
|
||||
Update ();
|
||||
m_speed = speed;
|
||||
@@ -76,13 +76,13 @@ StaticSpeedHelper::Update (void) const
|
||||
Time deltaTime = now - m_lastUpdate;
|
||||
m_lastUpdate = now;
|
||||
double deltaS = deltaTime.GetSeconds ();
|
||||
m_position.x += m_speed.dx * deltaS;
|
||||
m_position.y += m_speed.dy * deltaS;
|
||||
m_position.z += m_speed.dz * deltaS;
|
||||
m_position.x += m_speed.x * deltaS;
|
||||
m_position.y += m_speed.y * deltaS;
|
||||
m_position.z += m_speed.z * deltaS;
|
||||
}
|
||||
|
||||
void
|
||||
StaticSpeedHelper::Reset (const Speed &speed)
|
||||
StaticSpeedHelper::Reset (const Vector &speed)
|
||||
{
|
||||
Update ();
|
||||
m_speed = speed;
|
||||
@@ -98,7 +98,7 @@ StaticSpeedHelper::UpdateFull (const Rectangle &bounds) const
|
||||
m_position.y = std::max (bounds.yMin, m_position.y);
|
||||
}
|
||||
|
||||
Position
|
||||
Vector
|
||||
StaticSpeedHelper::GetCurrentPosition (const Rectangle &bounds) const
|
||||
{
|
||||
UpdateFull (bounds);
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
#define STATIC_SPEED_HELPER_H
|
||||
|
||||
#include "ns3/nstime.h"
|
||||
#include "position.h"
|
||||
#include "speed.h"
|
||||
#include "vector.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -32,16 +31,16 @@ class StaticSpeedHelper
|
||||
{
|
||||
public:
|
||||
StaticSpeedHelper ();
|
||||
StaticSpeedHelper (const Position &position);
|
||||
StaticSpeedHelper (const Position &position,
|
||||
const Speed &speed);
|
||||
void InitializePosition (const Position &position);
|
||||
StaticSpeedHelper (const Vector &position);
|
||||
StaticSpeedHelper (const Vector &position,
|
||||
const Vector &speed);
|
||||
void InitializePosition (const Vector &position);
|
||||
|
||||
void Reset (const Speed &speed);
|
||||
Position GetCurrentPosition (const Rectangle &bounds) const;
|
||||
Position GetCurrentPosition (void) const;
|
||||
Speed GetSpeed (void) const;
|
||||
void SetSpeed (const Speed &speed);
|
||||
void Reset (const Vector &speed);
|
||||
Vector GetCurrentPosition (const Rectangle &bounds) const;
|
||||
Vector GetCurrentPosition (void) const;
|
||||
Vector GetSpeed (void) const;
|
||||
void SetSpeed (const Vector &speed);
|
||||
void Pause (void);
|
||||
void Unpause (void);
|
||||
|
||||
@@ -49,8 +48,8 @@ class StaticSpeedHelper
|
||||
void Update (void) const;
|
||||
void UpdateFull (const Rectangle &rectangle) const;
|
||||
mutable Time m_lastUpdate;
|
||||
mutable Position m_position;
|
||||
Speed m_speed;
|
||||
mutable Vector m_position;
|
||||
Vector m_speed;
|
||||
bool m_paused;
|
||||
};
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ StaticSpeedMobilityModel::StaticSpeedMobilityModel ()
|
||||
{
|
||||
SetInterfaceId (StaticSpeedMobilityModel::iid);
|
||||
}
|
||||
StaticSpeedMobilityModel::StaticSpeedMobilityModel (const Position &position)
|
||||
StaticSpeedMobilityModel::StaticSpeedMobilityModel (const Vector &position)
|
||||
: m_helper (position)
|
||||
{
|
||||
SetInterfaceId (StaticSpeedMobilityModel::iid);
|
||||
}
|
||||
StaticSpeedMobilityModel::StaticSpeedMobilityModel (const Position &position,
|
||||
const Speed &speed)
|
||||
StaticSpeedMobilityModel::StaticSpeedMobilityModel (const Vector &position,
|
||||
const Vector &speed)
|
||||
: m_helper (position, speed)
|
||||
{
|
||||
SetInterfaceId (StaticSpeedMobilityModel::iid);
|
||||
@@ -49,25 +49,25 @@ StaticSpeedMobilityModel::~StaticSpeedMobilityModel ()
|
||||
{}
|
||||
|
||||
void
|
||||
StaticSpeedMobilityModel::SetSpeed (const Speed speed)
|
||||
StaticSpeedMobilityModel::SetSpeed (const Vector &speed)
|
||||
{
|
||||
m_helper.SetSpeed (speed);
|
||||
NotifyCourseChange ();
|
||||
}
|
||||
|
||||
|
||||
Position
|
||||
Vector
|
||||
StaticSpeedMobilityModel::DoGetPosition (void) const
|
||||
{
|
||||
return m_helper.GetCurrentPosition ();
|
||||
}
|
||||
void
|
||||
StaticSpeedMobilityModel::DoSetPosition (const Position &position)
|
||||
StaticSpeedMobilityModel::DoSetPosition (const Vector &position)
|
||||
{
|
||||
m_helper.InitializePosition (position);
|
||||
NotifyCourseChange ();
|
||||
}
|
||||
Speed
|
||||
Vector
|
||||
StaticSpeedMobilityModel::DoGetSpeed (void) const
|
||||
{
|
||||
return m_helper.GetSpeed ();
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "ns3/nstime.h"
|
||||
#include "ns3/component-manager.h"
|
||||
#include "static-speed-helper.h"
|
||||
#include "speed.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -48,15 +47,15 @@ public:
|
||||
* Create a position located at coordinates (x,y,z) with
|
||||
* speed (0,0,0).
|
||||
*/
|
||||
StaticSpeedMobilityModel (const Position &position);
|
||||
StaticSpeedMobilityModel (const Vector &position);
|
||||
/**
|
||||
*
|
||||
* Create a position located at coordinates (x,y,z) with
|
||||
* speed (dx,dy,dz).
|
||||
* Unit is meters and meters/s
|
||||
*/
|
||||
StaticSpeedMobilityModel (const Position &position,
|
||||
const Speed &speed);
|
||||
StaticSpeedMobilityModel (const Vector &position,
|
||||
const Vector &speed);
|
||||
virtual ~StaticSpeedMobilityModel ();
|
||||
|
||||
/**
|
||||
@@ -65,11 +64,11 @@ public:
|
||||
* Set the current speed now to (dx,dy,dz)
|
||||
* Unit is meters/s
|
||||
*/
|
||||
void SetSpeed (const Speed speed);
|
||||
void SetSpeed (const Vector &speed);
|
||||
private:
|
||||
virtual Position DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Position &position);
|
||||
virtual Speed DoGetSpeed (void) const;
|
||||
virtual Vector DoGetPosition (void) const;
|
||||
virtual void DoSetPosition (const Vector &position);
|
||||
virtual Vector DoGetSpeed (void) const;
|
||||
void Update (void) const;
|
||||
StaticSpeedHelper m_helper;
|
||||
};
|
||||
|
||||
@@ -8,12 +8,10 @@ def build(bld):
|
||||
'hierarchical-mobility-model.cc',
|
||||
'mobility-model.cc',
|
||||
'mobility-model-notifier.cc',
|
||||
'position.cc',
|
||||
'random-position.cc',
|
||||
'random-topology.cc',
|
||||
'rectangle.cc',
|
||||
'rectangle-default-value.cc',
|
||||
'speed.cc',
|
||||
'static-mobility-model.cc',
|
||||
'static-speed-helper.cc',
|
||||
'static-speed-mobility-model.cc',
|
||||
@@ -30,12 +28,10 @@ def build(bld):
|
||||
'hierarchical-mobility-model.h',
|
||||
'mobility-model.h',
|
||||
'mobility-model-notifier.h',
|
||||
'position.h',
|
||||
'random-position.h',
|
||||
'random-topology.h',
|
||||
'rectangle.h',
|
||||
'rectangle-default-value.h',
|
||||
'speed.h',
|
||||
'static-mobility-model.h',
|
||||
'static-speed-helper.h',
|
||||
'static-speed-mobility-model.h',
|
||||
|
||||
@@ -48,15 +48,15 @@ Sample ()
|
||||
{
|
||||
Ptr<Node> node = *nodeIter;
|
||||
Ptr<MobilityModel> mobility = node->QueryInterface<MobilityModel> (MobilityModel::iid);
|
||||
Position pos = mobility->GetPosition ();
|
||||
Speed vel = mobility->GetSpeed ();
|
||||
Vector pos = mobility->GetPosition ();
|
||||
Vector vel = mobility->GetSpeed ();
|
||||
|
||||
NodeUpdate update;
|
||||
update.node = PeekPointer<Node> (node);
|
||||
update.x = pos.x;
|
||||
update.y = pos.y;
|
||||
update.vx = vel.dx;
|
||||
update.vy = vel.dy;
|
||||
update.vx = vel.x;
|
||||
update.vy = vel.y;
|
||||
data->updateList.push_back (update);
|
||||
}
|
||||
data->time = Simulator::Now ().GetSeconds ();
|
||||
|
||||
Reference in New Issue
Block a user