public void DiagonalLine(int size, short[] points, float expectedC) { MockPixelGrid pixelGrid = new MockPixelGrid(size, points); float a, b, c; LinearRegression.CalculateLineEquation(pixelGrid, 0, 0, pixelGrid.Width, pixelGrid.Height, out a, out b, out c); MathHelper.NormalizeCoefficientsWithRespectToA(ref a, ref b, ref c); TestHelper.AssertABC(a, b, c, MathHelper.SQRT2DIV2, -MathHelper.SQRT2DIV2, expectedC); }
public void MiscellaneousLine(int size, short[] points, float exA, float exB, float exC) { MockPixelGrid pixelGrid = new MockPixelGrid(size, points); float a, b, c; LinearRegression.CalculateLineEquation(pixelGrid, 0, 0, pixelGrid.Width, pixelGrid.Height, out a, out b, out c); MathHelper.NormalizeCoefficientsWithRespectToA(ref a, ref b, ref c); TestHelper.AssertABC(a, b, c, exA, exB, exC); }
public void SquarePixelPatternGivesIndeterminateLine(int size, short[] points) { MockPixelGrid pixelGrid = new MockPixelGrid(size, points); float a, b, c; LinearRegression.CalculateLineEquation(pixelGrid, 0, 0, pixelGrid.Width, pixelGrid.Height, out a, out b, out c); Assert.IsTrue(float.IsNaN(a), MathHelper.CoeffecientsToString("Expected NaN for a, b and c, but got ", a, b, c)); Assert.IsTrue(float.IsNaN(b), MathHelper.CoeffecientsToString("Expected NaN for a, b and c, but got ", a, b, c)); Assert.IsTrue(float.IsNaN(c), MathHelper.CoeffecientsToString("Expected NaN for a, b and c, but got ", a, b, c)); }