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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef CONSTANT_VELOCITY_HELPER_H
9#define CONSTANT_VELOCITY_HELPER_H
10
11#include "box.h"
12
13#include "ns3/nstime.h"
14#include "ns3/vector.h"
15
16namespace ns3
17{
18
19class Rectangle;
20
21/**
22 * \ingroup mobility
23 *
24 * \brief Utility class used to move node with constant velocity.
25 */
27{
28 public:
30 /**
31 * Create object and set position
32 * \param position the position vector
33 */
34 ConstantVelocityHelper(const Vector& position);
35 /**
36 * Create object and set position and velocity
37 * \param position the position vector
38 * \param vel the velocity vector
39 */
40 ConstantVelocityHelper(const Vector& position, const Vector& vel);
41
42 /**
43 * Set position vector
44 * \param position Position vector
45 */
46 void SetPosition(const Vector& position);
47 /**
48 * Get current position vector
49 * \return Position vector
50 */
51 Vector GetCurrentPosition() const;
52 /**
53 * Get velocity; if paused, will return a zero vector
54 * \return Velocity vector
55 */
56 Vector GetVelocity() const;
57 /**
58 * Set new velocity vector
59 * \param vel Velocity vector
60 */
61 void SetVelocity(const Vector& vel);
62 /**
63 * Pause mobility at current position
64 */
65 void Pause();
66 /**
67 * Resume mobility from current position at current velocity
68 */
69 void Unpause();
70
71 /**
72 * Update position, if not paused, from last position and time of last update
73 * \param rectangle 2D bounding rectangle for resulting position; object will not move outside
74 * the rectangle
75 */
76 void UpdateWithBounds(const Rectangle& rectangle) const;
77 /**
78 * Update position, if not paused, from last position and time of last update
79 * \param bounds 3D bounding box for resulting position; object will not move outside the box
80 */
81 void UpdateWithBounds(const Box& bounds) const;
82 /**
83 * Update position, if not paused, from last position and time of last update
84 */
85 void Update() const;
86
87 private:
88 mutable Time m_lastUpdate; //!< time of last update
89 mutable Vector m_position; //!< state variable for current position
90 Vector m_velocity; //!< state variable for velocity
91 bool m_paused; //!< state variable for paused
92};
93
94} // namespace ns3
95
96#endif /* CONSTANT_VELOCITY_HELPER_H */
a 3d box
Definition box.h:24
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:24
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Every class exported by the ns3 library is enclosed in the ns3 namespace.