Example #1
0
        private static string FormatComplex(Complex cplx, TrigonometryMode trigonometryMode)
        {
            var sb = new StringBuilder();

            sb.Append("R: ");
            sb.Append(cplx.Real);
            sb.Append(" i: ");
            sb.Append(cplx.Imaginary);
            sb.Append("\r\n φ: ");
            switch (trigonometryMode)
            {
            case TrigonometryMode.DEG:
                sb.Append(Trigonometry.Rad2Deg(cplx.Phase));
                sb.Append(" °");
                break;

            case TrigonometryMode.GRAD:
                sb.Append(Trigonometry.Rad2Grad(cplx.Phase));
                sb.Append(" grad");
                break;

            case TrigonometryMode.RAD:
                sb.Append(cplx.Phase);
                sb.Append(" rad");
                break;
            }
            sb.Append(" ABS: ");
            sb.Append(cplx.Magnitude);
            return(sb.ToString());
        }