根据矩阵拉散

This commit is contained in:
szdot 2024-01-04 20:43:17 +08:00
parent 569d1a0569
commit 04c82c4c75

View File

@ -35,12 +35,11 @@ namespace FlyCube
InitializeComponent(); InitializeComponent();
//创建一个 主画布对象 //创建一个 主画布对象
TopCanvas = new MainCanvas(this.LayerPlane); TopCanvas = new MainCanvas(this.LayerPlane);
} }
/// <summary> /// <summary>
/// 3D绕行 /// 3D绕行
/// </summary> /// </summary>
private void ByPass_Click(object sender, RoutedEventArgs e) private async void ByPass_Click(object sender, RoutedEventArgs e)
{ {
//资源管理器 获取航点文件路径 //资源管理器 获取航点文件路径
FileBase.FileClass = new string[] { "航点文件" }; FileBase.FileClass = new string[] { "航点文件" };
@ -51,9 +50,11 @@ namespace FlyCube
List<Vector3[]> abVecs = FileBase.TxtToPos(FliePath, out string[] fightNames);//从txt文件里面读取航点 信息 List<Vector3[]> abVecs = FileBase.TxtToPos(FliePath, 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>> re = FlyVecFun.ABypassB(aVecs, new_bVecs, StrPrint, GetVal); Vector3[] new_bVecs = FlyVecFun.NormalPull(aVecs, bVecs);
//Task<List<List<Vector3>>> reTask = Task.Run(() => FlyVecFun.ABypassB(aVecs, bVecs, StrPrintAsync, GetVal));
//List<List<Vector3>> re = await reTask;
//string txta = ""; //string txta = "";
//string txtb = ""; //string txtb = "";
@ -62,15 +63,18 @@ namespace FlyCube
for (int i = 0; i < abVecs[0].Length; i++) for (int i = 0; i < abVecs[0].Length; i++)
{ {
//if (re.Count > 0) // if (re.Count > 0)
//{ // {
// txta += i + " 0" + " " + re[0][i].X + " " + re[0][i].Y + " " + re[0][i].Z + "\r\n"; // txta += i + " 0" + " " + re[0][i].X + " " + re[0][i].Y + " " + re[0][i].Z + "\r\n";
//} // }
//if (re.Count > 1) // if (re.Count > 1)
//{ // {
// txtb += i + " 0" + " " + re[1][i].X + " " + re[1][i].Y + " " + re[1][i].Z + "\r\n"; // txtb += i + " 0" + " " + re[1][i].X + " " + re[1][i].Y + " " + re[1][i].Z + "\r\n";
// }
// if (re.Count > 2)
// {
// 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_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";
} }
@ -81,9 +85,12 @@ namespace FlyCube
//if (re.Count > 1) //if (re.Count > 1)
//{ //{
// SaveFile("C:/Users/szdot/Desktop/b.txt", txtb); // SaveFile("C:/Users/szdot/Desktop/b.txt", txtb);
// SaveFile("C:/Users/szdot/Desktop/c.txt", txtc);
//} //}
//if (re.Count > 2)
//{
// SaveFile("C:/Users/szdot/Desktop/c.txt", txtc);
//}
SaveFile("C:/Users/szdot/Desktop/d.txt", txtd); SaveFile("C:/Users/szdot/Desktop/d.txt", txtd);
} }
else else
@ -91,11 +98,19 @@ namespace FlyCube
return; return;
} }
} }
//回调函数 输出日志 // 异步回调函数 输出日志
private async void StrPrintAsync(string str)
{
await Task.Run(() =>
{
// 输出日志的异步操作
//vLogBox.Text += "\r\n" + str;
MessageBox.Show(str);
});
}
private void StrPrint(string str) private void StrPrint(string str)
{ {
//MessageBox.Show(str);
vLogBox.Text += "\r\n" + str;
} }
private void GetVal(int val) private void GetVal(int val)
{ {