src/mobility/random-direction-2d-mobility-model.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 17 Apr 2008 13:42:25 -0700
changeset 2965 4b28e9740e3b
parent 2834 1aab57845b07
child 2989 b7eb3929096c
permissions -rw-r--r--
get rid of Attribute class. Use AttributeValue subclasses directly.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2007 INRIA
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#include "ns3/simulator.h"
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include <algorithm>
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include <cmath>
1625
0579a50b2c62 random-direction -> random-direction-2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1624
diff changeset
    23
#include "random-direction-2d-mobility-model.h"
1656
99949986bb92 Add a bit of function name logging.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1637
diff changeset
    24
#include "ns3/log.h"
99949986bb92 Add a bit of function name logging.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1637
diff changeset
    25
99949986bb92 Add a bit of function name logging.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1637
diff changeset
    26
NS_LOG_COMPONENT_DEFINE ("RandomDirection2dMobilityModel");
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
namespace ns3 {
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
1658
52f6bf2a7caa Improve the precision of the RandomDirection2dMobilityModel::PI constant (value copied from glibc's math.h header file).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1656
diff changeset
    30
const double RandomDirection2dMobilityModel::PI = 3.14159265358979323846;
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    31
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    32
NS_OBJECT_ENSURE_REGISTERED (RandomDirection2dMobilityModel);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2249
diff changeset
    35
TypeId
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
    36
RandomDirection2dMobilityModel::GetTypeId (void)
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    37
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2553
diff changeset
    38
  static TypeId tid = TypeId ("ns3::RandomDirection2dMobilityModel")
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    39
    .SetParent<MobilityModel> ()
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
    40
    .SetGroupName ("Mobility")
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    41
    .AddConstructor<RandomDirection2dMobilityModel> ()
2543
401bfe8c0176 kill old code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
    42
    .AddAttribute ("Bounds", "The 2d bounding area",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
    43
                   RectangleValue (Rectangle (-100, 100, -100, 100)),
2435
3128175f5866 ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    44
                   MakeRectangleAccessor (&RandomDirection2dMobilityModel::m_bounds),
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    45
                   MakeRectangleChecker ())
2543
401bfe8c0176 kill old code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
    46
    .AddAttribute ("Speed", "A random variable to control the speed (m/s).",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
    47
                   RandomVariableValue (UniformVariable (1.0, 2.0)),
2435
3128175f5866 ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    48
                   MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_speed),
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    49
                   MakeRandomVariableChecker ())
2543
401bfe8c0176 kill old code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
    50
    .AddAttribute ("Pause", "A random variable to control the pause (s).",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
    51
                   RandomVariableValue (ConstantVariable (2.0)),
2435
3128175f5866 ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    52
                   MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_pause),
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    53
                   MakeRandomVariableChecker ())
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    54
    ;
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    55
  return tid;
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    56
}
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    57
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
    59
RandomDirection2dMobilityModel::RandomDirection2dMobilityModel ()
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
{
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
    61
  m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
}
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
void 
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
    64
RandomDirection2dMobilityModel::DoDispose (void)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
{
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
  // chain up.
1579
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1575
diff changeset
    67
  MobilityModel::DoDispose ();
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
}
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
void
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
    70
RandomDirection2dMobilityModel::Start (void)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
{
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
  double direction = UniformVariable::GetSingleValue (0, 2 * PI);
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
  SetDirectionAndSpeed (direction);
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
}
1661
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    75
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    76
void
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    77
RandomDirection2dMobilityModel::BeginPause (void)
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    78
{
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
    79
  Time pause = Seconds (m_pause.GetValue ());
1661
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    80
  m_helper.Pause ();
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    81
  m_event = Simulator::Schedule (pause, &RandomDirection2dMobilityModel::ResetDirectionAndSpeed, this);
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    82
  NotifyCourseChange ();
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    83
}
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    84
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
void
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
    86
RandomDirection2dMobilityModel::SetDirectionAndSpeed (double direction)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
{
1656
99949986bb92 Add a bit of function name logging.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1637
diff changeset
    88
  NS_LOG_FUNCTION;
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
    89
  double speed = m_speed.GetValue ();
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
    90
  const Vector vector (std::cos (direction) * speed,
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
    91
                       std::sin (direction) * speed,
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
    92
                       0.0);
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
    93
  Vector position = m_helper.GetCurrentPosition (m_bounds);
1661
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    94
  m_helper.Reset (vector);
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
    95
  Vector next = m_bounds.CalculateIntersection (position, vector);
1620
69baa7b1c487 remove mobility model helper, re-enable random direction model with new helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1591
diff changeset
    96
  Time delay = Seconds (CalculateDistance (position, next) / speed);
1661
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    97
  m_event = Simulator::Schedule (delay,
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    98
				 &RandomDirection2dMobilityModel::BeginPause, this);
1620
69baa7b1c487 remove mobility model helper, re-enable random direction model with new helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1591
diff changeset
    99
  NotifyCourseChange ();
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
}
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
void
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
   102
RandomDirection2dMobilityModel::ResetDirectionAndSpeed (void)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
{
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
  double direction = UniformVariable::GetSingleValue (0, PI);
1591
4a1f822fe9aa split useful code out of random direction mobility model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1584
diff changeset
   105
  
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
   106
  Vector position = m_helper.GetCurrentPosition (m_bounds);
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
   107
  switch (m_bounds.GetClosestSide (position))
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
    {
1620
69baa7b1c487 remove mobility model helper, re-enable random direction model with new helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1591
diff changeset
   109
    case Rectangle::RIGHT:
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
      direction += PI / 2;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
      break;
1620
69baa7b1c487 remove mobility model helper, re-enable random direction model with new helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1591
diff changeset
   112
    case Rectangle::LEFT:
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
      direction += - PI / 2;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
      break;
1620
69baa7b1c487 remove mobility model helper, re-enable random direction model with new helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1591
diff changeset
   115
    case Rectangle::TOP:
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
      direction += PI;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
      break;
1620
69baa7b1c487 remove mobility model helper, re-enable random direction model with new helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1591
diff changeset
   118
    case Rectangle::BOTTOM:
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
      direction += 0.0;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
      break;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
    }
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
  SetDirectionAndSpeed (direction);
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
}
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
   124
Vector
1816
d7c9b9da78f4 rename MobilityModel::Get/Set to GetPosition/SetPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1661
diff changeset
   125
RandomDirection2dMobilityModel::DoGetPosition (void) const
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
{
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
   127
  return m_helper.GetCurrentPosition (m_bounds);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
}
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
void
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
   130
RandomDirection2dMobilityModel::DoSetPosition (const Vector &position)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
{
1620
69baa7b1c487 remove mobility model helper, re-enable random direction model with new helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1591
diff changeset
   132
  m_helper.InitializePosition (position);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
  Simulator::Remove (m_event);
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
   134
  m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
}
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
   136
Vector
1818
fbdc8361dc77 GetSpeed -> GetVelocity
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1817
diff changeset
   137
RandomDirection2dMobilityModel::DoGetVelocity (void) const
1624
6e7d48a8c120 add MobilityModel::GetSpeed method and implement it in all mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1620
diff changeset
   138
{
1818
fbdc8361dc77 GetSpeed -> GetVelocity
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1817
diff changeset
   139
  return m_helper.GetVelocity ();
1624
6e7d48a8c120 add MobilityModel::GetSpeed method and implement it in all mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1620
diff changeset
   140
}
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   143
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
} // namespace ns3