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

Method TestProjection

source/MRDotNet2Test/src/MeshTests.cs:311–339  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

309 }
310
311 [Test]
312 public void TestProjection()
313 {
314 var p = new Vector3f(1, 2, 3);
315 var mesh = makeSphere(new SphereParams(1.0f, 1000));
316 var projRes = findProjection(p, mesh);
317 Assert.That(projRes.distSq, Is.EqualTo(7.529f).Within(1e-3));
318
319 Assert.That(projRes.proj.face.id, Is.EqualTo(904));
320 Assert.That(projRes.proj.point.x, Is.EqualTo(0.310).Within(1e-3));
321 Assert.That(projRes.proj.point.y, Is.EqualTo(0.507).Within(1e-3));
322 Assert.That(projRes.proj.point.z, Is.EqualTo(0.803).Within(1e-3));
323
324 Assert.That(projRes.mtp.e.id, Is.EqualTo(1640));
325 Assert.That(projRes.mtp.bary.a, Is.EqualTo(0.053).Within(1e-3));
326 Assert.That(projRes.mtp.bary.b, Is.EqualTo(0.946).Within(1e-3));
327
328 var xf = AffineXf3f.translation(Vector3f.diagonal(1.0f));
329 projRes = findProjection(p, mesh, float.MaxValue, xf);
330
331 Assert.That(projRes.proj.face.id, Is.EqualTo(632));
332 Assert.That(projRes.proj.point.x, Is.EqualTo(1.000).Within(1e-3));
333 Assert.That(projRes.proj.point.y, Is.EqualTo(1.439).Within(1e-3));
334 Assert.That(projRes.proj.point.z, Is.EqualTo(1.895).Within(1e-3));
335
336 Assert.That(projRes.mtp.e.id, Is.EqualTo(1898));
337 Assert.That(projRes.mtp.bary.a, Is.EqualTo(0.5).Within(1e-3));
338 Assert.That(projRes.mtp.bary.b, Is.EqualTo(0.0).Within(1e-3));
339 }
340
341 [Test]
342 public void TestMeshMeshDistance()

Callers

nothing calls this directly

Calls 4

makeSphereFunction · 0.85
findProjectionFunction · 0.85
translationMethod · 0.80
diagonalMethod · 0.45

Tested by

no test coverage detected