Distance bug fix

This commit is contained in:
2022-09-29 13:13:41 -07:00
parent 152612bacb
commit 4568d3fbc6
21 changed files with 933 additions and 879 deletions

View File

@ -435,6 +435,35 @@ public class UnitTestCalculations
Assert.IsTrue(distance == 3);
}
[TestMethod]
public void TestGetPixelPercentageG()
{
int? x, y;
double x1, x2, y1, y2;
int height, width;
string normalizedPixelPercentagePadded;
width = 4608;
height = 3072;
normalizedPixelPercentagePadded = "683152331";
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
if (x is null || y is null)
throw new Exception();
Assert.IsTrue(x.Value == 3148);
Assert.IsTrue(y.Value == 1608);
x1 = x.Value;
y1 = y.Value;
normalizedPixelPercentagePadded = "234431671";
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
if (x is null || y is null)
throw new Exception();
Assert.IsTrue(x.Value == 1080);
Assert.IsTrue(y.Value == 973);
x2 = x.Value;
y2 = y.Value;
double distance = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
Assert.IsTrue(distance == 3);
}
[TestMethod]
public void TestGetDistance()
{