# How to check that these triangles are exactly the same triangle?

I have $$6$$ triangle:

tris = Triangle/@Permutations[{{0,0,0},{1,0,0},{0,1,1}}]

They are in every sense the same triangle. But how to check that these triangles are exactly the same triangle? And I note Equal @@ tris and SameQ @@ tris both cannot do this.

Furthermore, none of the current methods (comments and answers) seem to be able to tell if the following six triangles(tris2) are the same triangle:

Clear["`*"]
sol = Solve[{x1^2/16 + 9 y1^2 == 1, x2^2/16 + 9 y2^2 == 1,
x3^2/16 + 9 y3^2 ==
1, (x1 - x2)^2 + (y1 - y2)^2 == (x1 - x3)^2 + (y1 -
y3)^2 == (x2 - x3)^2 + (y2 - y3)^2, (143 Sin[1/2])/1299 ==
1/3 (y1 + y2 + y3), 572/147 Cos[1/2] == 1/3 (x1 + x2 + x3)}, {x1,
y1, x2, y2, x3, y3}];
tris2 = Triangle[{{x1, y1}, {x2, y2}, {x3, y3}}] /. sol
• Hack: Equal @@ (tris /. Triangle[x__] :> Triangle[Sort[x]])
– Syed
Aug 3, 2023 at 12:20
• @Syed Check my update, thanks.
– yode
Aug 3, 2023 at 12:30
• Please see the screenshot. I am on v12.2.0 on Win7-x64.
– Syed
Aug 3, 2023 at 12:41
• "They are in every sense the same triangle" isn't true! The orientation (normal vector) is different I think. Aug 4, 2023 at 7:35

Use RegionEqual.

RegionEqual @@ tris
(* True *)

If triangle coordinates are complicated symbolic expressions for which Mathematica cannot determine the equality, you can numericize them.

RegionEqual @@ N[tris2]
(* True *)
• Thanks, check my update. Maybe the RegionEqual have a bug.
– yode
Aug 3, 2023 at 12:30
• @yode There's no bug, the expressions are just too complicated for Equal to check that they are actually equal. If you use N to get approximations you'll see RegionEqual works. Aug 3, 2023 at 12:42

We may define a helper function that calculates the length of the sides:

sides[tri_] :=
Norm /@ {tri[[1, 1]] - tri[[1, 2]], tri[[1, 2]] - tri[[1, 3]],
tri[[1, 3]] - tri[[1, 1]]}

With this we may define a check function that checks for equality:

check[triangles_] := AllTrue[Sort /@ sides /@ N@triangles, Equal]

For a test:

check[tris]

True

And

check[tris2]

True

I have voted for other answers.

Just a visualization:

f[x_, y_] := x^2/16 + 9 y^2 - 1
cp = ContourPlot[f[x, y] == 0, {x, -5, 5}, {y, -1, 1}];

Using sol from OP:

tr = Triangle[{{x1, y1}, {x2, y2}, {x3, y3}}] /. sol // N;
rad = (Sqrt[(x1 - x2)^2 + (y1 - y2)^2] /. sol // N)[[1]];
circ = {Red, Circle[{x1, y1}, rad]} /. sol // N;

The three circle intersections define a unique triangle. The last constraints in the Solve provide the radius.

Show[cp, Graphics[{tr, circ}], AspectRatio -> Automatic]