diff --git a/Bonk/Simplex.cs b/Bonk/Simplex.cs index e30c1fa..60a62fd 100644 --- a/Bonk/Simplex.cs +++ b/Bonk/Simplex.cs @@ -1,5 +1,4 @@ -using System.Linq; -using System.Collections.Generic; +using System.Collections.Generic; using System.Numerics; using MoonTools.Core.Structs; using System; @@ -80,11 +79,15 @@ namespace MoonTools.Core.Bonk public bool Equals(Simplex2D other) { - var q = from a in Vertices - join b in other.Vertices on a equals b - select a; + if (Count != other.Count) { return false; } - return Count == other.Count && q.Count() == Count; + return + (A == other.A && B == other.B && C == other.C) || + (A == other.A && B == other.C && C == other.B) || + (A == other.B && B == other.A && C == other.C) || + (A == other.B && B == other.C && C == other.A) || + (A == other.C && B == other.A && C == other.B) || + (A == other.C && B == other.B && C == other.A); } public override int GetHashCode() diff --git a/Test/Equality.cs b/Test/Equality.cs index e69c9e5..d441c83 100644 --- a/Test/Equality.cs +++ b/Test/Equality.cs @@ -455,14 +455,26 @@ namespace Tests public void TwoSimplexEquals() { var simplexA = new Simplex2D(Vector2.One, Vector2.Zero, Vector2.UnitX); + var simplexB = new Simplex2D(Vector2.One, Vector2.Zero, Vector2.UnitX); simplexA.Equals(simplexB).Should().BeTrue(); - var simplexC = new Simplex2D(Vector2.One, Vector2.Zero, Vector2.UnitX); - var simplexD = new Simplex2D(Vector2.Zero, Vector2.One, Vector2.UnitX); + var simplexC = new Simplex2D(Vector2.Zero, Vector2.One, Vector2.UnitX); - simplexC.Equals(simplexD).Should().BeTrue(); + simplexA.Equals(simplexC).Should().BeTrue(); + + var simplexD = new Simplex2D(Vector2.UnitX, Vector2.Zero, Vector2.One); + + simplexA.Equals(simplexD).Should().BeTrue(); + + var simplexE = new Simplex2D(Vector2.One, Vector2.UnitX, Vector2.Zero); + + simplexA.Equals(simplexE).Should().BeTrue(); + + var simplexF = new Simplex2D(Vector2.Zero, Vector2.UnitX, Vector2.One); + + simplexA.Equals(simplexF).Should().BeTrue(); } [Test]