A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
constant-velocity-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006,2007 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#ifndef CONSTANT_VELOCITY_HELPER_H
20#define CONSTANT_VELOCITY_HELPER_H
21
22#include "box.h"
23
24#include "ns3/nstime.h"
25#include "ns3/vector.h"
26
27namespace ns3
28{
29
30class Rectangle;
31
32/**
33 * \ingroup mobility
34 *
35 * \brief Utility class used to move node with constant velocity.
36 */
38{
39 public:
41 /**
42 * Create object and set position
43 * \param position the position vector
44 */
45 ConstantVelocityHelper(const Vector& position);
46 /**
47 * Create object and set position and velocity
48 * \param position the position vector
49 * \param vel the velocity vector
50 */
51 ConstantVelocityHelper(const Vector& position, const Vector& vel);
52
53 /**
54 * Set position vector
55 * \param position Position vector
56 */
57 void SetPosition(const Vector& position);
58 /**
59 * Get current position vector
60 * \return Position vector
61 */
62 Vector GetCurrentPosition() const;
63 /**
64 * Get velocity; if paused, will return a zero vector
65 * \return Velocity vector
66 */
67 Vector GetVelocity() const;
68 /**
69 * Set new velocity vector
70 * \param vel Velocity vector
71 */
72 void SetVelocity(const Vector& vel);
73 /**
74 * Pause mobility at current position
75 */
76 void Pause();
77 /**
78 * Resume mobility from current position at current velocity
79 */
80 void Unpause();
81
82 /**
83 * Update position, if not paused, from last position and time of last update
84 * \param rectangle 2D bounding rectangle for resulting position; object will not move outside
85 * the rectangle
86 */
87 void UpdateWithBounds(const Rectangle& rectangle) const;
88 /**
89 * Update position, if not paused, from last position and time of last update
90 * \param bounds 3D bounding box for resulting position; object will not move outside the box
91 */
92 void UpdateWithBounds(const Box& bounds) const;
93 /**
94 * Update position, if not paused, from last position and time of last update
95 */
96 void Update() const;
97
98 private:
99 mutable Time m_lastUpdate; //!< time of last update
100 mutable Vector m_position; //!< state variable for current position
101 Vector m_velocity; //!< state variable for velocity
102 bool m_paused; //!< state variable for paused
103};
104
105} // namespace ns3
106
107#endif /* CONSTANT_VELOCITY_HELPER_H */
a 3d box
Definition: box.h:35
Utility class used to move node with constant velocity.
Time m_lastUpdate
time of last update
Vector GetCurrentPosition() const
Get current position vector.
Vector m_position
state variable for current position
Vector GetVelocity() const
Get velocity; if paused, will return a zero vector.
void Update() const
Update position, if not paused, from last position and time of last update.
void UpdateWithBounds(const Rectangle &rectangle) const
Update position, if not paused, from last position and time of last update.
void Unpause()
Resume mobility from current position at current velocity.
void SetPosition(const Vector &position)
Set position vector.
void SetVelocity(const Vector &vel)
Set new velocity vector.
void Pause()
Pause mobility at current position.
Vector m_velocity
state variable for velocity
bool m_paused
state variable for paused
a 2d rectangle
Definition: rectangle.h:35
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Every class exported by the ns3 library is enclosed in the ns3 namespace.