Skip to content

Commit 25649aa

Browse files
committed
util fn
1 parent 21665bb commit 25649aa

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

queries/MeshQueries.cs

+24
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,30 @@ public static double NearestPointDistance(DMesh3 mesh, ISpatial spatial, Vector3
5454
}
5555

5656

57+
58+
/// <summary>
59+
/// find distance between two triangles, with optional
60+
/// transform on second triangle
61+
/// </summary>
62+
public static DistTriangle3Triangle3 TriangleTriangleDistance(DMesh3 mesh1, int ti, DMesh3 mesh2, int tj, Func<Vector3d, Vector3d> TransformF = null)
63+
{
64+
if (mesh1.IsTriangle(ti) == false || mesh2.IsTriangle(tj) == false)
65+
return null;
66+
Triangle3d tri1 = new Triangle3d(), tri2 = new Triangle3d();
67+
mesh1.GetTriVertices(ti, ref tri1.V0, ref tri1.V1, ref tri1.V2);
68+
mesh2.GetTriVertices(tj, ref tri2.V0, ref tri2.V1, ref tri2.V2);
69+
if (TransformF != null) {
70+
tri2.V0 = TransformF(tri2.V0);
71+
tri2.V1 = TransformF(tri2.V1);
72+
tri2.V2 = TransformF(tri2.V2);
73+
}
74+
DistTriangle3Triangle3 dist = new DistTriangle3Triangle3(tri1, tri2);
75+
dist.Compute();
76+
return dist;
77+
}
78+
79+
80+
5781
/// <summary>
5882
/// convenience function to construct a IntrRay3Triangle3 object for a mesh triangle
5983
/// </summary>

0 commit comments

Comments
 (0)