Skip to content

Commit 603226c

Browse files
committed
MeshFeatureTests.assertTriangleEquality: javadoc
It's a complicated method, so it's worthwhile to document the need and rationale
1 parent a708ff0 commit 603226c

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

scijava-ops-image/src/test/java/org/scijava/ops/image/geom/geom3d/MeshFeatureTests.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,35 @@ public void testVoxelization3D() {
200200
// https://github.com/imagej/imagej-ops/issues/422
201201
}
202202

203+
/**
204+
* Determines whether two {@link Mesh} {@link Triangle}s are equivalent.
205+
* <p>
206+
* NB For two triangles to be the same, they must have:
207+
* <ol>
208+
* <li>The same three vertices</li>
209+
* <li>The same "front" side, which is determined by the normal and the
210+
* vertex ordering</li>
211+
* </ol>
212+
* </p>
213+
* <p>
214+
* Therefore, two triangles can be the same if:
215+
* <ol>
216+
* <li>They share the same normal {@code n} and vertices {@code (v1, v2, v3)},
217+
* with identical ordering</li>
218+
* <li>They share the same normal and vertices {@code (v1, v2, v3)}, but one
219+
* triangle orders them {@code (v1, v2, v3)} and the other {@code (v2, v3, v1)}</li>
220+
* <li>One has vertices {@code (v1, v2, v3)} and normal {@code n}, and the other
221+
* vertices {@code (v1, v3, v2)} and normal {@code -n}</li>
222+
* <li>A combination of the first two cases (inverse normal, opposite
223+
* ordering, <b>and</b> offset ordering)</li>
224+
* </ol>
225+
* </p>
226+
* This method covers all of those cases.
227+
*
228+
* @param exp the expected {@link Triangle}
229+
* @param act the actual {@link Triangle}
230+
* @param eps the allowed error in equality checks
231+
*/
203232
private static void assertTriangleEquality( //
204233
final Triangle exp, //
205234
final Triangle act, //

0 commit comments

Comments
 (0)