From 24d2a64abbc34cf16adfba2c1e74cc6d2ee53036 Mon Sep 17 00:00:00 2001 From: kradchen Date: Tue, 16 May 2023 14:34:18 +0800 Subject: [PATCH] Add Reflection dataFilter --- src/reflectionReconstruction/dataFilter.cpp | 26 +++++++++++++++++++++ src/reflectionReconstruction/dataFilter.h | 15 ++++++++++++ test/DataFilter_Test.cpp | 16 +++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/reflectionReconstruction/dataFilter.cpp create mode 100644 src/reflectionReconstruction/dataFilter.h diff --git a/src/reflectionReconstruction/dataFilter.cpp b/src/reflectionReconstruction/dataFilter.cpp new file mode 100644 index 0000000..7915a2b --- /dev/null +++ b/src/reflectionReconstruction/dataFilter.cpp @@ -0,0 +1,26 @@ +#include "dataFilter.h" +#include "Function1D.h" +#include "Function2D.h" +#include "Function3D.h" + +#define PI 3.141592653589793238462 +using namespace Aurora; +namespace Recon { +Matrix filterReflectionData(const Matrix &aVReceiverPositionBlock, + const Matrix &aVSenderPositionBlock, + const Matrix &aVSenderNormalBlock, + int aConstrictReflectionAngles, + double aAngleLowerLimit, double aAngleUpperLimit) { + auto reflectData = ones(1, aVReceiverPositionBlock.getDimSize(1)); + if (aConstrictReflectionAngles == 1) { + auto positionDifs = aVReceiverPositionBlock - aVSenderPositionBlock; + auto inbetweenAngle = acos(dot(aVSenderNormalBlock, positionDifs) / + vecnorm(positionDifs, Norm2, 1)); + auto flags = Aurora::auroraNot((inbetweenAngle < (PI * aAngleLowerLimit / 180)) + + (inbetweenAngle > (PI * aAngleUpperLimit / 180))); + reflectData = reflectData * flags; + } + return reflectData; +} + +} // namespace Recon \ No newline at end of file diff --git a/src/reflectionReconstruction/dataFilter.h b/src/reflectionReconstruction/dataFilter.h new file mode 100644 index 0000000..82efb75 --- /dev/null +++ b/src/reflectionReconstruction/dataFilter.h @@ -0,0 +1,15 @@ +#ifndef __REF_DATAFILTER_H__ +#define __REF_DATAFILTER_H__ + +#include "Matrix.h" +namespace Recon { + Aurora::Matrix filterReflectionData(const Aurora::Matrix &aVReceiverPositionBlock, + const Aurora::Matrix &aVSenderPositionBlock, + const Aurora::Matrix &aVSenderNormalBlock, + int aConstrictReflectionAngles, + double aAngleLowerLimit, + double aAngleUpperLimit); +} + + +#endif // __DATAFILTER_H__ \ No newline at end of file diff --git a/test/DataFilter_Test.cpp b/test/DataFilter_Test.cpp index 1ac2b6e..1aea8f1 100644 --- a/test/DataFilter_Test.cpp +++ b/test/DataFilter_Test.cpp @@ -4,8 +4,11 @@ #include "Function1D.h" #include "MatlabReader.h" #include "Matrix.h" +#include "reflectionReconstruction/dataFilter.h" #include "transmissionReconstruction/dataFilter/dataFilter.h" + + inline double fourDecimalRound(double src){ return round(src*10000.0)/10000.0; } @@ -114,4 +117,17 @@ TEST_F(DataFilter_Test, findDefectTransmissionData) { } } +TEST_F(DataFilter_Test, filterReflectionData) { + auto receiverPositionBlock = Aurora::transpose(Aurora::Matrix::fromRawData(new double[9]{-0.12,-0.12,-0.12,-0.01,-0.01,-0.01,0.03,0.03,0.04}, 3, 3)); + auto senderPositionBlock = Aurora::transpose(Aurora::Matrix::fromRawData(new double[9]{-0.12,-0.12,-0.12,-0.01,-0.01,-0.01,0.03,0.03,0.03}, 3, 3)); + auto senderNormalBlock = Aurora::transpose(Aurora::Matrix::fromRawData(new double[9]{0.99,0.99,0.99,0.10,0.10,0.10,0,0,0}, 3, 3)); + int constrictReflectionAngles = 1; + double lowerAngle = 45; + double upperAngle = 360; + auto result = Recon::filterReflectionData(receiverPositionBlock, senderPositionBlock, senderNormalBlock, constrictReflectionAngles, lowerAngle, upperAngle); + EXPECT_EQ(3, result.getDataSize()); + EXPECT_DOUBLE_AE(result[0],1); + EXPECT_DOUBLE_AE(result[1],1); + EXPECT_DOUBLE_AE(result[2],1); +}