MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / TEST

Function TEST

source/MRTest/MRDipoleTests.cpp:25–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25TEST(MRMesh, TriangleSolidAngle)
26{
27 const Triangle3f tri =
28 {
29 Vector3f{ 0.0f, 0.0f, 0.0f },
30 Vector3f{ 1.0f, 0.0f, 0.0f },
31 Vector3f{ 0.0f, 1.0f, 0.0f }
32 };
33 const auto c = ( tri[0] + tri[1] + tri[2] ) / 3.0f;
34
35 // solid angle near triangle center abruptly changes from -2pi to 2pi when the point crosses the triangle plane
36 const auto x = triangleSolidAngle( c + Vector3f( 0, 0, 1e-5f ), tri );
37 EXPECT_NEAR( x, -2 * PI_F, 1e-3f );
38 auto y = triangleSolidAngle( c - Vector3f( 0, 0, 1e-5f ), tri );
39 EXPECT_NEAR( y, 2 * PI_F, 1e-3f );
40
41 // solid angle in triangle vertices is equal to zero exactly
42 for ( int i = 0; i < 3; ++i )
43 {
44 EXPECT_EQ( triangleSolidAngle( tri[i], tri ), 0 );
45 }
46
47 // solid angle in the triangle plane outside of triangle is equal to zero exactly
48 EXPECT_EQ( triangleSolidAngle( tri[1] + tri[2], tri ), 0 );
49 EXPECT_EQ( triangleSolidAngle( -tri[1], tri ), 0 );
50 EXPECT_EQ( triangleSolidAngle( -tri[2], tri ), 0 );
51}
52
53} //namespace MR

Callers

nothing calls this directly

Calls 1

triangleSolidAngleFunction · 0.70

Tested by

no test coverage detected