LEFT | RIGHT |
(no file at all) | |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 Phillip Sitbon | 3 * Copyright (c) 2009 Phillip Sitbon |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 const double t_span = (m_next.time - m_current.time).GetSeconds (); | 153 const double t_span = (m_next.time - m_current.time).GetSeconds (); |
154 NS_ASSERT (t_span > 0); | 154 NS_ASSERT (t_span > 0); |
155 m_velocity.x = (m_next.position.x - m_current.position.x) / t_span; | 155 m_velocity.x = (m_next.position.x - m_current.position.x) / t_span; |
156 m_velocity.y = (m_next.position.y - m_current.position.y) / t_span; | 156 m_velocity.y = (m_next.position.y - m_current.position.y) / t_span; |
157 m_velocity.z = (m_next.position.z - m_current.position.z) / t_span; | 157 m_velocity.z = (m_next.position.z - m_current.position.z) / t_span; |
158 } | 158 } |
159 | 159 |
160 if ( now > m_current.time ) // Won't ever be less, but may be equal | 160 if ( now > m_current.time ) // Won't ever be less, but may be equal |
161 { | 161 { |
| 162 NS_ASSERT (now >= m_current.time); |
162 const double t_diff = (now - m_current.time).GetSeconds (); | 163 const double t_diff = (now - m_current.time).GetSeconds (); |
163 m_current.position.x += m_velocity.x * t_diff; | 164 m_current.position.x += m_velocity.x * t_diff; |
164 m_current.position.y += m_velocity.y * t_diff; | 165 m_current.position.y += m_velocity.y * t_diff; |
165 m_current.position.z += m_velocity.z * t_diff; | 166 m_current.position.z += m_velocity.z * t_diff; |
166 m_current.time = now; | 167 m_current.time = now; |
167 } | 168 } |
168 | 169 |
169 if ( newWaypoint ) | 170 if ( newWaypoint ) |
170 { | 171 { |
171 NotifyCourseChange (); | 172 NotifyCourseChange (); |
(...skipping 24 matching lines...) Expand all Loading... |
196 if ( !m_first && (now >= m_current.time) ) | 197 if ( !m_first && (now >= m_current.time) ) |
197 { | 198 { |
198 // This is only a course change if the node is actually moving | 199 // This is only a course change if the node is actually moving |
199 NotifyCourseChange (); | 200 NotifyCourseChange (); |
200 } | 201 } |
201 } | 202 } |
202 void | 203 void |
203 WaypointMobilityModel::EndMobility (void) | 204 WaypointMobilityModel::EndMobility (void) |
204 { | 205 { |
205 m_waypoints.clear (); | 206 m_waypoints.clear (); |
206 m_current.time = Time(std::numeric_limits<uint64_t>::infinity()); | 207 m_current.time = Time (std::numeric_limits<uint64_t>::infinity ()); |
207 m_next.time = m_current.time; | 208 m_next.time = m_current.time; |
208 m_first = true; | 209 m_first = true; |
209 } | 210 } |
210 Vector | 211 Vector |
211 WaypointMobilityModel::DoGetVelocity (void) const | 212 WaypointMobilityModel::DoGetVelocity (void) const |
212 { | 213 { |
213 return m_velocity; | 214 return m_velocity; |
214 } | 215 } |
215 | 216 |
216 } // namespace ns3 | 217 } // namespace ns3 |
217 | 218 |
LEFT | RIGHT |