Skip to content

Commit

Permalink
Update to unit tests for curved venetians and unit normals in view fa…
Browse files Browse the repository at this point in the history
…ctors.
  • Loading branch information
vidanovic committed Nov 15, 2024
1 parent 81e9dae commit 9833966
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,39 +329,39 @@ TEST_F(MultiPaneBSDF_102_VenetianDirectional_n_Band_Material, TestBSDF1)
CMultiPaneBSDF & aLayer = getLayer();

const double tauDiff = aLayer.DiffDiff(minLambda, maxLambda, Side::Front, PropertySimple::T);
EXPECT_NEAR(0.358468, tauDiff, 1e-6);
EXPECT_NEAR(0.450879, tauDiff, 1e-6);

const double rhoDiff = aLayer.DiffDiff(minLambda, maxLambda, Side::Front, PropertySimple::R);
EXPECT_NEAR(0.108058, rhoDiff, 1e-6);
EXPECT_NEAR(0.353426, rhoDiff, 1e-6);

const double absDiff1 = aLayer.AbsDiff(minLambda, maxLambda, Side::Front, 1);
EXPECT_NEAR(0.136506, absDiff1, 1e-6);
EXPECT_NEAR(0.137116, absDiff1, 1e-6);

const double absDiff2 = aLayer.AbsDiff(minLambda, maxLambda, Side::Front, 2);
EXPECT_NEAR(0.058649, absDiff2, 1e-6);
EXPECT_NEAR(0.058579, absDiff2, 1e-6);

const double theta = 0;
const double phi = 0;

const double tauHem =
aLayer.DirHem(minLambda, maxLambda, Side::Front, PropertySimple::T, theta, phi);
EXPECT_NEAR(0.524285, tauHem, 1e-6);
EXPECT_NEAR(0.523116, tauHem, 1e-6);

const double tauDir =
aLayer.DirDir(minLambda, maxLambda, Side::Front, PropertySimple::T, theta, phi);
EXPECT_NEAR(0.415503, tauDir, 1e-6);
EXPECT_NEAR(0.415499, tauDir, 1e-6);

const double rhoHem =
aLayer.DirHem(minLambda, maxLambda, Side::Front, PropertySimple::R, theta, phi);
EXPECT_NEAR(0.334203, rhoHem, 1e-6);
EXPECT_NEAR(0.334675, rhoHem, 1e-6);

const double rhoDir =
aLayer.DirDir(minLambda, maxLambda, Side::Front, PropertySimple::R, theta, phi);
EXPECT_NEAR(0.025928, rhoDir, 1e-6);

const double abs1 = aLayer.Abs(minLambda, maxLambda, Side::Front, 1, theta, phi);
EXPECT_NEAR(0.082066, abs1, 1e-6);
EXPECT_NEAR(0.082908, abs1, 1e-6);

