1、计算机图形学实验报告实验 2:高斯正反算以及换带程序的实现姓 名: 王震阳 学 号: 20094176 班 级: 测绘 09-1 班 指导老师: 周志易 完成时间: 2011.08.1 计算机图形学实验报告1 实验目的和要求1 了解高斯正反算的基本思想。2 完成高斯正反算点算程序的实现过程。2 实验环境和工具通过 Windows xp 系统运行 Vc 6.0 软件。3 实验结果计算机图形学实验报告计算机图形学实验报告计算机图形学实验报告3.1 程序代码1正反算程序char cb100,cl100,cl0100,cx100,cy100;char cbdu100,cbfen100,cbmiao10
2、0;char cldu100,clfen100,clmiao100;char cl0du100,cl0fen100,cl0miao100;double db=0,dl=0,dl0=0,dx=0,dy=0;double dbdu=0,dbfen=0,dbmiao=0;double dldu=0,dlfen=0,dlmiao=0;double dl0du=0,dl0fen=0,dl0miao=0;double p2=206264.8062;char cfr100;char cfb100,cfl100;double dfb=0,dfl=0;double dfbdu=0,dfbfen=0,dfbmia
3、o=0;double dfldu=0,dflfen=0,dflmiao;char cfbdu100,cfbfen100,cfbmiao100;char cfldu100,cflfen100,cflmiao100;m_b.GetWindowText(cb,100);for(int i=0;cbi!= ;i+)if(cbi!= )cbdui=cbi;cbdui=0;dbdu=atof(LPCTSTR)cbdu);/for(int j=0;cbj+strlen(cbdu)+1!= ;j+)cbfenj=cbj+strlen(cbdu)+1;cbfenj=0;dbfen=atof(LPCTSTR)cb
4、fen);/for(int k=0;cbk+strlen(cbdu)+strlen(cbfen)+2!= ;k+)cbmiaok=cbk+strlen(cbdu)+strlen(cbfen)+2;计算机图形学实验报告cbmiaok=0;dbmiao=atof(LPCTSTR)cbmiao);/db=(dbdu*3600+dbfen*60+dbmiao)/206264.8062;/纬度的弧度制/获取经度 L 的度分秒、 、 、 、/m_l.GetWindowText(cl,100);for( i=0;cli!= ;i+)if(cli!= )cldui=cli;cldui=0;dldu=atof(
5、LPCTSTR)cldu);/for( j=0;clj+strlen(cldu)+1!= ;j+)clfenj=clj+strlen(cldu)+1;clfenj=0;dlfen=atof(LPCTSTR)clfen);/for( k=0;clk+strlen(cldu)+strlen(clfen)+2!= ;k+)clmiaok=clk+strlen(cldu)+strlen(clfen)+2;clmiaok=0;dlmiao=atof(LPCTSTR)clmiao);/dl=(dldu*3600+dlfen*60+dlmiao)/206264.8062;/经度的弧度制/获取经度 L0 的度
6、分秒、 、 、 、/m_l0.GetWindowText(cl0,100);double dl1=atof(LPCTSTR)cl0);/dl0=dl1*3600/206264.8062;/中央子午线的弧度制/char czx100,czy100,czr100;double dzx=0.,dzy=0.,dzr=0.;double l=dl-dl0;double n=6399698.902-(21562.267-(108.973-0.612*cos(db)*cos(db)*cos(db)*cos(db)*cos(db)*cos(db);计算机图形学实验报告double a0=32140.404-(
7、135.3302-(0.7092-0.0040*cos(db)*cos(db)*cos(db)*cos(db)*cos(db)*cos(db);double a4=(0.25+0.00252*cos(db)*cos(db)*cos(db)*cos(db)-0.04166;double a6=(0.166*cos(db)*cos(db)-0.084)*cos(db)*cos(db);double a3=(0.3333333+0.001123*cos(db)*cos(db)*cos(db)*cos(db)-0.1666667;double a5=0.0083-(0.1667-(0.1968+0.0
8、04*cos(db)*cos(db)*cos(db)*cos(db)*cos(db)*cos(db);dzx=6367558.4969*db-(a0-(0.5+(a4+a6*l*l)*l*l)*l*l*n)*sin(db)*cos(db);dzy=(1.+(a3+a5*l*l)*l*l)*l*n*cos(db);_gcvt(dzx,14,czx);m_zx=czx;_gcvt(dzy,14,czy);m_zy=czy;/double zr1=0.33333+0.00674*cos(db)*cos(db);double zr2=(0.2*cos(db)*cos(db)-0.0067)*l*l;d
9、ouble dzrdu,dzrfen,dzrmiao;char czrdu100,czrfen100,czrmiao100,mczr1100;CString mczr2,mczr3,mczr4,mczr5,mczr6,mczr7,mczr8;dzr=l*sin(db)*(1+(zr1+zr2)*l*l*cos(db)*cos(db);dzrdu=(int)(dzr*p2/3600.0);dzrfen=(int)(dzr*p2-dzrdu*3600)/60.0);dzrmiao=(dzr*p2-dzrdu*3600-dzrfen*60);_gcvt(dzrdu,5,czrdu);_gcvt(dz
10、rfen,5,czrfen);_gcvt(dzrmiao,4,czrmiao);mczr6= ;mczr2=czrfen;mczr3=czrdu;mczr4=czrmiao;mczr5=mczr3+mczr6+mczr2+mczr6+mczr4;m_zr=mczr5;/反算程序/CString cfdu1,cffen1,cfmiao1,cff1;CString cfdu2,cffen2,cfmiao2,cff2;CString mcfr4,mcfr2,mcfr3,mcfr5,mcfr6;m_x.GetWindowText(cx,100);m_y.GetWindowText(cy,100);dx
11、=atof(LPCTSTR)cx);dy=atof(LPCTSTR)cy);double bter=dx/6367558.4969;double bf1=(293622+(2350+22*cos(bter)*cos(bter)*cos(bter)*cos(bter)*cos(bter)*cos(bter);double bf=bter+(50221746.0+bf1)*sin(bter)*cos(bter)/(10.0*10.0*10.0*10.0*10.0*10.0*10.0*10.0*10.0*计算机图形学实验报告10.0);double nf1=21562.267-(108.973-0.
12、612*cos(bf)*cos(bf)*cos(bf)*cos(bf);double nf=6399698.902-nf1*cos(bf)*cos(bf);double z=dy/(nf*cos(bf);double b2=(0.5+0.003369*cos(bf)*cos(bf)*sin(bf)*cos(bf);double b3=0.333333-(0.166667-0.001123*cos(bf)*cos(bf)*cos(bf)*cos(bf);double b4=0.25+(0.16161+0.00562*cos(bf)*cos(bf)*cos(bf)*cos(bf);double b
13、5=0.2-(0.1667-0.0088*cos(bf)*cos(bf)*cos(bf)*cos(bf);dfb=bf-(1-(b4-0.12*z*z)*z*z)*z*z*b2;dfl=dl0+(1-(b3-b5*z*z)*z*z)*z;dfbdu=(int)(dfb*p2/3600);dfbfen=(int)(dfb*p2-dfbdu*3600)/60);dfbmiao=dfb*p2-dfbdu*3600-dfbfen*60;_gcvt(dfbdu,15,cfbdu);cfdu1=cfbdu;_gcvt(dfbfen,15,cfbfen);cffen1=cfbfen;_gcvt(dfbmia
14、o,15,cfbmiao);cfmiao1=cfbmiao;cff1=cfdu1+mczr6+cffen1+mczr6+cfmiao1;m_fb=cff1;dfldu=(int)(dfl*p2/3600);dflfen=(int)(dfl*p2-dfldu*3600)/60);dflmiao=dfl*p2-dfldu*3600-dflfen*60;_gcvt(dfldu,10,cfldu);cfdu2=cfldu;_gcvt(dflfen,10,cflfen);cffen2=cflfen;_gcvt(dflmiao,10,cflmiao);cfmiao2=cflmiao;cff2=cfdu2+
15、mczr6+cffen2+mczr6+cfmiao2;m_fl=cff2;/计算反算子午收敛角 du/double dfr;double l1=dl0-dfl;double fr1=0.33333+0.00674*cos(dfb)*cos(dfb);double fr2=(0.2*cos(dfb)*cos(dfb)-0.0067)*l1*l1;double dfrdu,dfrfen,dfrmiao;char cfrdu100,cfrfen100,cfrmiao100,mcfr1100;dfr=l1*sin(dfb)*(1+(fr1+fr2)*l1*l1*cos(dfb)*cos(dfb);df
16、rdu=(int)(dfr*p2/3600.0);计算机图形学实验报告dfrfen=(int)(dfr*p2-dfrdu*3600)/60.0);dfrmiao=(dfr*p2-dfrdu*3600-dfrfen*60);_gcvt(dfrdu,5,cfrdu);_gcvt(dfrfen,5,cfrfen);_gcvt(dfrmiao,4,cfrmiao);mcfr6= ;mcfr2=czrfen;mcfr3=czrdu;mcfr4=czrmiao;mcfr5=mcfr3+mcfr6+mcfr2+mcfr6+mcfr4;m_fr=mcfr5;UpdateData(false);/换带程序cha
17、r cx100,cy100;char cl0100;char cl0n100;double dx=0.,dy=0.;double dl0=0.,dl0n=0.;m_x1.GetWindowText(cx,100);m_y1.GetWindowText(cy,100);dx=atof(LPCTSTR)cx);dy=atof(LPCTSTR)cy);m_l0.GetWindowText(cl0,100);dl0=atof(LPCTSTR)cl0);m_l0n.GetWindowText(cl0n,100);dl0n=atof(LPCTSTR)cl0n);double bter=dx/6367558
18、.4969;double bf1=(293622+(2350+22*cos(bter)*cos(bter)*cos(bter)*cos(bter)*cos(bter)*cos(bter);double bf=bter+(50221746.0+bf1)*sin(bter)*cos(bter)/(10.0*10.0*10.0*10.0*10.0*10.0*10.0*10.0*10.0*10.0);double nf1=21562.267-(108.973-0.612*cos(bf)*cos(bf)*cos(bf)*cos(bf);double nf=6399698.902-nf1*cos(bf)*
19、cos(bf);double z=dy/(nf*cos(bf);double b2=(0.5+0.003369*cos(bf)*cos(bf)*sin(bf)*cos(bf);double b3=0.333333-(0.166667-0.001123*cos(bf)*cos(bf)*cos(bf)*cos(bf);double b4=0.25+(0.16161+0.00562*cos(bf)*cos(bf)*cos(bf)*cos(bf);double b5=0.2-(0.1667-0.0088*cos(bf)*cos(bf)*cos(bf)*cos(bf);double dfb=0,dfl=
20、0.;dfb=bf-(1-(b4-0.12*z*z)*z*z)*z*z*b2;CString cfdu1,cffen1,cfmiao1,cff1;CString mczr6= ;double dfbdu=(int)(dfb*p2/3600);double dfbfen=(int)(dfb*p2-dfbdu*3600)/60);计算机图形学实验报告double dfbmiao=dfb*p2-dfbdu*3600-dfbfen*60;char cfbdu100,cfbfen100,cfbmiao100;_gcvt(dfbdu,15,cfbdu);cfdu1=cfbdu;_gcvt(dfbfen,1
21、5,cfbfen);cffen1=cfbfen;_gcvt(dfbmiao,15,cfbmiao);cfmiao1=cfbmiao;cff1=cfdu1+mczr6+cffen1+mczr6+cfmiao1;m_b=cff1;/dl0=dl0*3600/206264.8062;dfl=dl0+(1-(b3-b5*z*z)*z*z)*z;double dfldu=(int)(dfl*p2/3600);double dflfen=(int)(dfl*p2-dfldu*3600)/60);double dflmiao=dfl*p2-dfldu*3600-dflfen*60;char cfldu100
22、,cflfen100,cflmiao100;CString cfdu2,cffen2,cfmiao2,cff2;_gcvt(dfldu,100,cfldu);cfdu2=cfldu;_gcvt(dflfen,100,cflfen);cffen2=cflfen;_gcvt(dflmiao,100,cflmiao);cfmiao2=cflmiao;cff2=cfdu2+mczr6+cffen2+mczr6+cfmiao2;m_l=cff2;/UpdateData(false);double l=dfl-dl0n*3600/p2;double n=6399698.902-(21562.267-(10
23、8.973-0.612*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb);double a0=32140.404-(135.3302-(0.7092-0.0040*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb);double a4=(0.25+0.00252*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb)-0.04166;double a6=(0.166*cos(dfb)*cos(dfb)-0.084)*cos(dfb)*cos(dfb);double
24、a3=(0.3333333+0.001123*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb)-0.1666667;double a5=0.0083-(0.1667-(0.1968+0.004*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb)*cos(dfb)char cx2100;char cy2100;double dx2=6367558.4969*dfb-(a0-(0.5+(a4+a6*l*l)*l*l)*l*l*n)*sin(dfb)*cos(dfb);double dy2=(1.+(a3+a5*l*l)*l*l)*l*n*
25、cos(dfb);_gcvt(dx2,14,cx2);m_x2=cx2;_gcvt(dy2,14,cy2);m_y2=cy2;UpdateData(false);计算机图形学实验报告/double zr1=0.33333+0.00674*cos(dfb)*cos(dfb);double zr2=(0.2*cos(dfb)*cos(dfb)-0.0067)*l*l;double dzrdu,dzrfen,dzrmiao;char czrdu100,czrfen100,czrmiao100,mczr1100;CString mczr2,mczr3,mczr4,mczr5,mczr7,mczr8;d
26、ouble dzr=l*sin(dfb)*(1+(zr1+zr2)*l*l*cos(dfb)*cos(dfb);dzrdu=(int)(dzr*p2/3600.0);dzrfen=(int)(dzr*p2-dzrdu*3600)/60.0);dzrmiao=(dzr*p2-dzrdu*3600-dzrfen*60);_gcvt(dzrdu,5,czrdu);_gcvt(dzrfen,5,czrfen);_gcvt(dzrmiao,4,czrmiao);mczr6= ;mczr2=czrfen;mczr3=czrdu;mczr4=czrmiao;mczr5=mczr3+mczr6+mczr2+mczr6+mczr4;m_r=mczr5;UpdateData(false);3.2 运行结果分析得到预期结果,经过和答案比对完全正确,程序正确。4 实验心得本次程序和上一次大地主题结算程序相比有一点改进之处,在输入度分秒时可以在同一个编辑框里同时输入,之间要以空格分开,程序便可识别。