声源定位和GPS模拟实验编程.doc

  1. 1、本文档共4页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
声源定位和GPS模拟实验编程

声源定位: #include iostream #include cmath using namespace std; #define c 2982 #define pai 3.1415926535 int main() { double x0,x1,x2,y0,y1,y2,t0,t1,t2,t3,A,B,D,angle1,angle2,dt1,dt2,r; x0=0,x1=0,x2=0.3; y0=0,y1=0.45,y2=0.45; int i = 8; while(i--) { cout 请输入第8-i组时间数据 endl; cin t0 t1 t2 t3; t0 = t0 / 1000000; t1 = t1 / 1000000; t2 = t2 / 1000000; dt1 = t0 - t2; dt2 = t1 - t2; A = x2*(pow(x1,2)+pow(y1,2)-pow(c*dt1,2)) - x1*(pow(x2,2)+pow(y2,2)-pow(c*dt2,2)); B = y2*(pow(x1,2)+pow(y1,2)-pow(c*dt1,2)) - y1*(pow(x2,2)+pow(y2,2)-pow(c*dt2,2)); D = c*dt1*(pow(x2,2)+pow(y2,2)-pow(c*dt2,2)) - c*dt2*(pow(x1,2)+pow(y1,2)-pow(c*dt1,2)); angle2 = atan(B/A); if(acos(D/sqrt(pow(A,2)+pow(B,2)))+angle2 pai/2) angle1 = acos(D/sqrt(pow(A,2)+pow(B,2)))+angle2; else angle1 = angle2 - acos(D/sqrt(pow(A,2)+pow(B,2))); r = (pow(x1,2)+pow(y1,2)-pow(c*dt1,2))/(2*(x1*cos(angle1)+y1*sin(angle1)+c*dt1)); cout 声源坐标为:(r*cos(angle1)*1000mm , r*sin(angle1)*1000mm)endl; } // end while; return 0; } // end main; GPS模拟 #include iostream #include cmath #include iomanip using namespace std; #define c 2982 #define min 0.0000000001 void GPS(double x[10] , double y[10] , double t[10] , double x1 , double y1 , int num) { double a1,a2,a3,a4,b1,b2,mult,D=0,E=0; int i; while(1) { a1 = a2 = a3 = a4 = b1 = b2 = 0; for(i = 0; i 10; i ++) { a1 = a1-(3*pow((x[i]-x1),2)+pow((y[i]/1000-y1),2)-pow(c*t[i]/1000000,2)); a2 = a2+2*(x[i]/1000-x1)*(y1-y[i]/1000); a3 = a2; a4 = a4-(3*pow((y[i]-y1),2)+pow((x[i]/1000-x1),2)-pow(c*t[i]/1000000,2)); b1 = b1+(pow((x[i]/1000-x1),2)+pow((y[i]/1000-y1),2)-pow(c*t[i]/1000000,2))*(x1-x[i]/1000); b2 = b2+(pow((x[i]/1000-x1),2)+pow((y[i]/1000-y1),2)-pow(c*t[i]/1000000,2))*(y1-y[i]/1000); } //end for; mult = a3/a1; a4 -= a2*mult; b2 -= b1*mult; E = b2/a4; D = (b1-a2*E)/a1; x1 += D; y1 += E; if((pow(D,2)+pow(E,2)) min) break; } // end while; x1 = x1*1000; y1 = y1*1000; cout 点P num 定位于: X = f

文档评论(0)

153****9595 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档