Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Engine/Ascii3dEngine.Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="3.0.0" />
<PackageReference Include="YamlDotNet" Version="17.1.0" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions Engine/Support/MotionMatrix.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// This class holds information necessary to transformation point in 3D space
// The types of transformations that it supports are as follows
// - Scaling in 3 dimentions independently
// - Scaling in 3 dimensions independently
// - Rotating about each of the 3 axes independently
// - Translation to a different center in 3 dimentions independently
// - Translation to a different center in 3 dimensions independently
//
// This also has the ability to undo this transition, this allows us to take the intersection points that and map them back
// to where they should have landed without any of the transformation
//
// Some things to note
// Order of operations is important, we could have use 4d transformation matrixes
// Doing so that would allow us to simply apply each change to the matrix as given and we could undo them by computing the inverse matrix
// Commuting the inverse matrix of an arbitary 4x4 matrix should be doable (assuming it determinate is not 0, which this should not)
// Commuting the inverse matrix of an arbitrary 4x4 matrix should be doable (assuming it determinate is not 0, which this should not)
// But that can be computationally expensive.
// Plus b/c of order of operating matters it get tricky
// Basically translate laterally along the X axis, then rotate about the Y axis is very different if those operations are reversed
Expand Down
2 changes: 1 addition & 1 deletion TechDemo/Ascii3dEngine.TechDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Tests/Ascii3dEngine.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<!-- We could use MathNet.Numerics for more of our matrix math, but using it test to make sure our custom roll is at least correct -->
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.2.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.2.2" />
<PackageReference Include="MSTest.TestAdapter" Version="4.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="4.2.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions Tests/ColorUtilitesTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ascii3dEngine.Tests
{
[TestClass]
Expand Down
11 changes: 5 additions & 6 deletions Tests/MotionMatrixTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using MathNet.Numerics.LinearAlgebra.Double;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ascii3dEngine.Tests
{
[TestClass]
public class MotionMatrixTests
{
[TestMethod("Page 224 Practice Exercise 5.2.4 Build One - Understanding")]
[TestMethod(DisplayName = "Page 224 Practice Exercise 5.2.4 Build One - Understanding")]
public void Exercise_5_2_4_Understanding()
{
// The order of operations in the exercise are different
Expand Down Expand Up @@ -67,7 +66,7 @@ public void Exercise_5_2_4_Understanding()
TestUtilities.AssertVectorsAreEqual(expectedVector, result, delta: 0.001);
}

[TestMethod("Page 224 Practice Exercise 5.2.4 Build One - Code")]
[TestMethod(DisplayName = "Page 224 Practice Exercise 5.2.4 Build One - Code")]
public void Exercise_5_2_4_Code()
{
var radians = Utilities.DegreesToRadians(45);
Expand Down Expand Up @@ -114,7 +113,7 @@ public void Exercise_5_2_4_Code()
Assert.AreEqual(expectedPoint, actual);
}

[TestMethod("Page 228 Practice Exercise 5.2.22 Tow successive rotations")]
[TestMethod(DisplayName = "Page 228 Practice Exercise 5.2.22 Tow successive rotations")]
public void Exercise_5_2_22()
{
var random = TestUtilities.NewTestRandom;
Expand Down Expand Up @@ -149,7 +148,7 @@ public void Exercise_5_2_22()
}
}

[TestMethod("Page 237 Practice Exercise 5.3.2 Rotate points")]
[TestMethod(DisplayName = "Page 237 Practice Exercise 5.3.2 Rotate points")]
public void Exercise_5_3_2()
{
var motionMatrix = new MotionMatrix().RotateByY(Utilities.DegreesToRadians(30));
Expand All @@ -159,7 +158,7 @@ public void Exercise_5_3_2()
TestUtilities.AssertPointsAreEqual(new (4.598, 1, 1.964), actual, 3);
}

[TestMethod("Page 239 Example 5.3.3")]
[TestMethod(DisplayName = "Page 239 Example 5.3.3")]
public void Example_5_3_3()
{
var actual = new MotionMatrix()
Expand Down
1 change: 0 additions & 1 deletion Tests/TestUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using MathNet.Numerics.LinearAlgebra;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ascii3dEngine.Tests
{
Expand Down
15 changes: 7 additions & 8 deletions Tests/UtilitiesTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ascii3dEngine.Tests
{
[TestClass]
public class UtilitiesTests
{
[TestMethod("Check for bug that broke 'Looking Right'")]
[TestMethod(DisplayName = "Check for bug that broke 'Looking Right'")]
public void CheckAffineTransformationForRotatingAroundUnitWithSource()
{
var from = new Point3D(0, 3, 0);
Expand All @@ -23,7 +22,7 @@ public void CheckAffineTransformationForRotatingAroundUnitWithSource()
TestUtilities.AssertPointsAreEqual(expected, actual, round: 15);
}

[TestMethod("Page 216 Practice Exercise 5.2.1 Apply The Transform")]
[TestMethod(DisplayName = "Page 216 Practice Exercise 5.2.1 Apply The Transform")]
public void Exercise_5_2_1()
{
// The practice exercise is in 2d
Expand All @@ -42,7 +41,7 @@ public void Exercise_5_2_1()
Assert.AreEqual(Q, actual);
}

[TestMethod("Page 220 Example 5.2.1")]
[TestMethod(DisplayName = "Page 220 Example 5.2.1")]
public void Example_5_2_1()
{
// The practice exercise is in 2d
Expand Down Expand Up @@ -77,7 +76,7 @@ public void Example_5_2_1()
Assert.AreEqual(actual.Length, Q.Length, "The Transformation should should not have changed their Length");
}

[DataTestMethod]
[TestMethod]
[DataRow( 2, 3, -45, 3.5355, 0.7071, DisplayName = "Page 220 Practice Exercise 5.2.3 Rotate a point A")]
[DataRow( 1, 1, -180, -1.0, -1.0, DisplayName = "Page 220 Practice Exercise 5.2.3 Rotate a point B")]
[DataRow(60, 61, 4, 55.5987, 65.0368, DisplayName = "Page 220 Practice Exercise 5.2.3 Rotate a point C")]
Expand All @@ -93,7 +92,7 @@ public void Exercise_5_2_3(int pX, int pY, int degrees, double qX, double qY)
Assert.AreEqual(actual.Length, Q.Length, delta: 0.0001);
}

[TestMethod("Page 223 Exercise 5.2.5 What is the inverse of a rotation")]
[TestMethod(DisplayName = "Page 223 Exercise 5.2.5 What is the inverse of a rotation")]
public void Exercise_5_2_5()
{
var random = TestUtilities.NewTestRandom;
Expand All @@ -118,7 +117,7 @@ public void Exercise_5_2_5()
}
}

[TestMethod("Page 224 Example 5.2.4")]
[TestMethod(DisplayName = "Page 224 Example 5.2.4")]
public void Example_5_2_4()
{
var radians = Utilities.DegreesToRadians(45);
Expand Down Expand Up @@ -148,7 +147,7 @@ public void Example_5_2_4()
}


[TestMethod("Page 241 Example 5.3.4 Rotating about an axis")]
[TestMethod(DisplayName = "Page 241 Example 5.3.4 Rotating about an axis")]
public void Example_5_3_4()
{
var u = Point3D.Identity.Normalized();
Expand Down
2 changes: 1 addition & 1 deletion Tools/Ascii3dEngine.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 6 additions & 4 deletions Tools/CharProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,18 @@ public static (int[] Counts, int Width, int Height, Rgb24[] NamedColors) Compute
return (charCounts, charWidth, charHeight, colors);
}

private static void AssertIsColor(Rgb24[,] imageData, int pixelRow, int pixelCol, Color color)
private static void AssertIsColor(Rgb24[,] imageData, int pixelRow, int pixelCol, Rgb24 color)
{
var found = imageData[pixelRow, pixelCol];
var expected = color.ToPixel<Rgb24>();
if (!AreClose(found, expected))
if (!AreClose(found, color))
{
throw new ApplicationException($"At {nameof(pixelRow)}: {pixelRow}, {nameof(pixelCol)}: {pixelCol}, {nameof(found)}: {found}, {nameof(expected)}: {expected}");
throw new ApplicationException($"At {nameof(pixelRow)}: {pixelRow}, {nameof(pixelCol)}: {pixelCol}, {nameof(found)}: {found}, {nameof(color)}: {color}");
}
}

private static void AssertIsColor(Rgb24[,] imageData, int pixelRow, int pixelCol, Color color)
=> AssertIsColor(imageData, pixelRow, pixelCol, color.ToPixel<Rgb24>());

private static int Check(Rgb24[,] imageData, int at, int start, bool across, Color color, int max = -1)
{
if (max == -1)
Expand Down