📄 complex.cs
字号:
namespace Opus6
{
using System;
[Version("$Id: Complex.cs,v 1.6 2001/10/28 19:50:09 brpreiss Exp $"), Copyright("Copyright (c) 2001 by Bruno R. Preiss, P.Eng.")]
public class Complex
{
public Complex() : this(0, 0)
{
}
public Complex(double x) : this(x, 0)
{
}
public Complex(double x, double y)
{
this.real = x;
this.imag = y;
}
public void Copy(Complex c)
{
this.real = c.real;
this.imag = c.imag;
}
public static Complex operator +(Complex c1, Complex c2)
{
return new Complex(c1.Real + c2.Real, c1.Imag + c2.Imag);
}
public static Complex operator -(Complex c1, Complex c2)
{
return new Complex(c1.Real - c2.Real, c1.Imag - c2.Imag);
}
public override string ToString()
{
return string.Concat(new object[] { this.real, "+", this.imag, "i" });
}
public double Imag
{
get
{
return this.imag;
}
set
{
this.imag = value;
}
}
public double R
{
get
{
return Math.Sqrt((this.real * this.real) + (this.imag * this.imag));
}
set
{
double num1 = this.Theta;
this.real = value * Math.Cos(num1);
this.imag = value * Math.Sin(num1);
}
}
public double Real
{
get
{
return this.real;
}
set
{
this.real = value;
}
}
public double Theta
{
get
{
return Math.Atan2(this.imag, this.real);
}
set
{
double num1 = this.R;
this.real = num1 * Math.Cos(value);
this.imag = num1 * Math.Sin(value);
}
}
private double imag;
private double real;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -