-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend room rotations with 4 more transformations. It is now possible…
… to choose exactly which transformations can be applied to a given room shape.
- Loading branch information
1 parent
764a498
commit 8c9c5be
Showing
20 changed files
with
621 additions
and
71 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
GeneralAlgorithms.Tests/DataStructures/Common/IntVector2Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace GeneralAlgorithms.Tests.DataStructures.Common | ||
{ | ||
using GeneralAlgorithms.DataStructures.Common; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class IntVector2Tests | ||
{ | ||
[Test] | ||
public void Transform_CorrectlyTransforms() | ||
{ | ||
var point = new IntVector2(1, 2); | ||
|
||
Assert.That(point.Transform(Transformation.Identity), Is.EqualTo(new IntVector2(1, 2))); | ||
Assert.That(point.Transform(Transformation.Rotate90), Is.EqualTo(new IntVector2(2, -1))); | ||
Assert.That(point.Transform(Transformation.Rotate180), Is.EqualTo(new IntVector2(-1, -2))); | ||
Assert.That(point.Transform(Transformation.Rotate270), Is.EqualTo(new IntVector2(-2, 1))); | ||
Assert.That(point.Transform(Transformation.MirrorX), Is.EqualTo(new IntVector2(1, -2))); | ||
Assert.That(point.Transform(Transformation.MirrorY), Is.EqualTo(new IntVector2(-1, 2))); | ||
Assert.That(point.Transform(Transformation.Diagonal13), Is.EqualTo(new IntVector2(2, 1))); | ||
Assert.That(point.Transform(Transformation.Diagonal24), Is.EqualTo(new IntVector2(-2, -1))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
GeneralAlgorithms/Algorithms/Common/TransformationHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace GeneralAlgorithms.Algorithms.Common | ||
{ | ||
using System; | ||
using DataStructures.Common; | ||
|
||
public static class TransformationHelper | ||
{ | ||
public static Transformation[] GetAllTransforamtion() | ||
{ | ||
return (Transformation[]) Enum.GetValues(typeof(Transformation)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace GeneralAlgorithms.DataStructures.Common | ||
{ | ||
public enum Transformation | ||
{ | ||
Identity, | ||
Rotate90, Rotate180, Rotate270, // Rotations are clockwise | ||
MirrorX, MirrorY, | ||
Diagonal13, Diagonal24 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.