private static bool isReverse() { // 情况1: 左下右上 // false // 情况2: 左上右下 // true PointXYZ centerPoint1 = Const.FK_LINE.getKLine1().getCenterPoint(); PointXYZ centerPoint2 = Const.FK_LINE.getKLine2().getCenterPoint(); double x1 = centerPoint1.getX(); double y1 = centerPoint1.getY(); double z1 = centerPoint1.getZ(); // not used here double x2 = centerPoint2.getX(); double y2 = centerPoint2.getY(); double z2 = centerPoint2.getZ(); // not used here double k = Const.FK_LINE.getFLine().getK(); double b = Const.FK_LINE.getFLine().getB(); if ((y1 > k * x1 + b) && (y2 < k * x2 + b)) // 左上右下判断限定 { return(true); } return(false); }
public static void getRectanglePoint(double adp_x1, double adp_y1, double adp_x2, double adp_y2) { double minX = 0; double maxX = 0; double minY = 0; double maxY = 0; if (adp_x1 < adp_x2) { minX = adp_x1; maxX = adp_x2; } else { minX = adp_x2; maxX = adp_x1; } if (adp_y1 < adp_y2) { minY = adp_y1; maxY = adp_y2; } else { minY = adp_y2; maxY = adp_y1; } AREA_LEFT_TOP = new PointXYZ(minX, maxY); AREA_LEFT_BOTTOM = new PointXYZ(minX, minY); AREA_RIGHT_TOP = new PointXYZ(maxX, maxY); AREA_RIGHT_BOTTOM = new PointXYZ(maxX, minY); }
//通过矩形对角线上的一对点确定裁剪区域范围 public void setArea(PointXYZ point1, PointXYZ point2) { double x1 = point1.getX(); double y1 = point1.getY(); double x2 = point2.getX(); double y2 = point2.getY(); if (x1 < x2) { minX = x1; maxX = x2; } else { minX = x2; maxX = x1; } if (y1 < y2) { minY = y1; maxY = y2; } else { minY = y2; maxY = y1; } }
private void initKeyPoint2() { // 断裂线 double x1 = Convert.ToDouble(textBox22.Text); double y1 = Convert.ToDouble(textBox23.Text); double z1 = Convert.ToDouble(textBox24.Text); double x2 = Convert.ToDouble(textBox25.Text); double y2 = Convert.ToDouble(textBox26.Text); double z2 = Convert.ToDouble(textBox27.Text); double distance = Convert.ToDouble(textBox28.Text); distance = -distance; // 距离直接反向。 // 假设断裂线水平, 下盘固定不同, 移动上盘位置。 // 符号: + , 表示上盘向右移动 // 符号: - , 表示上盘向左移动 // 断裂线 PointXYZ point1 = new PointXYZ(x1, y1, 0); PointXYZ point2 = new PointXYZ(x2, y2, 0); Const.fline = new KeyLine(point1, point2); Const.distance_recovery = distance; }
public static void setValue() { FAULT_LINE_POINT_START = new PointXYZ(fline_ps_x, fline_ps_y, fline_ps_z); FAULT_LINE_POINT_END = new PointXYZ(fline_pe_x, fline_pe_y, fline_pe_z); KEY_LINE1_POINT_START = new PointXYZ(kline1_ps_x, kline1_ps_y, kline1_ps_z); KEY_LINE1_POINT_END = new PointXYZ(kline1_pe_x, kline1_pe_y, kline1_pe_z); KEY_LINE2_POINT_START = new PointXYZ(kline2_ps_x, kline2_ps_y, kline2_ps_z); KEY_LINE2_POINT_END = new PointXYZ(kline2_pe_x, kline2_pe_y, kline2_pe_z); }
private static void translation() { Const.listdata_translation.Clear(); PointXYZ point = null; double dx = Const.FK_LINE.getTranslationVector().getX(); double dy = Const.FK_LINE.getTranslationVector().getY(); // AM20191025 - 注意: 这里的dx和dy可能存在取反的情况 if (isReverse()) { dx = -dx; dy = -dy; } Const.distance_recovery = Math.Sqrt(dx * dx + dy * dy); double k = Const.FK_LINE.getFLine().getK(); double b = Const.FK_LINE.getFLine().getB(); double tx = 0; double ty = 0; double tz = 0; double nx = 0; double ny = 0; for (int i = 0; i < Const.listdata.Count; i++) { tx = Const.listdata[i].getX(); ty = Const.listdata[i].getY(); tz = Const.listdata[i].getZ(); //沿着断层进行区域分割,断层下盘不变,上盘移动 if (k * tx + b - ty > 0) { //断层上盘 point = new PointXYZ(); //按照平移向量进行水平移动 nx = tx + dx; ny = ty + dy; point.setX(nx); point.setY(ny); point.setZ(tz); Const.listdata_translation.Add(point); } else { //断层下盘不进行变换 Const.listdata_translation.Add(Const.listdata[i]); } } }
private static void translation2() { Const.listdata_translation.Clear(); PointXYZ point = null; // double dx = Const.FK_LINE.getTranslationVector().getX(); // double dy = Const.FK_LINE.getTranslationVector().getY(); double k = Const.fline.getK(); double b = Const.fline.getB(); // 这里需要求dx和dy double ds = Const.distance_recovery; double dx = ds * 1 / Math.Sqrt(1 + k * k); double dy = ds * k / Math.Sqrt(1 + k * k); double tx = 0; double ty = 0; double tz = 0; double nx = 0; double ny = 0; for (int i = 0; i < Const.listdata.Count; i++) { tx = Const.listdata[i].getX(); ty = Const.listdata[i].getY(); tz = Const.listdata[i].getZ(); //沿着断层进行区域分割,断层下部分不变,上部分移动 if (k * tx + b - ty < 0) // 这里修改了符号 { //断层上部分 point = new PointXYZ(); //按照平移向量进行水平移动 nx = tx - dx; // 这里修改了符号: [+]变[-] ny = ty - dy; // 这里修改了符号: [+]变[-] point.setX(nx); point.setY(ny); point.setZ(tz); Const.listdata_translation.Add(point); } else { //断层下盘不进行变换 Const.listdata_translation.Add(Const.listdata[i]); } } }
public PointXYZ getCenterPoint() { PointXYZ centerPoint = new PointXYZ(); double centerX = (point1.getX() + point2.getX()) / 2; double centerY = (point1.getY() + point2.getY()) / 2; double centerZ = (point1.getZ() + point2.getZ()) / 2; centerPoint.setValue("CenterPoint", centerX, centerY, centerZ); return(centerPoint); }
public FaultKeyLine(KeyLine fline, KeyLine kline1, KeyLine kline2) { this.fline = fline; this.kline1 = kline1; this.kline2 = kline2; CalculateKeyPoint(); translationVector = CalculateTranslationVector(); }
public PointXYZ CalculateTranslationVector() { PointXYZ point = new PointXYZ(); double dx = keyPoint2.getX() - keyPoint1.getX(); double dy = keyPoint2.getY() - keyPoint1.getY(); point.setX(dx); point.setY(dy); return(point); }
public static PointXYZ getPoint(String line) { string str = System.Text.RegularExpressions.Regex.Replace(line, @"\s+", ","); string[] sd = str.Split(','); PointXYZ point = new PointXYZ(); point.setX(Convert.ToDouble(sd[0])); point.setY(Convert.ToDouble(sd[1])); point.setZ(Convert.ToDouble(sd[2])); return(point); }
public bool isInKeyRectangle(PointXYZ point) { bool result = false; double x = point.getX(); double y = point.getY(); if ((x >= minX) && (x <= maxX) && (y >= minY) && (y < maxY)) { result = true; } return(result); }
private static void cut(PointXYZ point1, PointXYZ point2) { Const.listdata_cut.Clear(); KeyRectangle rectangle = new KeyRectangle(point1, point2); for (int i = 0; i < Const.listdata_translation.Count; i++) { if (rectangle.isInKeyRectangle(Const.listdata_translation[i])) { Const.listdata_cut.Add(Const.listdata_translation[i]); } } }
private void initKeyPoint() { // 断裂线 double x1 = Convert.ToDouble(textBox2.Text); double y1 = Convert.ToDouble(textBox3.Text); double z1 = Convert.ToDouble(textBox4.Text); double x2 = Convert.ToDouble(textBox5.Text); double y2 = Convert.ToDouble(textBox6.Text); double z2 = Convert.ToDouble(textBox7.Text); // 特征线 1 double x3 = Convert.ToDouble(textBox8.Text); double y3 = Convert.ToDouble(textBox9.Text); double z3 = Convert.ToDouble(textBox10.Text); double x4 = Convert.ToDouble(textBox11.Text); double y4 = Convert.ToDouble(textBox12.Text); double z4 = Convert.ToDouble(textBox13.Text); // 特征线 2 double x5 = Convert.ToDouble(textBox14.Text); double y5 = Convert.ToDouble(textBox15.Text); double z5 = Convert.ToDouble(textBox16.Text); double x6 = Convert.ToDouble(textBox17.Text); double y6 = Convert.ToDouble(textBox18.Text); double z6 = Convert.ToDouble(textBox19.Text); // 断裂线 PointXYZ point1 = new PointXYZ(x1, y1, 0); PointXYZ point2 = new PointXYZ(x2, y2, 0); // 标志线 1 PointXYZ point3 = new PointXYZ(x3, y3, 0); PointXYZ point4 = new PointXYZ(x4, y4, 0); // 标志线 2 PointXYZ point5 = new PointXYZ(x5, y5, 0); PointXYZ point6 = new PointXYZ(x6, y6, 0); KeyLine fline = new KeyLine(point1, point2); KeyLine kline1 = new KeyLine(point3, point4); KeyLine kline2 = new KeyLine(point5, point6); Const.FK_LINE = new FaultKeyLine(fline, kline1, kline2); Console.WriteLine(Convert.ToString(Const.FK_LINE.getTranslationVector().getX() + ":" + Const.FK_LINE.getTranslationVector().getY() + ":" + Const.FK_LINE.getVectorDistance())); }
public static void transformLine(List <PointXYZ> listdata, double k, double b) { Const.listdata_h_kxb.Clear(); PointXYZ point = null; for (int i = 0; i < listdata.Count; i++) { point = new PointXYZ(); point.setX(listdata[i].getX()); point.setY(listdata[i].getY()); double z = Const.ALTITUDE_MIN + k * (listdata[i].getZ() - Const.ALTITUDE_MIN) + b; point.setZ(z); Const.listdata_h_kxb.Add(point); } }
public static PointXYZ getIntersectPoint(KeyLine line1, KeyLine line2) { PointXYZ point = new PointXYZ(); double k1 = line1.getK(); double b1 = line1.getB(); double k2 = line2.getK(); double b2 = line2.getB(); double x0 = (b2 - b1) / (k1 - k2); double y0 = (k1 * b2 - k2 * b1) / (k1 - k2); point.setX(x0); point.setY(y0); return(point); }
public KeyLine(PointXYZ point1, PointXYZ point2) { this.point1 = point1; this.point2 = point2; getKB(); }
public void setKeyPoint1(PointXYZ keyPoint1) { this.keyPoint1 = keyPoint1; }
public KeyRectangle(PointXYZ point1, PointXYZ point2) { setArea(point1, point2); }
public void setKeyPoint2(PointXYZ keyPoint2) { this.keyPoint2 = keyPoint2; }
public void CalculateKeyPoint() { this.keyPoint1 = Core.getIntersectPoint(fline, kline1); this.keyPoint2 = Core.getIntersectPoint(fline, kline2); }
public void setTranslationVector(PointXYZ translationVector) { this.translationVector = translationVector; }