声源定位和GPS模拟实验编程(1)

上传人:jiups****uk12 文档编号:90776126 上传时间:2019-06-16 格式:DOC 页数:4 大小:221.01KB
返回 下载 相关 举报
声源定位和GPS模拟实验编程(1)_第1页
第1页 / 共4页
声源定位和GPS模拟实验编程(1)_第2页
第2页 / 共4页
声源定位和GPS模拟实验编程(1)_第3页
第3页 / 共4页
声源定位和GPS模拟实验编程(1)_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《声源定位和GPS模拟实验编程(1)》由会员分享,可在线阅读,更多相关《声源定位和GPS模拟实验编程(1)(4页珍藏版)》请在金锄头文库上搜索。

1、1、 声源定位:#include #include using namespace std;#define c 2982#define pai 3.1415926535int 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组时间数据 t0 t1 t2 t3;t0 = t0 / 1000000;t1 = t1 / 1000000;t2 = t2 / 100000

2、0;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(ac

3、os(D/sqrt(pow(A,2)+pow(B,2)+angle2 pai/2)angle1 = acos(D/sqrt(pow(A,2)+pow(B,2)+angle2;elseangle1 = 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

4、; / end main;2、 GPS模拟#include #include #include using namespace std;#define c 2982#define min 0.0000000001void GPS(double x10 , double y10 , double t10 , 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-(

5、3*pow(xi-x1),2)+pow(yi/1000-y1),2)-pow(c*ti/1000000,2);a2 = a2+2*(xi/1000-x1)*(y1-yi/1000);a3 = a2;a4 = a4-(3*pow(yi-y1),2)+pow(xi/1000-x1),2)-pow(c*ti/1000000,2);b1 = b1+(pow(xi/1000-x1),2)+pow(yi/1000-y1),2)-pow(c*ti/1000000,2)*(x1-xi/1000);b2 = b2+(pow(xi/1000-x1),2)+pow(yi/1000-y1),2)-pow(c*ti/1

6、000000,2)*(y1-yi/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 = fixed setprecision(8) x1;cout (mm) , Y = fixed setprecision(8) y1 (mm)endl; / end GPS;int main()int yy;double t110 , t210 , t310 , x10 , y10;cout 请输入时间数据(us)与坐标数据(mm): endl;int i;for(i = 0; i = 9; i +)cout 第 i+1 组: t1i t2i t3i xi yi; / end for;GPS(x,y,t1,0,0.45,1);GPS(x,y,t2,0.3,0.45,2);GPS(x,y,t3,0,0,3);cinyy;return 0; / end main;- 4 -

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 其它中学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号