NormalPull 拉散函数 加入判断第一个图案是否是平面

This commit is contained in:
szdot 2024-01-24 16:05:10 +08:00
parent 3a6de2e67f
commit 4cd26f6b62
10 changed files with 43 additions and 35 deletions

View File

@ -2062,6 +2062,12 @@ namespace FlightRouteV2
Vector3[] new_aVecs = aVecs.ToArray(); //a图副本 Vector3[] new_aVecs = aVecs.ToArray(); //a图副本
Vector3[] new_bVecs = bVecs.ToArray(); //矩阵副本 Vector3[] new_bVecs = bVecs.ToArray(); //矩阵副本
int planeCou = new_aVecs.Length; //获取飞机总数 int planeCou = new_aVecs.Length; //获取飞机总数
///判断a图是不是平面
if (!(planeCou == FindMaxPlaneIndices(aVecs).Count))
{
StrPrint("-------,故不能做拉散图案操作-------");
return null;
}
///a图b图 中心 ///a图b图 中心
Vector3 aCenterPos = GetPosCenter(new_aVecs, false); Vector3 aCenterPos = GetPosCenter(new_aVecs, false);
///判断bVec 矩阵的数量长宽 ///判断bVec 矩阵的数量长宽

View File

@ -40,39 +40,39 @@ namespace FlyCube
//创建一个 主画布对象 //创建一个 主画布对象
TopCanvas = new MainCanvas(this.LayerPlane); TopCanvas = new MainCanvas(this.LayerPlane);
List<Vector3[]> abVecs = FileBase.TxtToPos("C:/Users/szdot/Desktop/1.txt", out string[] fightNames);//从txt文件里面读取航点 信息 //List<Vector3[]> abVecs = FileBase.TxtToPos("C:/Users/szdot/Desktop/1.txt", out string[] fightNames);//从txt文件里面读取航点 信息
Vector3[] aVecs = abVecs[0].ToArray(); //Vector3[] aVecs = abVecs[0].ToArray();
Vector3[] bVecs = abVecs[1].ToArray(); //Vector3[] bVecs = abVecs[1].ToArray();
Vector3[] new_bVecs = FlyVecFun.ContactABOut(aVecs, bVecs, StrPrint); //Vector3[] new_bVecs = FlyVecFun.ContactABOut(aVecs, bVecs, StrPrint);
List<List<Vector3>> listVecs = FlyVecFun.CollisionLayer(aVecs, new_bVecs, StrPrintAsync); //List<List<Vector3>> listVecs = FlyVecFun.CollisionLayer(aVecs, new_bVecs, StrPrintAsync);
string txta = ""; //string txta = "";
string txtb = ""; //string txtb = "";
string txtd = ""; //string txtd = "";
for (int i = 0; i < bVecs.Length; i++) //for (int i = 0; i < bVecs.Length; i++)
{ //{
txta += i + " 0" + " " + listVecs[0][i].X + " " + listVecs[0][i].Y + " " + listVecs[0][i].Z + "\r\n"; // txta += i + " 0" + " " + listVecs[0][i].X + " " + listVecs[0][i].Y + " " + listVecs[0][i].Z + "\r\n";
txtb += i + " 0" + " " + listVecs[1][i].X + " " + listVecs[1][i].Y + " " + listVecs[1][i].Z + "\r\n"; // txtb += i + " 0" + " " + listVecs[1][i].X + " " + listVecs[1][i].Y + " " + listVecs[1][i].Z + "\r\n";
txtd += i + " 0" + " " + new_bVecs[i].X + " " + new_bVecs[i].Y + " " + new_bVecs[i].Z + "\r\n"; // txtd += i + " 0" + " " + new_bVecs[i].X + " " + new_bVecs[i].Y + " " + new_bVecs[i].Z + "\r\n";
} //}
string patha = "C:/Users/szdot/Desktop/a.txt"; //string patha = "C:/Users/szdot/Desktop/a.txt";
string pathb = "C:/Users/szdot/Desktop/b.txt"; //string pathb = "C:/Users/szdot/Desktop/b.txt";
string pathd = "C:/Users/szdot/Desktop/d.txt"; //string pathd = "C:/Users/szdot/Desktop/d.txt";
if (File.Exists(patha)) //if (File.Exists(patha))
{ //{
File.Delete(patha); // File.Delete(patha);
} //}
SaveFile(patha, txta); //SaveFile(patha, txta);
if (File.Exists(pathb)) //if (File.Exists(pathb))
{ //{
File.Delete(pathb); // File.Delete(pathb);
} //}
SaveFile(pathb, txtb); //SaveFile(pathb, txtb);
if (File.Exists(pathd)) //if (File.Exists(pathd))
{ //{
File.Delete(pathd); // File.Delete(pathd);
} //}
SaveFile(pathd, txtd); //SaveFile(pathd, txtd);
} }
/// <summary> /// <summary>
@ -90,10 +90,12 @@ namespace FlyCube
Vector3[] aVecs = abVecs[0].ToArray(); Vector3[] aVecs = abVecs[0].ToArray();
Vector3[] bVecs = abVecs[1].ToArray(); Vector3[] bVecs = abVecs[1].ToArray();
//Vector3[] new_bVecs = FlyVecFun.ContactABOut(aVecs, bVecs, StrPrint); //Vector3[] new_bVecs = FlyVecFun.ContactABOut(aVecs, bVecs, StrPrint);
Vector3[] new_aVecs = FlyVecFun.NormalPull(aVecs, bVecs, StrPrintAsync); //Vector3[] new_aVecs = FlyVecFun.NormalPull(aVecs, bVecs, StrPrintAsync);
List<int> mappingId = new List<int>() { 1,2,3,4,10,7,5,8,9,6};
bool isPass; bool isPass;
Task<List<List<Vector3>>> reTask = Task.Run(() => FlyVecFun.ABypassB(new_aVecs, bVecs, StrPrintAsync, GetVal, cts.Token, out isPass)); Task<List<List<Vector3>>> reTask = Task.Run(() => FlyVecFun.ABypassB(aVecs, bVecs, StrPrintAsync, GetVal, cts.Token, out isPass, mappingId));
List<List<Vector3>> re = await reTask; List<List<Vector3>> re = await reTask;
string txta = ""; string txta = "";
@ -115,7 +117,7 @@ namespace FlyCube
{ {
txtc += i + " 0" + " " + re[2][i].X + " " + re[2][i].Y + " " + re[2][i].Z + "\r\n"; txtc += i + " 0" + " " + re[2][i].X + " " + re[2][i].Y + " " + re[2][i].Z + "\r\n";
} }
txtd += i + " 0" + " " + new_aVecs[i].X + " " + new_aVecs[i].Y + " " + new_aVecs[i].Z + "\r\n"; txtd += i + " 0" + " " + bVecs[i].X + " " + bVecs[i].Y + " " + bVecs[i].Z + "\r\n";
} }
if (re.Count > 0) if (re.Count > 0)