OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2014 Tiago Cerqueira |
| 4 * |
| 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 |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 * |
| 18 * Author: Tiago Cerqueira <1090678@isep.ipp.pt> <tiago.miguel43@gmail.com> |
| 19 */ |
| 20 |
| 21 #include "leg.h" |
| 22 NS_LOG_COMPONENT_DEFINE ("Leg"); |
| 23 namespace ns3 { |
| 24 Leg::Leg () |
| 25 { |
| 26 NS_LOG_FUNCTION (this); |
| 27 } |
| 28 |
| 29 Leg::Leg (StepList &stepList) |
| 30 { |
| 31 NS_LOG_FUNCTION (this); |
| 32 this->m_stepList = stepList; |
| 33 } |
| 34 |
| 35 Leg::Leg (const Leg& orig) |
| 36 { |
| 37 } |
| 38 |
| 39 Leg::~Leg () |
| 40 { |
| 41 NS_LOG_FUNCTION (this); |
| 42 } |
| 43 |
| 44 double |
| 45 Leg::CalculatePartialDistance (Ptr<Point> p1, Ptr<Point> p2) |
| 46 { |
| 47 NS_LOG_FUNCTION (this); |
| 48 double distance = 0; |
| 49 distance = sqrt (((pow ((p2->GetXCoordinate () - p1->GetXCoordinate ()), 2.0))
+ (pow ((p2->GetYCoordinate () - p1->GetYCoordinate ()), 2.0)))); |
| 50 return distance; |
| 51 } |
| 52 |
| 53 double |
| 54 Leg::CalculateTotalDistanceInStep (Step& step) |
| 55 { |
| 56 NS_LOG_FUNCTION (this); |
| 57 double distance = 0; |
| 58 std::list<Ptr<Point> > pointList = step.GetPointList (); |
| 59 std::list<Ptr<Point> >::iterator i = pointList.begin (); |
| 60 i++; |
| 61 for (std::list<Ptr<Point> >::iterator k = pointList.begin (); i != pointList.e
nd (); i++, k++) |
| 62 { |
| 63 distance += CalculatePartialDistance ((*k), (*i)); |
| 64 } |
| 65 return distance; |
| 66 } |
| 67 void |
| 68 Leg::GetStepList (StepList &stepList) |
| 69 { |
| 70 NS_LOG_FUNCTION (this); |
| 71 stepList = StepList (m_stepList); |
| 72 } |
| 73 void |
| 74 Leg::SetStepList (std::list<Ptr<Step> > stepList) |
| 75 { |
| 76 NS_LOG_FUNCTION (this); |
| 77 this->m_stepList = StepList (stepList); |
| 78 } |
| 79 } |
OLD | NEW |