资源描述:
《测绘常用程序C语言.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、测量平差程序设计1.角度(度分秒)到弧度AngleToRadian#definePI3.14159265doubleAngleToRadian(doubleangle){intD,M;doubleS,radian,degree,angle,MS;D=int(angle+0.3);MS=angle-D;M=int((MS)*100+0.3);S=(MS*100-M)*100;degree=D+M/60.0+S/3600.0;radian=degree*PI/180.0;returnradian;}注意:防止数据溢出,要加个微小量,例如0.3.2.弧度换角度(度分秒)RadianT
2、oAngle#definePI3.14159265doubleRadianToAngle(doubleradian){intD,M;doubleS,radian,degree,MS,angle;degree=radian*180/PI;D=int(degree);MS=degree-D;M=int(MS*60);S=(MS*60-M)*60;angle=D+M/100.0+S/10000.0;returnangle;}3.已知两点求坐标方位角Azimuth#includedoubleAzimuth(doublexi,doubleyi,doublexj,doubl
3、eyj){doubleDx,Dy,S,T;Dx=xj-xi;Dy=yj-yi;S=sqrt(Dx*Dx+Dy*Dy);if(S<1e-10)return0;T=asin(Dy/S);if(Dx<0)T=PI-T;if(Dx>0&&(Dy<0)
4、
5、T<0)T=2*PI+T;returnT;}4.开辟二维数组的动态空间的宏#include#defineNewArray2D(type,A,i,n,m){A=(type**)malloc(n*sizeof(type*));for(i=0;i6、pe));}5.释放开辟的二维数组的空间#defineFreeSpace(A,i,m){for(i=0;i7、le**B,double**C,inti,intj,intk){intm,n,p;for(m=0;mvoidcountermatrix(double**T,double**s,double**r,double**Q,double**N,double**rt,intn){for(i=0;i8、+){s-=T[k][i]*T[k][i];}T[i][i]=sqrt(s)for(j=i+1;j=0;i++){r[i][i]=1/T[i][i];for(j=i+1;j9、i=0;i