const double abs2 = aLayer.Abs(minLambda, maxLambda, Side::Front, 2, theta, phi);
EXPECT_NEAR(0.059447, abs2, 1e-6);
EXPECT_NEAR(0.059301, abs2, 1e-6);
}
Original file line number Diff line number Diff line change
Expand Up @@ -351,39 +351,39 @@ TEST_F(MultiPaneBSDF_102_VenetianDirectional_n_Band_Material_Condensed, TestBSDF
CMultiPaneBSDF & aLayer = getLayer();

const double tauDiff = aLayer.DiffDiff(minLambda, maxLambda, Side::Front, PropertySimple::T);
EXPECT_NEAR(0.700846, tauDiff, 1e-6);
EXPECT_NEAR(0.701633, tauDiff, 1e-6);

const double rhoDiff = aLayer.DiffDiff(minLambda, maxLambda, Side::Front, PropertySimple::R);
EXPECT_NEAR(0.130002, rhoDiff, 1e-6);
EXPECT_NEAR(0.136723, rhoDiff, 1e-6);

const double absDiff1 = aLayer.AbsDiff(minLambda, maxLambda, Side::Front, 1);
EXPECT_NEAR(0.071834, absDiff1, 1e-6);
EXPECT_NEAR(0.064227, absDiff1, 1e-6);

const double absDiff2 = aLayer.AbsDiff(minLambda, maxLambda, Side::Front, 2);
EXPECT_NEAR(0.097319, absDiff2, 1e-6);
EXPECT_NEAR(0.097417, absDiff2, 1e-6);

const double theta = 0;
const double phi = 0;

const double tauHem =
aLayer.DirHem(minLambda, maxLambda, Side::Front, PropertySimple::T, theta, phi);
EXPECT_NEAR(0.778732, tauHem, 1e-6);
EXPECT_NEAR(0.779177, tauHem, 1e-6);

const double tauDir =
aLayer.DirDir(minLambda, maxLambda, Side::Front, PropertySimple::T, theta, phi);
EXPECT_NEAR(0.778663, tauDir, 1e-6);
EXPECT_NEAR(0.778669, tauDir, 1e-6);

const double rhoHem =
aLayer.DirHem(minLambda, maxLambda, Side::Front, PropertySimple::R, theta, phi);
EXPECT_NEAR(0.065530, rhoHem, 1e-6);
EXPECT_NEAR(0.072179, rhoHem, 1e-6);

const double rhoDir =
aLayer.DirDir(minLambda, maxLambda, Side::Front, PropertySimple::R, theta, phi);
EXPECT_NEAR(0.065426, rhoDir, 1e-6);
EXPECT_NEAR(0.065510, rhoDir, 1e-6);

const double abs1 = aLayer.Abs(minLambda, maxLambda, Side::Front, 1, theta, phi);
EXPECT_NEAR(0.067492, abs1, 1e-6);
EXPECT_NEAR(0.060343, abs1, 1e-6);

const double abs2 = aLayer.Abs(minLambda, maxLambda, Side::Front, 2, theta, phi);
EXPECT_NEAR(0.088246, abs2, 1e-6);
EXPECT_NEAR(0.088301, abs2, 1e-6);
}
14 changes: 3 additions & 11 deletions src/SingleLayerOptics/src/VenetianSegments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace SingleLayerOptics

namespace Helper
{
// In case of outgoing front and incoming back, unit vector need to be inversed.
// In case of outgoing front and incoming back, unit vector need to be inverse.
Viewer::CSegment2D unitVector(const CBeamDirection & t_Direction,
const BSDFDirection t_BSDFDirection,
const Side t_Side)
Expand Down Expand Up @@ -156,17 +156,9 @@ namespace SingleLayerOptics
double aResult = 0;
for(size_t i = 0; i < slatRadiances.size(); ++i)
{
const auto & segment = slats[i];

auto testRadiance = slatRadiances[i];
auto testVisibleFraction = visibleFraction[i];
auto testLength = segment.length();
auto testSurfaceNormal = segment.surfaceUnitNormal();
auto testDotProduct = segment.surfaceUnitNormal().dotProduct(outgoingUnitVector.endPoint());

aResult +=
visibleFraction[i] * slatRadiances[i] * segment.length()
* std::abs(segment.surfaceUnitNormal().dotProduct(outgoingUnitVector.endPoint()));
visibleFraction[i] * slatRadiances[i] * slats[i].length()
* std::abs(slats[i].surfaceUnitNormal().dotProduct(outgoingUnitVector.endPoint()));
}

return aResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ TEST_F(TestVenetianCellCurved55_1, TestVenetian2)
Tdir_dif = aCell->T_dir_dif(aSide, aDirection, outDirection);
Rdir_dif = aCell->R_dir_dif(aSide, aDirection, outDirection);

EXPECT_NEAR(0.085068844915552735, Tdir_dif, 1e-6);
EXPECT_NEAR(0.19224309643794207, Rdir_dif, 1e-6);
EXPECT_NEAR(0.074890457852183318, Tdir_dif, 1e-6);
EXPECT_NEAR(0.19781642870300131, Rdir_dif, 1e-6);

// Back side
aSide = Side::Back;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ TEST(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat0_nSegments2_Rise
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.1_Slat=0_nSegments=2_Rise=3.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTb_T=0_R=0.1_Slat=0_nSegments=2_Rise=3.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRb_T=0_R=0.1_Slat=0_nSegments=2_Rise=3.csv",
true
false
);
}

