《C#中坐标转换(4页).doc》由会员分享,可在线阅读,更多相关《C#中坐标转换(4页).doc(4页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、-C#中坐标转换-第 4 页static void Main(string args) /(1)利用A,B两点坐标计算方位角 Console.Write(请输入A,B两点的坐标(xA,yA),(xB,yB):); string xA = Console.ReadLine(); string yA = Console.ReadLine(); string xB = Console.ReadLine(); string yB = Console.ReadLine(); /将字符型数据转换为double类型 double xa = double.Parse (xA); double ya = dou
2、ble.Parse (yA); double xb = double.Parse (xB); double yb = double.Parse (yB); double AB = Math.Atan(yb - ya) / (xb- xa) * (180 / Math.PI); double BA = AB + 180; Console.WriteLine(AB=0,BA=1, AB, BA); /(2)计算AP和BP的方位角 Console.Write(请输入,的角度值:); string 0 = Console.ReadLine(); string 0= Console.ReadLine()
3、; /将字符型数据转换为double类型 double = double.Parse(0); double = double.Parse(0); double AP = AB - , BP = BA + ; Console.WriteLine(AP=0,BP=1, AP, BP); /(3)分别以A,B为基点计算P点的坐标值 Console.Write(输入边长AP和边长BP:); string ap = Console.ReadLine(); string bp = Console.ReadLine(); /将字符型数据转换为double类型 double AP = double.Parse
4、(ap); double BP = double.Parse(bp); double Xp1 = xa + AP * Math.Cos(AP / (180 / Math.PI); double Yp1 = ya + AP * Math.Sin(AP / (180 / Math.PI); double Xp2 = xb + BP * Math.Cos(BP / (180 / Math.PI); double Yp2 = yb + BP * Math.Sin(BP / (180 / Math.PI); Console.WriteLine(Xp1=0,Yp1=1, Xp1, Yp1); Console.WriteLine(Xp2=0,Yp2=1, Xp2, Yp2); /(4)计算P点的坐标差值(X,Y)及坐标值(Xp,Yp): double X = Xp1 - Xp2, Y = Yp1 - Yp2; double Xp = (Xp1 + Xp2) * 0.5, Yp = (Yp1 + Yp2) * 0.5; Console.WriteLine(X=0,Y=1, X, Y); Console.WriteLine(Xp=0,Yp=1, Xp, Yp); Console.ReadLine();