public static cyOXYLine operator *(cyOXYLine line, double a) { cyOXYLine obj = new cyOXYLine(); obj.A = (float)(line.A * a); obj.B = (float)(line.B * a); obj.C = (float)(line.C * a); return(obj); }
/// <summary> /// 计算两个直线的夹角是多少 /// </summary> /// <param name="line1"></param> /// <returns></returns> public double GetAngle(cyOXYLine line1) { double xArr = line1.A - A; double yArr = line1.B - B; double angle = Math.Atan2(yArr, xArr); return(angle); }
/// <summary> /// 根据旋转矩阵,对直线进行旋转, /// 旋转中心点:(0,0)点 /// 旋转矩阵为:Tr = [cosθ, -sinθ, Xoffset]; /// [sinθ, cosθ, Yoffset]; /// [ 0, 0, 1]; /// θ为:O-XY,中的夹角 /// 直线系数[A,B,C], 原始的直线系数为:[a,b,c] /// [A,B,-C] = [a,b,-c]*Tr;(因为还是在原始的坐标系中, x', y'都是过渡量,还是得转换成x,y的方程) /// </summary> /// <param name="transArray">旋转矩阵,</param> /// <param name="pointX">旋转点坐标X</param> /// <param name="pointY">旋转点坐标Y</param> public cyOXYLine OnTranslateCoorPoint(double angle, double pointX, double pointY) { double cosV = Math.Cos(angle), sinV = Math.Sin(angle); double A1 = A * cosV - B * sinV; double B1 = A * sinV + B * cosV; double C1 = C - ((A * pointX) + B * (pointY)); //计算某个特定的值 cyOXYLine newline = new cyOXYLine(A1, B1, C1); newline.OnMove(-pointX, -pointY); return(newline); }
/// <summary> /// 判断是否与a 垂直 /// </summary> /// <param name="a"></param> /// <returns></returns> public bool OnVertical(cyOXYLine a) { float tValue = a.A * this.A + this.B * this.B; return(Math.Abs(tValue) <= 1e-6 ? true : false); }
/// <summary> /// 判断两条直线是否平行 /// </summary> /// <param name="a"></param> /// <returns></returns> public bool GetParallel(cyOXYLine a) { double tValue = A * a.B - B * a.A; return(Math.Abs(tValue) <= 1e-16); }