IntensityModel.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        IntensityModel.h
00003  *
00004  * author:      Jerome Rousselot
00005  *
00006  * copyright:   (C) 2008 Centre Suisse d'Electronique et Microtechnique (CSEM) SA
00007  *              Real-Time Software and Networking
00008  *              Jaquet-Droz 1, CH-2002 Neuchatel, Switzerland.
00009  *
00010  *              This program is free software; you can redistribute it
00011  *              and/or modify it under the terms of the GNU General Public
00012  *              License as published by the Free Software Foundation; either
00013  *              version 2 of the License, or (at your option) any later
00014  *              version.
00015  *              For further information see file COPYING
00016  *              in the top level directory
00017  * description: this AnalogueModel models the spreading of radiated power
00018  *        over a sphere centered on the emitter.
00019  ***************************************************************************/
00020 #ifndef INTENSITYMODEL_H_
00021 #define INTENSITYMODEL_H_
00022 
00023 #include "AnalogueModel.h"
00024 #include "Mapping.h"
00025 #include "Signal_.h"
00026 #include "BaseWorldUtility.h"
00027 #include <math.h>
00028 
00029 #define PI 3.1415926
00030 
00036 class IntensityModel : public AnalogueModel {
00037 
00038 public:
00039   IntensityModel() { }
00040   void filterSignal(Signal& s) {
00041     TimeMapping<Linear>* attMapping = new TimeMapping<Linear> ();
00042 
00043     // Determine distance between sender and receiver
00044     Move srcMove = s.getMove();
00045     Coord srcCoord, rcvCoord;
00046     double distance = 0;
00047     srcCoord = srcMove.getPositionAt(s.getSignalStart());
00048     rcvCoord = move->getPositionAt(s.getSignalStart());
00049     distance = rcvCoord.distance(srcCoord);
00050 
00051     Argument arg;
00052     attMapping->setValue(arg, 4*PI*pow(distance, 2));
00053     s.addAttenuation(attMapping);
00054   }
00055 };
00056 
00057 #endif /* INTENSITYMODEL_H_ */