A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
constant-acceleration-mobility-model.cc
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Author: Gustavo Carneiro <gjc@inescporto.pt>
5 */
7
8#include "ns3/simulator.h"
9
10namespace ns3
11{
12
13NS_OBJECT_ENSURE_REGISTERED(ConstantAccelerationMobilityModel);
14
15TypeId
17{
18 static TypeId tid = TypeId("ns3::ConstantAccelerationMobilityModel")
20 .SetGroupName("Mobility")
21 .AddConstructor<ConstantAccelerationMobilityModel>();
22 return tid;
23}
24
28
32
33inline Vector
35{
36 double t = (Simulator::Now() - m_baseTime).GetSeconds();
37 return Vector(m_baseVelocity.x + m_acceleration.x * t,
40}
41
42inline Vector
44{
45 double t = (Simulator::Now() - m_baseTime).GetSeconds();
46 double half_t_square = t * t * 0.5;
47 return Vector(m_basePosition.x + m_baseVelocity.x * t + m_acceleration.x * half_t_square,
48 m_basePosition.y + m_baseVelocity.y * t + m_acceleration.y * half_t_square,
49 m_basePosition.z + m_baseVelocity.z * t + m_acceleration.z * half_t_square);
50}
51
52void
60
61void
63 const Vector& acceleration)
64{
67 m_baseVelocity = velocity;
68 m_acceleration = acceleration;
70}
71
72} // 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:197
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.