PurplePen.DescriptionCourseObj.BestNumberOfColumns C# (CSharp) Method

BestNumberOfColumns() private method

private BestNumberOfColumns ( SizeF currentSize ) : int
currentSize System.Drawing.SizeF
return int
        private int BestNumberOfColumns(SizeF currentSize)
        {
            float aspectAngle = (float) Math.Atan2(currentSize.Height, currentSize.Width);

            float bestAngleDiff = Math.Abs(aspectAnglesByColumns[1] - aspectAngle);
            int bestColumns = 1;
            for (int i = 2; i < aspectAnglesByColumns.Length; ++i) {
                float angleDiff = Math.Abs(aspectAnglesByColumns[i] - aspectAngle);
                if (angleDiff < bestAngleDiff) {
                    bestAngleDiff = angleDiff;
                    bestColumns = i;
                }
            }

            return bestColumns;
        }