How to draw a Scalene Triangle in Console with given sides length in C#?

Viewed 33

I want to draw a Scalene Triangle in Console, trying with c# language. We have only the sides length.Imagine the length are AB,BC and AC. So What is a Algorithm and better if C# code to draw this triangle base on these three given sides. However, if it is not possible or very hard to say how to draw the triangle with three side, Just draw a triangle by Base Line and Height. So here are the code to calculation of Height and base line in triangle.

 public byte CalculateTriangleBaseLine()
    {
        return new byte[] { SideABLength, SideBCLength, SideACLength }.Max();
    }
 public double CalculateTriangleHeight()
    {
        return 2 * (AreaCalculation() / CalculateTriangleBaseLine());
    }
public double PerimeterCalculation()
    {
        return IsDrawable() ? Convert.ToDouble(SideABLength + SideBCLength + SideACLength) : 0D;
    }
public double GammaCalculation()
    {
        return Math.Asin((2 * AreaCalculation()) / (SideBCLength * SideABLength)) * (180 / Math.PI);
    }
public double AreaCalculation()
    {
        var s = 0.5 * (SideABLength + SideBCLength + SideACLength);
        return IsDrawable() ? Math.Sqrt(s * (s - SideABLength) * (s - SideBCLength) * (s - SideACLength)) : 0D;
    }
 public bool IsDrawable()
    {
        if (SidesValidityRecognition())
            return true;
        return false;
    }
 public bool SidesValidityRecognition()
    {
        bool retVal = false;
        if (SideABLength > 0 && SideBCLength > 0 && SideACLength > 0)
            retVal = true;
        if (
            SideABLength + SideBCLength <= SideACLength ||
            SideABLength + SideACLength <= SideBCLength ||
            SideBCLength + SideACLength <= SideABLength
            )
            retVal = false;
        else
            retVal = true;
        return retVal;
    }
0 Answers
Related