src/mobility/random-direction-2d-mobility-model.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 21 Feb 2008 00:00:18 +0100
changeset 2440 baffd08c6898
parent 2435 3128175f5866
child 2458 e8f7c4960576
permissions -rw-r--r--
EnumValue -> Value
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
 * All rights reserved.
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * 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
     7
 * 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
     8
 * published by the Free Software Foundation;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * 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
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 * GNU General Public License for more details.
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * 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
    16
 * along with this program; if not, write to the Free Software
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 * 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
    18
 *
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
 */
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include "ns3/random-variable-default-value.h"
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "ns3/simulator.h"
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include <algorithm>
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include <cmath>
1625
0579a50b2c62 random-direction -> random-direction-2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1624
diff changeset
    25
#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
    26
#include "ns3/log.h"
99949986bb92 Add a bit of function name logging.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1637
diff changeset
    27
99949986bb92 Add a bit of function name logging.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1637
diff changeset
    28
NS_LOG_COMPONENT_DEFINE ("RandomDirection2dMobilityModel");
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
namespace ns3 {
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
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
    32
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
    33
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    34
NS_OBJECT_ENSURE_REGISTERED (RandomDirection2dMobilityModel);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2249
diff changeset
    37
TypeId
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
    38
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
    39
{
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    40
  static TypeId tid = TypeId ("RandomDirection2dMobilityModel")
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    41
    .SetParent<MobilityModel> ()
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
    42
    .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
    43
    .AddConstructor<RandomDirection2dMobilityModel> ()
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
    44
    .AddParameter ("bounds", "The 2d bounding area",
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    45
                   Rectangle (-100, 100, -100, 100),
2435
3128175f5866 ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    46
                   MakeRectangleAccessor (&RandomDirection2dMobilityModel::m_bounds),
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    47
                   MakeRectangleChecker ())
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
    48
    .AddParameter ("speed", "A random variable to control the speed (m/s).",
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    49
                   UniformVariable (1.0, 2.0),
2435
3128175f5866 ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    50
                   MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_speed),
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    51
                   MakeRandomVariableChecker ())
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
    52
    .AddParameter ("pause", "A random variable to control the pause (s).",
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    53
                   ConstantVariable (2.0),
2435
3128175f5866 ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    54
                   MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_pause),
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    55
                   MakeRandomVariableChecker ())
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    56
    ;
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    57
  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
    58
}
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    59
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
RandomDirection2dMobilityModel::RandomDirection2dMobilityModel ()
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
{
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
    63
  m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
}
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
void 
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
    66
RandomDirection2dMobilityModel::DoDispose (void)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
{
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  // chain up.
1579
a4187ed1e45e Position -> MobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1575
diff changeset
    69
  MobilityModel::DoDispose ();
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
}
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
void
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
    72
RandomDirection2dMobilityModel::Start (void)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
{
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
  double direction = UniformVariable::GetSingleValue (0, 2 * PI);
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
  SetDirectionAndSpeed (direction);
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
}
1661
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    77
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    78
void
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    79
RandomDirection2dMobilityModel::BeginPause (void)
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    80
{
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
    81
  Time pause = Seconds (m_pause.GetValue ());
1661
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    82
  m_helper.Pause ();
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    83
  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
    84
  NotifyCourseChange ();
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    85
}
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
    86
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
void
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
    88
RandomDirection2dMobilityModel::SetDirectionAndSpeed (double direction)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
{
1656
99949986bb92 Add a bit of function name logging.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1637
diff changeset
    90
  NS_LOG_FUNCTION;
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
    91
  double speed = m_speed.GetValue ();
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
    92
  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
    93
                       std::sin (direction) * speed,
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
    94
                       0.0);
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
    95
  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
    96
  m_helper.Reset (vector);
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
    97
  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
    98
  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
    99
  m_event = Simulator::Schedule (delay,
7583786bd063 Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1658
diff changeset
   100
				 &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
   101
  NotifyCourseChange ();
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
}
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
void
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
   104
RandomDirection2dMobilityModel::ResetDirectionAndSpeed (void)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
{
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
  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
   107
  
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
   108
  Vector position = m_helper.GetCurrentPosition (m_bounds);
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
   109
  switch (m_bounds.GetClosestSide (position))
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
    {
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
   111
    case Rectangle::RIGHT:
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
      direction += PI / 2;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
      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
   114
    case Rectangle::LEFT:
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
      direction += - PI / 2;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
      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
   117
    case Rectangle::TOP:
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
      direction += PI;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
      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
   120
    case Rectangle::BOTTOM:
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
      direction += 0.0;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
      break;
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
    }
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
  SetDirectionAndSpeed (direction);
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
}
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
   126
Vector
1816
d7c9b9da78f4 rename MobilityModel::Get/Set to GetPosition/SetPosition
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1661
diff changeset
   127
RandomDirection2dMobilityModel::DoGetPosition (void) const
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
{
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2383
diff changeset
   129
  return m_helper.GetCurrentPosition (m_bounds);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
}
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
void
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
   132
RandomDirection2dMobilityModel::DoSetPosition (const Vector &position)
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
{
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
   134
  m_helper.InitializePosition (position);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
  Simulator::Remove (m_event);
1626
feaecfd93b5d RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1625
diff changeset
   136
  m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this);
1575
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
}
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
   138
Vector
1818
fbdc8361dc77 GetSpeed -> GetVelocity
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1817
diff changeset
   139
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
   140
{
1818
fbdc8361dc77 GetSpeed -> GetVelocity
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1817
diff changeset
   141
  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
   142
}
1575
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
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   145
cbc37ce4b91d RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
} // namespace ns3