![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 00029 #include <WNS/Positionable.hpp> 00030 #include <WNS/PositionObserver.hpp> 00031 #include <WNS/Assure.hpp> 00032 00033 #include <functional> 00034 00035 using namespace wns; 00036 00037 Positionable::Positionable() : 00038 position() 00039 { 00040 } 00041 00042 Positionable::Positionable(const Positionable& other) : 00043 SubjectType::SubjectType(other), 00044 PositionableInterface(other), 00045 SubjectType(other), 00046 position(other.position) 00047 { 00048 } 00049 00050 Positionable::Positionable(const Position& p) : 00051 position(p) 00052 { 00053 } 00054 00055 Positionable::Positionable(const wns::pyconfig::View& positionView) : 00056 position() 00057 { 00058 position = Position(positionView.get<double>("x"), 00059 positionView.get<double>("y"), 00060 positionView.get<double>("z")); 00061 } 00062 00063 Positionable::~Positionable() 00064 { 00065 } 00066 00067 const wns::Position& 00068 Positionable::getPosition() const 00069 { 00070 return position; 00071 } 00072 00073 double 00074 Positionable::getDistance(PositionableInterface* p) 00075 { 00076 assure(p, "No valid object provided!"); 00077 return (p->getPosition() - this->getPosition()).abs(); 00078 } 00079 00080 double 00081 Positionable::getDistance(const PositionableInterface& p) 00082 { 00083 return (p.getPosition() - this->getPosition()).abs(); 00084 } 00085 00086 double 00087 Positionable::getAngle(const PositionableInterface &p) 00088 { 00089 return(p.getPosition() - this->getPosition()).getAzimuth(); 00090 } 00091 00092 00093 void 00094 Positionable::setPosition(const wns::Position& p) 00095 { 00096 this->sendNotifies(&PositionObserver::positionWillChange); 00097 position = p; 00098 this->sendNotifies(&PositionObserver::positionChanged); 00099 } 00100 00101 00102
1.5.5