![]() |
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 #include <RISE/antenna/ITUAntennaWithWrap.hpp> 00029 #include <RISE/stations/station.hpp> 00030 #include <cmath> 00031 00032 using namespace rise::antenna; 00033 00034 ITUAntennaWithWrap::ITUAntennaWithWrap(const wns::pyconfig::View& pyConfigView, Station* const station): 00035 ITUAntenna(pyConfigView, station), 00036 sizeX(pyConfigView.get<double>("sizeX")), 00037 sizeY(pyConfigView.get<double>("sizeX")) 00038 { 00039 } 00040 00041 ITUAntennaWithWrap::~ ITUAntennaWithWrap() 00042 { 00043 } 00044 00045 wns::Ratio 00046 ITUAntennaWithWrap::getGain(const wns::Position& pos, const PatternPtr pattern) const 00047 { 00048 double x1 = getPosition().getX(); 00049 double y1 = getPosition().getY(); 00050 double x2 = pos.getX(); 00051 double y2 = pos.getY(); 00052 double newX2 = 0.0; 00053 double newY2 = 0.0; 00054 00055 if((abs(x1 - x2) > (sizeX - abs(x1 - x2))) or (abs(y1 - y2) > (sizeY - abs(y1 - y2)))) 00056 { 00057 // draw over edge required 00058 if (abs(x1 - x2) < abs(y1 - y2)) 00059 { 00060 // draw over x-edge 00061 if (y1 < y2) 00062 { 00063 // [x1, y1] is the lower point 00064 double dy1 = y1; 00065 double dy2 = sizeY - y2; 00066 double dy = dy1 + dy2; 00067 double dx = x2 - x1; 00068 newX2 = x1+dx*dy1/dy; 00069 newY2 = 0.0; 00070 } 00071 else 00072 { 00073 // [x2, y2] is the lower point -> reverse operation 00074 double dy1 = sizeY - y1; 00075 double dy2 = y2; 00076 double dy = dy1 + dy2; 00077 double dx = x2 - x1; 00078 newX2 = x1+dx*dy1/dy; 00079 newY2 = sizeX; 00080 } 00081 } 00082 else 00083 { 00084 // draw over y-edge 00085 if (x1 < x2) 00086 { 00087 // [x1, y1] is the left point 00088 double dy = y2 - y1; 00089 double dx1 = x1; 00090 double dx2 = sizeX - x2; 00091 double dx = dx1 + dx2; 00092 newX2 = 0.0; 00093 newY2 = y1+dy*dx1/dx; 00094 } 00095 else 00096 { 00097 // [x2, y2] is the left point -> reverse operation 00098 double dy = y2 - y1; 00099 double dx1 = sizeX - x1; 00100 double dx2 = x2; 00101 double dx = dx1 + dx2; 00102 newX2 = sizeY; 00103 newY2 = y1+dy*dx1/dx; 00104 } 00105 } 00106 } 00107 else 00108 { 00109 newX2 = x2; 00110 newY2 = y2; 00111 } 00112 wns::Position newPos(newX2, newY2, pos.getZ()); 00113 00114 MESSAGE_BEGIN(NORMAL, log, m,"Moving point"); 00115 m << "(" << pos.getX() << "," << pos.getY() << "," << pos.getZ() << ") to "; 00116 m << "(" << newPos.getX() << "," << newPos.getY() << "," << newPos.getZ() << ")"; 00117 MESSAGE_END(); 00118 00119 return(ITUAntenna::getGain(newPos, pattern)); 00120 }
1.5.5