A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
constant-acceleration-mobility-model.cc
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 *
15 * Author: Gustavo Carneiro <gjc@inescporto.pt>
16 */
18
19#include "ns3/simulator.h"
20
21namespace ns3
22{
23
24NS_OBJECT_ENSURE_REGISTERED(ConstantAccelerationMobilityModel);
25
26TypeId
28{
29 static TypeId tid = TypeId("ns3::ConstantAccelerationMobilityModel")
31 .SetGroupName("Mobility")
32 .AddConstructor<ConstantAccelerationMobilityModel>();
33 return tid;
34}
35
37{
38}
39
41{
42}
43
44inline Vector
46{
47 double t = (Simulator::Now() - m_baseTime).GetSeconds();
48 return Vector(m_baseVelocity.x + m_acceleration.x * t,
51}
52
53inline Vector
55{
56 double t = (Simulator::Now() - m_baseTime).GetSeconds();
57 double half_t_square = t * t * 0.5;
58 return Vector(m_basePosition.x + m_baseVelocity.x * t + m_acceleration.x * half_t_square,
59 m_basePosition.y + m_baseVelocity.y * t + m_acceleration.y * half_t_square,
60 m_basePosition.z + m_baseVelocity.z * t + m_acceleration.z * half_t_square);
61}
62
63void
65{
68 m_basePosition = position;
70}
71
72void
74 const Vector& acceleration)
75{
78 m_baseVelocity = velocity;
79 m_acceleration = acceleration;
81}
82
83} // namespace ns3
Mobility model for which the current acceleration does not change once it has been set and until it i...
void SetVelocityAndAcceleration(const Vector &velocity, const Vector &acceleration)
Set the model's velocity and acceleration.
static TypeId GetTypeId()
Register this type with the TypeId system.
ConstantAccelerationMobilityModel()
Create position located at coordinates (0,0,0) with speed (0,0,0).
Keep track of the current position and velocity of an object.
void NotifyCourseChange() const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.