Commit 3a55471d authored by Philipp Schäfer's avatar Philipp Schäfer

ART - AdaptiveRayGrid

- advanced ray zooming now gets idxMin from ray directly
- changed some variable names
parent c0cd7ae7
......@@ -58,7 +58,7 @@ namespace ITAPropagationPathSim
//! 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);
void ZoomIntoRay(const std::shared_ptr<CRay> pRay, const VistaVector3D& v3ReceiverPosition, const double& dThreshold);
//! Zooms into the given ray using a specific angular resolution by creating up to 8 new rays surrounding the given one.
void ZoomIntoRay(const std::shared_ptr<CRay> pRay, const double& deltaTheta, const double& deltaPhi);
......
......@@ -56,13 +56,17 @@ void CAdaptiveRayGrid::ZoomIntoRay(const std::shared_ptr<CRay> pRay)
DoubleRayResolution();
}
void CAdaptiveRayGrid::ZoomIntoRay(const std::shared_ptr<CRay> pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold)
void CAdaptiveRayGrid::ZoomIntoRay(const std::shared_ptr<CRay> pRay, const VistaVector3D& v3ReceiverPosition, const double& dThreshold)
{
if (!Contains(pRay))
ITA_EXCEPT_INVALID_PARAMETER("Given ray is not part of the adapted grid.");
const CRayReceiverData* receiverData = pRay->ReceiverDistanceData(v3ReceiverPosition);
if(!receiverData)
ITA_EXCEPT_INVALID_PARAMETER("Given ray has no data about given receiver.");
SetToSurroundingGrid(pRay);
SetAdvancedRayGridLimits(pRay, idxMinDist, receiverPosition, threshold);
SetAdvancedRayGridLimits(pRay, receiverData->idxMinDist, v3ReceiverPosition, dThreshold);
DoubleRayResolution();
}
......@@ -118,37 +122,37 @@ void CAdaptiveRayGrid::ZoomIntoRay(const std::shared_ptr<CRay> pZoomRay, const d
#pragma endregion
#pragma region NEW RAY LIMITS - private
void CAdaptiveRayGrid::SetAdvancedRayGridLimits(const std::shared_ptr<CRay> pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold)
void CAdaptiveRayGrid::SetAdvancedRayGridLimits(const std::shared_ptr<CRay> pRay, const int idxMinDist, const VistaVector3D& v3ReceiverPosition, const double& dThreshold)
{
if (NPhi() > 3) // There can be more than three rays if pRay is located at a pole
return;
std::vector<int> phiIdxVec = FindAdvancedRayGridLimits1D( GetRaysWithSameTheta(pRay), idxMinDist, receiverPosition, threshold );
std::vector<int> thetaIdxVec = FindAdvancedRayGridLimits1D( GetRaysWithSamePhi(pRay), idxMinDist, receiverPosition, threshold );
std::vector<int> phiIdxVec = FindAdvancedRayGridLimits1D( GetRaysWithSameTheta(pRay), idxMinDist, v3ReceiverPosition, dThreshold );
std::vector<int> thetaIdxVec = FindAdvancedRayGridLimits1D( GetRaysWithSamePhi(pRay), idxMinDist, v3ReceiverPosition, dThreshold );
FilterDirections(thetaIdxVec, phiIdxVec);
}
std::vector<int> CAdaptiveRayGrid::FindAdvancedRayGridLimits1D(const std::vector<std::shared_ptr<CRay>>& rayVector, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold) const
std::vector<int> CAdaptiveRayGrid::FindAdvancedRayGridLimits1D(const std::vector<std::shared_ptr<CRay>>& vpRayVector, const int idxMinDist, const VistaVector3D& v3ReceiverPosition, const double& dThreshold) const
{
if (rayVector.size() == 1)
if (vpRayVector.size() == 1)
return { 0 };
if (rayVector.size() == 2)
if (vpRayVector.size() == 2)
return {0, 1};
if (rayVector.size() != 3)
if (vpRayVector.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 std::shared_ptr<CRay>& pRayMin = vpRayVector[1];
const std::shared_ptr<CRay>& pRay1 = vpRayVector[0];
const std::shared_ptr<CRay>& pRay2 = vpRayVector[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();
VistaVector3D v1 = (v3ReceiverPosition - pRay1->AtTime(tMin).position).GetNormalized();
VistaVector3D v2 = (v3ReceiverPosition - pRay2->AtTime(tMin).position).GetNormalized();
VistaVector3D vMin = (v3ReceiverPosition - pRayMin->at(idxMinDist).position).GetNormalized();
const float vProd1 = v1.Dot(vMin);
const float vProd2 = v2.Dot(vMin);
if (std::abs(vProd1 - vProd2) < threshold)
if (std::abs(vProd1 - vProd2) < dThreshold)
return {0, 1, 2};
if (vProd1 < vProd2)
return {0, 1};
......
......@@ -226,21 +226,27 @@ void Test1DThetaGrid()
void TestAdvancedRayZooming()
{
const auto sourcePos = VistaVector3D(0, 0, 1000);
const auto receiverPos = VistaVector3D(500, 0, 900);
CEquiangularRayDistribution rayGrid = CEquiangularRayDistribution(sourcePos, 7, 12);
const float dEnd = 1000.0;
const double tEnd = 10.0;
const int nPoints = 10;
for each (auto ray in rayGrid.UniqueRays())
for (int idxPoint = 1; idxPoint < nPoints; idxPoint++)
ray->Append(rayGrid.SourcePosition() + ray->InitialDirection() * dEnd*idxPoint/nPoints, ray->InitialDirection(), tEnd*idxPoint/nPoints);
for each (auto ray in rayGrid.UniqueRays())
{
for (int idxPoint = 1; idxPoint < nPoints; idxPoint++)
{
ray->Append(rayGrid.SourcePosition() + ray->InitialDirection() * dEnd * idxPoint / nPoints, ray->InitialDirection(), tEnd * idxPoint / nPoints);
ray->UpdateMinimumReceiverDistance(receiverPos);
}
ray->FinalizeMinimumReceiverDistances();
}
CAdaptiveRayGrid adaptiveRayGrid;
std::shared_ptr<CRay> pRay;
adaptiveRayGrid = CAdaptiveRayGrid(rayGrid);
const auto receiverPos = VistaVector3D(500, 0, 900);
pRay = rayGrid.At(3, 0);
adaptiveRayGrid.ZoomIntoRay(pRay, 5, receiverPos, 0.1);
adaptiveRayGrid.ZoomIntoRay(pRay, receiverPos, 0.1);
CheckAdaptedRayGrid(adaptiveRayGrid, 15, 15, 9);
}
......
Markdown is supported
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