private bool isValidPosition(RightTriangle triangle) { var heightBounds = new List <int>() { triangle.V1.Y, triangle.V2.Y, triangle.V3.Y, Height }; var widthBounds = new List <int>() { triangle.V1.X, triangle.V2.X, triangle.V3.X, Width }; if (heightBounds.Max() != Height) { return(false); } if (widthBounds.Max() != Width) { return(false); } return(true); }
public MatrixPoint CalculateMatrixPosition(RightTriangle triangle) { var result = new MatrixPoint(); if (!triangle.IsValid || !isValidPosition(triangle)) { return(result); } if (triangle.SideA != HeightIncrements || triangle.SideB != WidthIncrements) { return(result); } var heightIncrements = triangle.V1.Y / triangle.SideA; result.Row = triangle.IsLeft ? convertToRowString(heightIncrements) : convertToRowString(heightIncrements + 1); var widthIncrements = triangle.V1.X / triangle.SideB; result.Column = triangle.IsLeft ? (widthIncrements * 2) + 1 : widthIncrements * 2; return(result); }