Commit 059f1245 authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

ART - RayResolutionAdapter

- added functions for advanced ray zooming
parent debfb2d4
#include "RayResolutionAdapter.h"
#include <ITAException.h>
using namespace ITAPropagationPathSim::AtmosphericRayTracing;
using namespace ITAPropagationPathSim::AtmosphericRayTracing::EigenraySearch;
......@@ -9,29 +11,61 @@ void CRayResolutionAdapter::Reset(const CRayGrid& rayGrid)
vpNewRaysOfLastAdaptation.clear();
}
bool CRayResolutionAdapter::ZoomIntoRay(const std::shared_ptr<CRay>& pRay)
void CRayResolutionAdapter::ZoomIntoRay(const std::shared_ptr<CRay>& pRay)
{
vpNewRaysOfLastAdaptation.clear();
if(NRays() <= 1|| !Contains(pRay))
return false;
if(!Contains(pRay) /*|| NRays() <= 1*/)
ITA_EXCEPT_INVALID_PARAMETER("Given ray is not part of the adapted grid.");
SetToSurroundingGrid(pRay);
DoubleRayResolution();
}
void CRayResolutionAdapter::ZoomIntoRay(const std::shared_ptr<CRay>& pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold)
{
if (!Contains(pRay) /*|| NRays() <= 1*/)
ITA_EXCEPT_INVALID_PARAMETER("Given ray is not part of the adapted grid.");
SetToSurroundingGrid(pRay);
SetAdvancedRayGridLimits(pRay, idxMinDist, receiverPosition, threshold);
DoubleRayResolution();
return true;
}
void CRayResolutionAdapter::SetAdvancedRayGridLimits(const std::shared_ptr<CRay>& pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold)
{
if (NPhi() > 3) // There can be more than three rays if pRay is located at a pole
return;
std::vector<int> thetaIdxVec = FindAdvancedRayGridLimits1D( GetRaysWithSameTheta(pRay), idxMinDist, receiverPosition, threshold );
std::vector<int> phiIdxVec = FindAdvancedRayGridLimits1D( GetRaysWithSamePhi(pRay), idxMinDist, receiverPosition, threshold );
FilterDirections(thetaIdxVec, phiIdxVec);
}
std::vector<int> CRayResolutionAdapter::FindAdvancedRayGridLimits1D(const std::vector<std::shared_ptr<CRay>>& rayVector, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold) const
{
if (rayVector.size() == 1)
return { 0 };
if (rayVector.size() == 2)
return {0, 1};
if (rayVector.size() != 3)
ITA_EXCEPT_INVALID_PARAMETER("Expected a vector with one to three rays.");
const std::shared_ptr<CRay>& pRayMin = rayVector[1];
const std::shared_ptr<CRay>& pRay1 = rayVector[0];
const std::shared_ptr<CRay>& pRay2 = rayVector[2];
const double tMin = pRayMin->at(idxMinDist).timeStamp;
VistaVector3D v1 = (receiverPosition - pRay1->AtTime(tMin).position).GetNormalized();
VistaVector3D v2 = (receiverPosition - pRay2->AtTime(tMin).position).GetNormalized();
VistaVector3D vMin = (receiverPosition - pRayMin->at(idxMinDist).position).GetNormalized();
//void CRayResolutionAdapter::AdvancedRayZooming(const std::shared_ptr<CRay>& pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold)
//{
//
//}
//
//void CRayResolutionAdapter::FindZoomRays(const std::vector< std::shared_ptr<CRay> >& pRays, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold)
//{
//
//}
const float vProd1 = v1.Dot(vMin);
const float vProd2 = v2.Dot(vMin);
if (std::abs(vProd1 - vProd2) < threshold)
return {0, 1, 2};
if (vProd1 < vProd2)
return {0, 1};
return {1, 2};
}
void CRayResolutionAdapter::DoubleRayResolution()
{
......
......@@ -43,12 +43,28 @@ namespace ITAPropagationPathSim
const std::vector< std::shared_ptr<CRay> >& Rays() { return CRayGrid::Rays(); }
const std::vector< std::shared_ptr<CRay> >& NewRaysOfLastAdaptation() { return vpNewRaysOfLastAdaptation; }
bool ZoomIntoRay(const std::shared_ptr<CRay>& pRay);
//bool ZoomIntoRay(const std::shared_ptr<CRay>& pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold);
//! Simple adaptation method: Setting the limits to neighboring rays and shoots additional rays to double the angular resolution of the grid.
void ZoomIntoRay(const std::shared_ptr<CRay>& pRay);
//! Advanced adaptation method: Further reduces the angular limits using additional information compared to simple method before doubling the angular resolution.
void ZoomIntoRay(const std::shared_ptr<CRay>& pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold);
private:
void AdvancedRayZooming(const std::shared_ptr<CRay>& pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold);
void FindZoomRays(const std::vector< std::shared_ptr<CRay> >& pRays, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold);
//! Further reduces the limits of the ray grid using additional information on given rays and the receiver position
/**
* If the original ray grid looks like the sketch below where r5 is the ray with minimum distance to the receiver,
* this will decide whether the eigenray is rather above/below and left/right of it. In best case, the number of rays is reduced from 9 to 4.
*
* r1--------r2----------r3
* | c1 / c2 \
* r4------r5-------------r6
* \ c3 \ c4 /
* r7------r8--------r9
*
* Also works for a 1D ray grid (NTheta == 1 or NPhi() == 1)
*/
void SetAdvancedRayGridLimits(const std::shared_ptr<CRay>& pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold);
//! By comparing the vector from three rays to the receiver, this decides between which two rays the eigenray is located and returns their indices
std::vector<int> FindAdvancedRayGridLimits1D(const std::vector< std::shared_ptr<CRay> >& pRays, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold) const;
void DoubleRayResolution();
std::vector<double> DoubleAngularResolution(const std::vector<double>& angleVector) const;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment