本文主要是介绍补发上期:C Sharp编写缓和曲线计算应用程序——漏洞,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在上期编译程序后,发现缓和曲线整桩位为0,无法计算桩位坐标。
为此存在的一些漏洞在此表示抱歉!!!
主要错误出现在表单存储这里:上期应用"count"存储是有漏洞的。
if (i > Kzh)
{
Kjd1 = i;
存里程.Count();
正确的应该是:应用Add方法。
Kjd1 = i;存里程.Add(Kjd1);
其余细节的修改部分这里就不做赘述。
修复版内容:
namespace 缓和曲线计算
{class Program{public struct AtH1 {public double AtH2(double ang){int fuhao = (int)(ang / Math.Abs(ang));ang = Math.Abs(ang);int d = (int)ang;int m = ((int)(ang * 100)) - d * 100;double s = ang * 10000 - m * 100 - d * 10000;return ((d + m / 60.0 + s / 3600.0) * fuhao) / 180.0 * Math.PI;}}static void Main(string[] args){double m;double p;double Thyx;double Thyy;double T;double L;double E;double q;double Kqz;double Tx;double Ty;double Kzh;double Khy;double Kyh;double Khz;double wet;AtH1 A;Console.WriteLine("请输入交点里程(需要输入里程与小数):");double Kjd = double.Parse(Console.ReadLine());Console.WriteLine("请输入转角值:");double Aef = A.AtH2(double.Parse(Console.ReadLine()));Console.WriteLine("请输入曲线半径值:");double R = double.Parse(Console.ReadLine());Console.WriteLine("请输入直缓点的X坐标:");double Xzh = double.Parse(Console.ReadLine());Console.WriteLine("请输入直缓点的Y坐标:");double Yzh = double.Parse(Console.ReadLine());Console.WriteLine("请输入ZY-JD方位角:");double Wt = A.AtH2(double.Parse(Console.ReadLine()));Console.WriteLine("请输入缓和曲线长:");double Hd = double.Parse(Console.ReadLine());m = Hd / 2 - (Hd * Hd * Hd / 240 / R / R / R);Console.WriteLine(m);p = Hd * Hd / 24 / R;Console.WriteLine(p);wet = Hd * A.AtH2(180) / 2 / R / Math.PI;Console.WriteLine(wet);Console.ReadKey();T = (R + p) * Math.Tan(Aef / 2) + m;Console.WriteLine("T ={0}", T);L = Math.PI * R * (Aef - 2 * wet) / A.AtH2(180) + 2 * Hd;Console.WriteLine("L ={0}", L);E = (R + p) / Math.Cos(Aef / 2) - R;Console.WriteLine("E = {0}", E);q = 2 * T - L;Console.WriteLine("q = {0}", q);Kzh = Kjd - T;Console.WriteLine("Kzh = {0}", Kzh);Khy = Kzh + Hd;Console.WriteLine("Khy = {0}", Khy);Kqz = Kzh + L / 2;Console.WriteLine("Kqz = {0}", Kqz);Kyh = Kqz + L / 2;Console.WriteLine("Kyh = {0}", Kyh);Khz = Kzh + L;Console.WriteLine("Khz = {0}", Khz);Console.WriteLine("检校值{0}", Kqz + q / 2 - Kjd);Console.WriteLine("请输入整桩点间隔值:");double ZZD = double.Parse(Console.ReadLine());double Kjd1 = 0;//此处我们已经可以找到整条圆曲线中间的整桩点里程 List<double> 存里程 = new List<double>();for (double i = 0; i < Khy; i += ZZD){if (i > Kzh){Kjd1 = i;存里程.Add(Kjd1);}}Console.WriteLine("本曲线共有{0}个整桩点,请输入需要计算的整桩点点号", 存里程.Count);int co = int.Parse(Console.ReadLine());Kjd1 = 存里程[ co - 1];if (Kqz + q / 2 - Kjd == 0) {Tx = Xzh + (Hd - (Hd * Hd * Hd * Hd * Hd) / (40 * R * R * (Kjd1 - Kzh)));Console.WriteLine("Tx(第{0}桩) = {1}", co, Tx);Ty = Yzh + (Hd * Hd * Hd) / (6 * R * (Kjd1 - Kzh)) - (Hd * Hd * Hd * Hd * Hd * Hd * Hd) / (336 * R * R * R * ((Kjd1 - Kzh) * (Kjd1 - Kzh) * (Kjd1 - Kzh)));Console.WriteLine("Ty(第{0}桩) = {1}", co, Ty);存里程.Add(Tx);存里程.Add(Ty);Console.ReadKey();}else{Console.WriteLine("里程不符合,计算超限");Console.ReadKey();}Kjd1 = Kzh;Thyx = Xzh + (Hd - Hd * Hd * Hd / (40 * R * R));Console.WriteLine("Thyx(缓圆点X)={0}", Thyx);Thyy = Yzh + (Hd * Hd) / (6 * R) - (Hd * Hd * Hd) / (336 * R * R * R);Console.WriteLine("Thyy(缓圆点X)={0}", Thyy);Console.ReadKey();}}
}
计算结果:
本程序由吉林建筑科技学院梁*杰老师教学授课,小编经梁*杰老师传授,进行一系列整理希望能帮助到各位测绘同学!(如有侵权请告知!!!)
这篇关于补发上期:C Sharp编写缓和曲线计算应用程序——漏洞的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!