--- a/src/node/random-walk-2d-mobility-model.cc Thu Jul 19 09:54:57 2007 +0200
+++ b/src/node/random-walk-2d-mobility-model.cc Thu Jul 19 10:01:42 2007 +0200
@@ -133,18 +133,22 @@
void
RandomWalk2dMobilityModel::DoWalk (Time delayLeft)
{
- Time delay = m_helper.GetDelayToNextPosition (m_parameters->m_bounds,
- delayLeft);
- if (delay < 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 ();
+ if (m_parameters->m_bounds.IsInside (nextPosition))
{
- m_event = Simulator::Schedule (delay, &RandomWalk2dMobilityModel::Rebound, this,
- delayLeft - delay);
+ m_event = Simulator::Schedule (delayLeft, &RandomWalk2dMobilityModel::Start, this);
}
else
{
- NS_ASSERT (delay == delayLeft);
- m_event = Simulator::Schedule (delay, &RandomWalk2dMobilityModel::Start, this);
- }
+ nextPosition = m_parameters->m_bounds.CalculateIntersection (position, speed);
+ Time delay = Seconds ((nextPosition.x - position.x) / speed.dx);
+ m_event = Simulator::Schedule (delay, &RandomWalk2dMobilityModel::Rebound, this,
+ delayLeft - delay);
+ }
NotifyCourseChange ();
}
--- a/src/node/static-speed-helper.cc Thu Jul 19 09:54:57 2007 +0200
+++ b/src/node/static-speed-helper.cc Thu Jul 19 10:01:42 2007 +0200
@@ -64,23 +64,6 @@
m_speed = speed;
m_pauseEnd = Simulator::Now ();
}
-Time
-StaticSpeedHelper::GetDelayToNextPosition (const Rectangle &bounds, Time delayLeft)
-{
- UpdateFull (bounds);
- Position nextPosition = m_position;
- nextPosition.x += m_speed.dx * delayLeft.GetSeconds ();
- nextPosition.y += m_speed.dy * delayLeft.GetSeconds ();
- if (bounds.IsInside (nextPosition))
- {
- return delayLeft;
- }
-
- nextPosition = bounds.CalculateIntersection (m_position, m_speed);
- Time delay = Seconds ((nextPosition.x - m_position.x) / m_speed.dx);
- return delay;
-}
-
void
StaticSpeedHelper::UpdateFull (const Rectangle &bounds) const
{
--- a/src/node/static-speed-helper.h Thu Jul 19 09:54:57 2007 +0200
+++ b/src/node/static-speed-helper.h Thu Jul 19 10:01:42 2007 +0200
@@ -16,11 +16,8 @@
void InitializePosition (const Position &position);
void Reset (const Speed &speed, const Time &pauseDelay);
-
void Reset (const Speed &speed);
- Time GetDelayToNextPosition (const Rectangle &bounds, Time delayLeft);
Position GetCurrentPosition (const Rectangle &bounds) const;
-
Position GetCurrentPosition (void) const;
Speed GetSpeed (void) const;