Expand All @@ -252,7 +252,7 @@ TEST(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat0_nSegments5_Rise
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTb_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRb_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv",
true
false
);
}

Expand All @@ -267,7 +267,7 @@ TEST(TestVenetianDirectionalMatrix, Configuration2_T0_R0_15_Slat45_nSegments5_Ri
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTb_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRb_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
true
false
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ TEST_F(TestVenetianDirectionalShadeCurvedMinus45_0, TestVenetian1)
BSDFIntegrator aResults = aShade->getResults();

double tauDiff = aResults.DiffDiff(Side::Front, PropertySimple::T);
EXPECT_NEAR(0.51004483165182746, tauDiff, 1e-6);
EXPECT_NEAR(0.395816, tauDiff, 1e-6);

double RfDiff = aResults.DiffDiff(Side::Front, PropertySimple::R);
EXPECT_NEAR(0.52127289710024438, RfDiff, 1e-6);
EXPECT_NEAR(0.562219, RfDiff, 1e-6);
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ TEST_F(TestVenetianUniformMatrix, Configuration1_T0_R0_1_Slat0_nSegments5_Rise3)
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv",
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTb_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv",
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRb_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv",
true
false
);
}

Expand All @@ -197,7 +197,7 @@ TEST_F(TestVenetianUniformMatrix, Configuration2_T0_R0_15_Slat45_nSegments5_Rise
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTb_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRb_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
true
false
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Viewer/tst/units/Segment2D.unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TEST_F(TestSegment2D, Segment2DTest1)
EXPECT_NEAR(0, angle, 1e-6);

const auto surfaceNormal{aSegment.surfaceUnitNormal()};
const CPoint2D correctSurfaceNormal{0.0, -1.0};
const CPoint2D correctSurfaceNormal{0.0, 1.0};

EXPECT_TRUE(correctSurfaceNormal == surfaceNormal);
}
Expand All @@ -51,7 +51,7 @@ TEST_F(TestSegment2D, Segment2DTest2)
EXPECT_NEAR(45, angle, 1e-6);

const auto surfaceNormal{aSegment.surfaceUnitNormal()};
const CPoint2D correctSurfaceNormal{-0.7071067811865476, 0.7071067811865476};
const CPoint2D correctSurfaceNormal{0.7071067811865476, -0.7071067811865476};

EXPECT_TRUE(correctSurfaceNormal == surfaceNormal);
}
Expand All @@ -70,7 +70,7 @@ TEST_F(TestSegment2D, Segment2DTest3)
EXPECT_NEAR(45, angle, 1e-6);

const auto surfaceNormal{aSegment.surfaceUnitNormal()};
const CPoint2D correctSurfaceNormal{0.7071067811865476, -0.7071067811865476};
const CPoint2D correctSurfaceNormal{-0.7071067811865476, 0.7071067811865476};

EXPECT_TRUE(correctSurfaceNormal == surfaceNormal);
}
Expand All @@ -89,7 +89,7 @@ TEST_F(TestSegment2D, Segment2DTest4)
EXPECT_NEAR(45, angle, 1e-6);

const auto surfaceNormal{aSegment.surfaceUnitNormal()};
const CPoint2D correctSurfaceNormal{0.7071067811865476, -0.7071067811865476};
const CPoint2D correctSurfaceNormal{-0.7071067811865476, 0.7071067811865476};

EXPECT_TRUE(correctSurfaceNormal == surfaceNormal);
}

0 comments on commit 9833966

Please sign in to comment.