Commit 31464c3e authored by Armin Erraji's avatar Armin Erraji
Browse files

Merge branch 'develop' of https://git.rwth-aachen.de/ita/ITAPropagationModels into develop

parents b21c8c92 e3a3e49f
......@@ -20,15 +20,13 @@ set( ITAPropagationModelsHeader
"include/ITAPropagationModels/Definitions.h"
"include/ITAPropagationModels/DiffractionFilter.h"
"include/ITAPropagationModels/FilterEngine.h"
"include/ITAPropagationModels/FilterGenerator.h"
"include/ITAPropagationModels/Kirchhoff.h"
"include/ITAPropagationModels/Maekawa.h"
"include/ITAPropagationModels/Svensson.h"
"include/ITAPropagationModels/UTD.h"
)
set( ITAPropagationModelsSources
"src/ITAPropagationModels/FilterEngine.cpp"
"src/ITAPropagationModels/FilterGenerator.cpp"
"src/ITAPropagationModels/Kirchhoff.cpp"
"src/ITAPropagationModels/Maekawa.cpp"
"src/ITAPropagationModels/Svensson.cpp"
"src/ITAPropagationModels/UTD.cpp"
)
......
......@@ -21,7 +21,7 @@
#include <ITAPropagationModels/Base.h>
#include <ITAPropagationModels/Kirchhoff.h>
#include <ITAPropagationModels/Maekawa.h>
#include <ITAPropagationModels/UTD.h>
#include <ITAPropagationModels/Svensson.h>
......@@ -47,7 +47,7 @@
using namespace std;
using namespace ITAPropagationModels;
float g_fSpeedOfSound = 344.0f;
float g_fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F;
float g_fSampleRate = 44.1e3;
int g_iFilterLength = 64;
......@@ -82,44 +82,47 @@ void benchmark_single_wedge()
oReceiver->qOrient = VistaQuaternion( 0, 1, 0, 0 );
oReceiver->vPos.SetValues( -.4f, .6f, .1f );
auto oWedge = std::make_shared< ITAGeo::CITADiffractionWedgeAperture >();
oWedge->v3MainWedgeFaceNormal = VistaVector3D( 1.0f, 1.0f, .0f ).GetNormalized();
oWedge->v3OppositeWedgeFaceNormal = VistaVector3D( -1.0f, 1.0f, .0f ).GetNormalized();
oWedge->v3VertextStart.SetValues( .0f, 1.0f, -1.0f );
oWedge->v3VertextEnd.SetValues( .0f, 1.0f, 1.0f );
auto pWedge = std::make_shared< ITAGeo::CITADiffractionOuterWedgeAperture >();
pWedge->v3MainWedgeFaceNormal = VistaVector3D( 1.0f, 1.0f, .0f ).GetNormalized();
pWedge->v3OppositeWedgeFaceNormal = VistaVector3D( -1.0f, 1.0f, .0f ).GetNormalized();
pWedge->v3VertextStart.SetValues( .0f, 1.0f, -1.0f );
pWedge->v3VertextEnd.SetValues( .0f, 1.0f, 1.0f );
ITAGeoUtils::CalculateDiffractionAperturePoint( oWedge->GetEdgeRay(), oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, oWedge->v3AperturePoint );
ITAGeoUtils::CalculateDiffractionAperturePoint( pWedge->GetEdgeRay(), oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, pWedge->v3AperturePoint );
if( !ITAGeoUtils::IsDiffractionAperturePointInRange( oWedge->v3VertextStart, oWedge->v3VertextEnd, oWedge->v3AperturePoint ) )
if( !ITAGeoUtils::IsDiffractionAperturePointInRange( pWedge->v3VertextStart, pWedge->v3VertextEnd, pWedge->v3AperturePoint ) )
ITA_EXCEPT_INVALID_PARAMETER( "Aperture point over wedge is outside edge vertices" );
if( !oWedge->IsOutsideWedge( oSource->v3InteractionPoint ) )
if( !pWedge->IsOutsideWedge( oSource->v3InteractionPoint ) )
ITA_EXCEPT_INVALID_PARAMETER( "Source point is inside wedge (solid part)" );
if( !oWedge->IsOutsideWedge( oReceiver->v3InteractionPoint ) )
if( !pWedge->IsOutsideWedge( oReceiver->v3InteractionPoint ) )
ITA_EXCEPT_INVALID_PARAMETER( "Receiver point is inside wedge (solid part)" );
ITAGeo::CPropagationPath oPropPath;
oPropPath.push_back( oSource );
oPropPath.push_back( oWedge );
oPropPath.push_back( pWedge );
oPropPath.push_back( oReceiver );
cout << "Path: " << oPropPath << endl;
// Kirchhoff
if( Kirchhoff::IsApplicable( oPropPath ) )
if( Maekawa::IsApplicable( oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, pWedge ) )
ITA_EXCEPT_INVALID_PARAMETER( "Kirchhoff model can not be applied for this propagation path." );
ITAStopWatch sw;
cout << "Starting Kirchoff model benchmark:" << endl;
double dStartTime = ITAClock::getDefaultClock()->getTime();
ITABase::CHDFTSpectrum oTF( g_fSampleRate, g_iFilterLength, true );
for( int i = 0; i < 1e8; i++ )
{
sw.start();
Kirchhoff::CalculateDiffractionFilter( oPropPath, oTF, g_fSpeedOfSound );
double dDir, dDet;
Maekawa::GetDirectLengthAndDetourLength( oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, pWedge, dDir, dDet );
Maekawa::CalculateDiffractionFilter( dDir, dDet, oTF, g_fSpeedOfSound );
sw.stop();
}
double dStopTime = ITAClock::getDefaultClock()->getTime();
......@@ -136,7 +139,7 @@ void benchmark_single_wedge()
for( int i = 0; i < 1e6; i++ )
{
sw.start();
UTD::CalculateDiffractionFilter(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, oWedge, oTF, iMethod, g_fSpeedOfSound);
UTD::CalculateDiffractionFilter(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, pWedge, oTF, iMethod, g_fSpeedOfSound);
sw.stop();
}
dStopTime = ITAClock::getDefaultClock()->getTime();
......@@ -149,14 +152,14 @@ void benchmark_single_wedge()
sw.reset();
cout << "Starting Biot-Tolstoy-Medwin-Svensson model benchmark:" << endl;
dStartTime = ITAClock::getDefaultClock()->getTime();
const float fMinDelay = oWedge->GetMinimumWavefrontDelayTime(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, g_fSpeedOfSound);
const float fMaxDelay = oWedge->GetMaximumWavefrontDelayTime(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, g_fSpeedOfSound);
const float fMinDelay = pWedge->GetMinimumWavefrontDelayTime(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, g_fSpeedOfSound);
const float fMaxDelay = pWedge->GetMaximumWavefrontDelayTime(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, g_fSpeedOfSound);
const int iIRLength = ( int ) ceil( float( fMaxDelay - fMinDelay ) * g_fSampleRate );
ITABase::CFiniteImpulseResponse oIR( iIRLength, g_fSampleRate, true );
for( int i = 0; i < 1e4; i++ )
{
sw.start();
Svensson::CalculateDiffractionIR(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, oWedge, oIR, g_fSpeedOfSound);
Svensson::CalculateDiffractionIR(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, pWedge, oIR, g_fSpeedOfSound);
sw.stop();
}
dStopTime = ITAClock::getDefaultClock()->getTime();
......
......@@ -25,14 +25,18 @@
// ITA includes
#include <ITAGeo/Base.h>
#include <ITAGeo/Material//Manager.h>
#include <ITAHDFTSpectra.h>
#include <ITAHDFTSpectrum.h>
// STL includes
#include <vector>
namespace ITAPropagationModels
{
using namespace std;
//! Transfer function filter generator for propagation paths
/**
* Generates transfer functions in the frequency-domain that
......@@ -65,12 +69,37 @@ namespace ITAPropagationModels
//! Applies all acoustic models like reflection diffraction models
void ApplyAcousticModels( ITAGeo::CPropagationPathList& oPathList );
void ApplyDiffractionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = 1 );
void ApplyReflectionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = 1 );
//!Applies diffraction models
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
*/
void ApplyDiffractionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = -1);
//!Applies reflection models
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
*/
void ApplyReflectionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = -1 );
void ApplyTransmissionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = 1 ); // @todo
//!Applies emitter models
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
*/
void ApplyEmitterModel(ITAGeo::CPropagationPathList& oPathList, int iModel = -1);
//! Generate multi-channel propagation path (for multi-channel receiver directivitiy)
//!Applies sensor models
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
*/
void ApplySensorModel(ITAGeo::CPropagationPathList& oPathList, int iModel = -1);
void ApplyTransmissionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = -1 ); // @todo
//! Generate multi-channel propagation path (for multi-channel receiver directivity)
/**
* @todo AER
*/
......@@ -79,15 +108,44 @@ namespace ITAPropagationModels
//! Generate single-channel propagation path (for single-channel receiver directivity)
inline void Generate( const ITAGeo::CPropagationPathList& oPathList, ITABase::CHDFTSpectrum& oFilter )
{
const std::vector< ITABase::CHDFTSpectrum* > vpSpectra = { &oFilter };
const vector< ITABase::CHDFTSpectrum* > vpSpectra = { &oFilter };
ITABase::CHDFTSpectra oTF( vpSpectra );
Generate( oPathList, oTF );
};
//! Sets a connection to the material manager
void SetMaterialManager( const ITAGeo::CMaterialManager* pMaterialManager );
// Returns pointer to material manager or null
const ITAGeo::CMaterialManager* GetMaterialManager() const;
private:
ITABase::CHDFTSpectra m_oAccumulatedSpectra; //!< Gathered propagation paths from list
ITABase::CHDFTSpectra m_oTempPropPathSpectra; //!< Single prop-path spectra
unique_ptr<ITABase::CHDFTSpectra> m_pAccumulatedSpectra; //!< Gathered propagation paths from list
unique_ptr<ITABase::CHDFTSpectra> m_pTempPropPathSpectra; //!< Single prop-path spectra
static struct m_DefaultValues //!< Default values
{
static const int iReflectionModel = ITAGeo::IAcousticMaterial::SCALAR;
static const int iDiffractionModel = ITAGeo::IAcousticMaterial::THIRD_OCTAVE;
static const int iEmitterModel = ITAGeo::IAcousticMaterial::SCALAR;
static const int iSensorModel = ITAGeo::IAcousticMaterial::SCALAR;
};
const ITAGeo::CMaterialManager* m_pMaterialManager;
const double m_dHumidity = 80.0;
const double m_dTemperature = 20.0;
const float m_fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F;
static struct m_DefaultDiffractionModel //!< Default values for diffractions
{
int iModel = 1;
};
};
}
......
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER_GENERATOR
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER_GENERATOR
#include "Base.h"
#include "Definitions.h"
#include "DiffractionFilter.h"
// ITA includes
#include <ITAGeo/Base.h>
#include <ITAHDFTSpectra.h>
#include <ITAHDFTSpectrum.h>
// STL includes
#include <vector>
namespace ITAPropagationModels
{
//! Transfer function filter generator for propagation paths
/**
* Generates transfer functions in the frequency-domain that
* can be used as filters, e.g. for auralization.
*/
class ITA_PROPAGATION_MODELS_API CTFGenerator
{
public:
//! Construct a generator with predetermined output channels, e.g. for binaural or SH filters
/**
* @param[in] iNumOutputChannels Number of output channels
* @param[in] iDFTSize Length of the DFT used to construct and combine filter components
* @param[in] fSamplingRate Filer sampling rate
*/
CTFGenerator( const int iNumOutputChannels, const int iDFTSize = 128, const float fSamplingRate = 44100.0f );
//! Cunstruct a generator with matching properties of a target spectrum
inline CTFGenerator( const ITABase::CHDFTSpectrum& pTransferFunction )
: CTFGenerator( 1, pTransferFunction.GetDFTSize(), pTransferFunction.GetSampleRate() )
{
};
//! Cunstruct a generator with matching properties of multi-channel target spectra
CTFGenerator( const ITABase::CHDFTSpectra& pTransferFunctions )
: CTFGenerator( pTransferFunctions.GetNumChannels(), pTransferFunctions.GetDFTSize(), pTransferFunctions.GetSampleRate() )
{
};
//! Generate a single-channel transfer function
inline void GenerateTF( ITABase::CHDFTSpectrum& pTransferFunction )
{
const std::vector< ITABase::CHDFTSpectrum* > vpSpectra = { &( pTransferFunction ) };
ITABase::CHDFTSpectra oTF( vpSpectra );
GenerateTF( oTF );
};
//! Generate a multi-channel transfer function
inline void GenerateTF( ITABase::CHDFTSpectra& pTransferFunctions );
private:
};
}
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER_GENERATOR
......@@ -19,8 +19,8 @@
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_KIRCHHOFF
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_KIRCHHOFF
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_MAEKAWA
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_MAEKAWA
#include "Definitions.h"
......@@ -35,143 +35,118 @@
namespace ITAPropagationModels
{
//! Diffraction calculation based on Kirchhoff approximation
//! Diffraction calculation based on Maekawa
/**
* @sa Maekawa, Z.; Noise reduction by screens Applied Acoustics; 1968, 1, 157 - 173
* @sa Pierce, A. D.; Diffraction of sound around corners and over wide barriers; J. Acoust. Soc. Am., 1974, 55, 941-955
*/
namespace Kirchhoff
namespace Maekawa
{
//! Validates if Kirchhoff diffraction method can be applied
//! Validates if Maekawa diffraction method can be applied
/**
* The Kirchhoff detour method only makes sense if the source is
* The Maekawa method only makes sense if the source is
* occluded by obstacles in it's way to the receiver (or vice versa).
* This may include specular reflections, but inverse wedges (corners) have to
* be excluded because they can not occlude entities.
*
* @param[in] oPropPath Propagation path to be simulated
* @return True, if Kirchhoff can be used (makes sense for this path)
* @param[in] v3SourcePos Source position
* @param[in] v3TargetPos Target position
* @param[in] pApex Aperture point on wedge
*
* @sa KirchhoffDetourAndLength
* @sa KirchhoffDiffractionFilter
* @return True, if Maekawa can be used (diffracting into shadow zone)
*
* @sa MaekawaDetourAndLength
* @sa MaekawaDiffractionFilter
*
* @note Throws ITAException on error
*
*/
bool ITA_PROPAGATION_MODELS_API IsApplicable( const ITAGeo::CPropagationPath& oPropPath );
bool ITA_PROPAGATION_MODELS_API IsApplicable( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeApertureBase > pApex );
//! Calculates the detour of a propagation path for the Kirchhoff method
//! Calculates the detour of a propagation path for the Maekawa method
/**
* Calculates the direct path vs. detour path by taking diffraction anchors into account.
* It is recommended to validate the path, first. Otherwise unpredictable results will occur.
*
* 1. Specular reflections will increase the direct path length AND detour length
* 2. Only diffraction around a wedge are treated (diffraction angle greater \pi, where 0 would be back-scattering and \pi is gracing angle)
* Calculates the direct path vs. detour path by taking the diffraction anchor into account.
*
* @param[in] oPropPath Propagation path to be simulated
* @param[out] dPropagationLengthDirect Propagation path length without occlusion [m]
* @param[out] dPropagationLengthDetour Propagation path detour length with occlusion [m]
* @param[in] v3SourcePos Source position
* @param[in] v3TargetPos Target position
* @param[in] pApex Aperture point on wedge
* @param[out] dPropagationLengthFreeField Propagation path length without occlusion [m]
* @param[out] dPropagationLengthOverApex Propagation path detour length with occlusion [m]
*
* @sa IsKirchhoffApplicable
* @sa IsMaekawaApplicable
*
* @note Throws ITAException on error
*
*/
void ITA_PROPAGATION_MODELS_API GetDirectLengthAndDetourLength( const ITAGeo::CPropagationPath& oPropPath, double& dPropagationLengthDirect, double& dPropagationLengthDetour );
void ITA_PROPAGATION_MODELS_API GetDirectLengthAndDetourLength( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeApertureBase > pApex, double& dPropagationLengthFreeField, double& dPropagationLengthOverApex );
//! Calculates the detour-and-direct-path difference of a propagation path for the Kirchhoff method
//! Calculates the detour-and-direct-path difference of a propagation path for the Maekawa method
/**
* @param[in] dPropagationLengthDirect Direct path length [m] (sometimes referred to as 'd')
* @param[in] dPropagationLengthDetour Detour path length [m] (sometimes referred to as 'A+B')
* @param[in] dPropagationLengthFreeField Direct path length [m] (sometimes referred to as 'd')
* @param[in] dPropagationLengthOverApex Detour path length [m] (sometimes referred to as 'A+B')
*
* @return Kirchhoff delta (difference) [m] (\delta, sometimes referred to as 'A+B-d')
*
* @note Throws ITAException on error
*
*/
double ITA_PROPAGATION_MODELS_API KirchhoffDelta( const double dPropagationLengthDirect, const double dPropagationLengthDetour );
double ITA_PROPAGATION_MODELS_API KirchhoffDelta( const double dPropagationLengthFreeField, const double dPropagationLengthOverApex );
//! Calculates the detour-and-direct-path inverse difference factor of a propagation path for the Kirchhoff method
//! Calculates the detour-and-direct-path inverse difference factor of a propagation path for the Maekawa method
/**
* @return Kirchhoff delta factor (ratio), always greater or equal 1.0
*
* @note Throws ITAException on error
*
*/
inline double KirchhoffDeltaInverseFactor( const double dPropagationLengthDirect, const double dPropagationLengthDetour )
inline double KirchhoffDeltaInverseFactor( const double dPropagationLengthFreeField, const double dPropagationLengthOverApex )
{
const double dKirchhoffDelta = Kirchhoff::KirchhoffDelta( dPropagationLengthDirect, dPropagationLengthDetour );
const double dKirchhoffDeltaInverseFactor = ( dPropagationLengthDirect + dKirchhoffDelta ) / dPropagationLengthDirect;
const double dKirchhoffDelta = Maekawa::KirchhoffDelta( dPropagationLengthFreeField, dPropagationLengthOverApex );
const double dKirchhoffDeltaInverseFactor = ( dPropagationLengthFreeField + dKirchhoffDelta ) / dPropagationLengthFreeField;
return dKirchhoffDeltaInverseFactor;
};
//! Calculate diffraction filter (frequency domain) based on the Kirchhoff detour method
//! Calculate diffraction filter based on the Maekawa detour method
/**
* This function calculates the Kirchhoff diffraction filter based on detour length around a wedge obstacle
* and the direct path length with and withont any obstacles.
* This function calculates the Maekawa diffraction filter coefficient based on detour length around a wedge obstacle
* and the direct path length with and without any obstacles.
*
* @param[in] dPropagationLengthDirect Direct path length [m]
* @param[in] dPropagationLengthDetour Detour path length [m]
* @param[out] oTransferFunction Destination filter of simulation (zero-phase frequency domain magnitude spectrum)
* @param[in] dPropagationLengthFreeField Direct path length [m]
* @param[in] dPropagationLengthOverApex Detour path length [m]
* @param[in] fFrequency Frequency [Hz]
* @param[in] fSpeedOfSound Speed of sound [m/s]
*
*/
void ITA_PROPAGATION_MODELS_API CalculateDiffractionFilter( const double dPropagationLengthDirect, const double dPropagationLengthDetour, ITABase::CHDFTSpectrum& oTransferFunction, const float fSpeedOfSound = 344.0f );
double ITA_PROPAGATION_MODELS_API CalculateDiffractionFilterCoefficient( const double dPropagationLengthFreeField, const double dPropagationLengthOverApex, const float fFrequency, const float fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F);
//! Calculate diffraction filter (frequency domain) based on the Kirchhoff detour method for a single wedge
//! Calculate diffraction factor based on the Maekawa detour method
/**
* This function calculates the Kirchhoff diffraction filter based on detour length around a wedge obstacle
* and the direct path length with and without any obstacles.
* This function calculates the Maekawa diffraction factor based on detour length around a wedge obstacle
* and the direct path length with and without any obstacles.
* The diffraction factor contains the influence of the wedge without the influence of the propagation path length.
*
* @param[in] oPropPath Propagation path
* @param[out] oTransferFunction Destination filter of simulation (frequency domain)
*
* @return True, if Kirchhoff method could be applied
*
* @note Throws ITAException on error
* @param[in] dPropagationLengthFreeField Direct path length [m]
* @param[in] dPropagationLengthOverApex Detour path length [m]
* @param[in] fFrequency Frequency [Hz]
* @param[in] fSpeedOfSound Speed of sound [m/s]
*
*/
inline bool CalculateDiffractionFilter( const ITAGeo::CPropagationPath& oPropPath, ITABase::CHDFTSpectrum& oTransferFunction, const float fSpeedOfSound = 344.0f )
{
if( !Kirchhoff::IsApplicable( oPropPath ) )
return false;
double dDirect, dDetour;
Kirchhoff::GetDirectLengthAndDetourLength( oPropPath, dDirect, dDetour );
Kirchhoff::CalculateDiffractionFilter( dDirect, dDetour, oTransferFunction, fSpeedOfSound );
double ITA_PROPAGATION_MODELS_API CalculateDiffractionFactor(const double dPropagationLengthFreeField, const double dPropagationLengthOverApex, const float fFrequency, const float fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F);
return true;
};
//! Calculate diffraction filter (frequency domain) based on the Kirchhoff detour method for a single wedge
//! Calculate diffraction filter (frequency domain) based on the Maekawa detour method
/**
* This function calculates the Kirchhoff diffraction filter based on detour length around a wedge obstacle
* and the direct path length with and without any obstacles.
*
* @param[in] pSource Source of propagation (previous anchor point of path)
* @param[in] pWedge Diffraction wedge of propagation
* @param[in] pTarget Target of propagation (next anchor point of path)
* @param[out] oTransferFunction Destination filter of simulation (frequency domain)
*
* @return True, if Kirchhoff method could be applied
* This function calculates the Maekawa diffraction filter based on detour length around a wedge obstacle
* and the direct path length with and withont any obstacles.
*
* @note Throws ITAException on error
* @param[in] dPropagationLengthFreeField Direct path length [m]
* @param[in] dPropagationLengthOverApex Detour path length [m]
* @param[out] oTransferFunction Destination filter of simulation (zero-phase frequency domain magnitude spectrum)
* @param[in] fSpeedOfSound Speed of sound [m/s]
*
*/
inline bool CalculateDiffractionFilter( std::shared_ptr< ITAGeo::CPropagationAnchor > pSource, std::shared_ptr< ITAGeo::CITADiffractionWedgeAperture > pWedge, std::shared_ptr< ITAGeo::CPropagationAnchor > pTarget, ITABase::CHDFTSpectrum& oTransferFunction, const float fSpeedOfSound = 344.0f )
{
if( !pWedge->IsOccluding( pSource, pTarget ) )
return false;
// A little dirty removing const, but we know what we are doing, here.
ITAGeo::CPropagationPath oPropPath;
oPropPath.push_back( pSource );
oPropPath.push_back( pWedge );
oPropPath.push_back( pTarget );
const ITAGeo::CPropagationPath& oConstPropPath( oPropPath ); // Not necessary, just making a point
return CalculateDiffractionFilter( oConstPropPath, oTransferFunction, fSpeedOfSound );
};
void ITA_PROPAGATION_MODELS_API CalculateDiffractionFilter( const double dPropagationLengthFreeField, const double dPropagationLengthOverApex, ITABase::CHDFTSpectrum& oTransferFunction, const float fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F);
}
}
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_KIRCHHOFF
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_MAEKAWA
......@@ -49,7 +49,7 @@ namespace ITAPropagationModels
*
* @sa GetMinimumWavefrontDelayTime, GetMaximumWavefrontDelayTime
*/
ITA_PROPAGATION_MODELS_API bool CalculateDiffractionIR( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeAperture > pApex, ITABase::CFiniteImpulseResponse& oEffectiveDiffractionIR, const float fSpeedOfSound = 344.0f );
ITA_PROPAGATION_MODELS_API bool CalculateDiffractionIR( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeApertureBase > pApex, ITABase::CFiniteImpulseResponse& oEffectiveDiffractionIR, const float fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F );
}
}
......
......@@ -40,6 +40,9 @@ namespace ITAPropagationModels
{
namespace UTD
{
using namespace std;
//! UTD diffraction coefficient calculation methods (only approximation implemented yet!)
enum UTD_DIFFRACTION_ALGORITHM
{
......@@ -60,10 +63,24 @@ namespace ITAPropagationModels
* @param[in] v3TargetPos target position (outside wedge)
* @param[in] pApex Aperture point including wedge parameters (angles, etc)
* @param[in] fWaveNumber Wave number ( k )
* @param[out] cfCoeff Complex-valued diffraction coefficient ( D( n, k,\rho, r, \phi_i, \alpha_i, \alpha_d ) )
* @param[out] cfFactor Complex-valued diffraction coefficient ( D( n, k,\rho, r, \phi_i, \alpha_i, \alpha_d ) )
* @param[in] iMethod Approximation algorithm
*/
ITA_PROPAGATION_MODELS_API bool CalculateDiffractionCoefficient( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeAperture > pApex, const float fWaveNumber, std::complex< float >& cfCoeff, const int iMethod = UTD_APPROX_KAWAI_KOUYOUMJIAN );
bool ITA_PROPAGATION_MODELS_API CalculateDiffractionCoefficient( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeApertureBase > pApex, const float fFrequency, complex< float >& cfCoeff, const int iMethod = UTD_APPROX_KAWAI_KOUYOUMJIAN, const float fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F );
//! Calculate diffraction factor based on the Maekawa detour method
/**
* This function calculates the Maekawa diffraction factor based on detour length around a wedge obstacle
* and the direct path length with and without any obstacles.
* The diffraction factor contains the influence of the wedge without the influence of the propagation path length.
*
* @param[in] dPropagationLengthFreeField Direct path length [m]
* @param[in] dPropagationLengthOverApex Detour path length [m]
* @param[in] fFrequency Frequency [Hz]
* @param[in] fSpeedOfSound Speed of sound [m/s]
*
*/
bool ITA_PROPAGATION_MODELS_API CalculateDiffractionFactor(const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, shared_ptr< const ITAGeo::CITADiffractionWedgeApertureBase > pApex, const float fFrequency, complex< float >& cfFactor, const int iMethod = UTD_APPROX_KAWAI_KOUYOUMJIAN, const float fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F );
//! Calculates the UTD diffraction filter in frequency domain for a given constellation
/**
......@@ -78,7 +95,7 @@ namespace ITAPropagationModels
* @param[in] iMethod Approximation algorithm
* @param[in] fSpeedOfSound Sound speed
*/
ITA_PROPAGATION_MODELS_API void CalculateDiffractionFilter( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeAperture > pApex, ITABase::CHDFTSpectrum& oTF, const int iMethod = UTD_APPROX_KAWAI_KOUYOUMJIAN, const float fSpeedOfSound = 344.0f );
void ITA_PROPAGATION_MODELS_API CalculateDiffractionFilter( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeApertureBase > pApex, ITABase::CHDFTSpectrum& oTF, const int iMethod = UTD_APPROX_KAWAI_KOUYOUMJIAN, const float fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F );
}
}
......
#include <ITAPropagationModels/FilterGenerator.h>
#include <ITAPropagationModels/FilterEngine.h>
// ITA includes