A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
constant-acceleration-mobility-model.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: Gustavo Carneiro <gjc@inescporto.pt>
17  */
19 #include "ns3/simulator.h"
20 
21 namespace ns3 {
22 
23 NS_OBJECT_ENSURE_REGISTERED (ConstantAccelerationMobilityModel)
24  ;
25 
27 {
28  static TypeId tid = TypeId ("ns3::ConstantAccelerationMobilityModel")
30  .AddConstructor<ConstantAccelerationMobilityModel> ();
31  return tid;
32 }
33 
35 {
36 }
37 
39 {
40 }
41 
42 inline Vector
44 {
45  double t = (Simulator::Now () - m_baseTime).GetSeconds ();
49 }
50 
51 inline Vector
53 {
54  double t = (Simulator::Now () - m_baseTime).GetSeconds ();
55  double half_t_square = t*t*0.5;
56  return Vector (m_basePosition.x + m_baseVelocity.x*t + m_acceleration.x*half_t_square,
57  m_basePosition.y + m_baseVelocity.y*t + m_acceleration.y*half_t_square,
58  m_basePosition.z + m_baseVelocity.z*t + m_acceleration.z*half_t_square);
59 }
60 
61 void
63 {
66  m_basePosition = position;
68 }
69 
70 void
72  const Vector &acceleration)
73 {
76  m_baseVelocity = velocity;
77  m_acceleration = acceleration;
79 }
80 
81 
82 } // namespace ns3
double x
x coordinate of vector
Definition: vector.h:49
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
a 3d vector
Definition: vector.h:31
Keep track of the current position and velocity of an object.
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
Vector3D Vector
Definition: vector.h:118
ConstantAccelerationMobilityModel()
Create position located at coordinates (0,0,0) with speed (0,0,0).
double y
y coordinate of vector
Definition: vector.h:53
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
void SetVelocityAndAcceleration(const Vector &velocity, const Vector &acceleration)
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
double z
z coordinate of vector
Definition: vector.h:57