public Complex(double _XorR, double _YorTheta, ComplexRepresentingModeEnum _mode = ComplexRepresentingModeEnum.Cartesian) { if (_mode == ComplexRepresentingModeEnum.Cartesian) { this.Real = _XorR; this.Imaginary = _YorTheta; } else { this.Real = _XorR * Math.Cos(_YorTheta); this.Imaginary = _XorR * Math.Sin(_YorTheta); } }
public string ToString(ComplexRepresentingModeEnum mode) { if (mode == ComplexRepresentingModeEnum.Cartesian) { return(this.ToString()); } else { string res = ""; string reRes = ""; if (this.Imaginary == 0) { res = this.Real.ToString().Trim(); } else { if (this.Real == 1) { reRes = ""; } else if (this.Real == -1) { reRes = "-"; } else { reRes = (!this).ToString("f3").Trim(); } if ((~this).HasValue) { res = reRes + "exp(" + ((~this).Value / Math.PI).ToString("f3").Trim() + "πi)"; } } return(res); } }