public static Complex i { get; private set; }定义了一个静态的属性
static Complex() 定义了一个静态构造函数
{
i = new Complex(0, 1);
}
static public implicit operator Complex(double value)定义了隐式转换,double可以转换为Complex类型
{
return new Complex(value);
}
class ConversionCurve
{
public ConversionCurve(double Ax, double Ay, double Cx, double Cy)构造函数
{
this.Ax = Ax;
this.Ay = Ay;
this.Cx = Cx;
this.Cy = Cy;
}
public double Ax { get; set; }属性
public double Ay { get; set; }属性
public double Cy { get; set; }属性
public double Cx { get; set; }属性
public double XtoY(double x)用来计算位点
{
var ret = -1 *(Ay * x + Cy * x * Complex.i - Ay * Cx - Ax * Cy * Complex.i) / (Ax * Complex.i + Cx + x * (-1 - Complex.i));
return ret.Re;
}
public double YtoX(double x)函数方法,用来计算位点
{
var ret = (Ay * Cx - x * (Ax * Complex.i + Cx) + Ax * Cy * Complex.i) / (Ay + Cy * Complex.i + x * (-1 - Complex.i));
return ret.Re;
}
public Point Calc(Point middle)函数方法,用来重画位点,也就是移动窗口的位置
{
double my = XtoY(middle.X);
double mx = YtoX(middle.Y);
double lx = Math.Min(middle.X, mx);
double rx = Math.Max(middle.X, mx);
double ty = Math.Max(middle.Y, my);
double by = Math.Min(middle.Y, my);
double mix = lx +(rx - lx)/2;
double miy = by + (ty - by)/2;
return new Point(mix, miy);
}
}
打酱油 做任务