版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上基于C+編寫線路CAD程序1.1 曲線要素計(jì)算程序1.1.1 主要內(nèi)容和計(jì)算函數(shù)(1) 計(jì)算內(nèi)容:在txt文件中讀取交點(diǎn)信息,編程計(jì)算線路曲線要素、特征點(diǎn)里程及坐標(biāo)、逐樁里程和坐標(biāo),并讀出到txt文件。(2) 計(jì)算函數(shù):struct JDDATA /定義交點(diǎn)數(shù)據(jù)結(jié)構(gòu)體struct randompoint /定義任意點(diǎn)坐標(biāo)數(shù)據(jù)結(jié)構(gòu)double JSFWJ(double x1,double x2,double y1,double y2); /計(jì)算方位角的函數(shù)double JSp(double lo,double R); /計(jì)算內(nèi)移距p的函數(shù)double JSm(doubl
2、e lo); /計(jì)算切垂距m的函數(shù)char JSZYP(double fwj1,double fwj2); /判斷左右偏函數(shù) (其中左偏記為”L”,右偏記為”R”)double JSalpha(double fwj1,double fwj2); /計(jì)算的函數(shù)double JST(double R,double p,double m,double alpha); /計(jì)算切線長(zhǎng)的函數(shù)double JSL(double R,double lo,double alpha); /計(jì)算曲線長(zhǎng)的函數(shù)double JSE(double R,double p,double alpha); /計(jì)算外矢距的函數(shù)do
3、uble JSKZH(double K,double x1,double y1,double x2,double y2,double T1,double T2); /計(jì)算直緩點(diǎn)里程的函數(shù)double JSKHY(double KZH,double lo); /計(jì)算緩圓點(diǎn)里程的函數(shù)double JSKYH(double KZH,double L,double lo); /計(jì)算圓緩點(diǎn)里程的函數(shù)double JSKHZ(double KZH,double L); /計(jì)算緩直點(diǎn)里程的函數(shù)double JSKQZ(double KZH,double L); /計(jì)算曲中點(diǎn)里程的函數(shù)double JSZHx
4、(double x,double fwj,double T); /計(jì)算直緩點(diǎn)x坐標(biāo)的函數(shù)double JSZHy(double y,double fwj,double T); /計(jì)算直緩點(diǎn)y坐標(biāo)的函數(shù)double JSHZx(double x,double fwj,double T); /計(jì)算緩直點(diǎn)x坐標(biāo)的函數(shù)double JSHZy(double y,double fwj,double T); /計(jì)算緩直點(diǎn)y坐標(biāo)的函數(shù)double JSHYx(double lo,double R,double fwj,char zyp,double x);/計(jì)算緩圓點(diǎn)x坐標(biāo)的函數(shù)double JSHYy(d
5、ouble lo,double R,double fwj,char zyp,double y);/計(jì)算緩圓點(diǎn)y坐標(biāo)的函數(shù)double JSYHx(double lo,double R,double fwj,char zyp,double x);/計(jì)算圓緩點(diǎn)x坐標(biāo)的函數(shù)double JSYHy(double lo,double R,double fwj,char zyp,double y);/計(jì)算圓緩點(diǎn)y坐標(biāo)的函數(shù)void JSQZZB(double x,double y,double fwj,double L,double R,double lo,double m,double p,char
6、zyp,double *qzx,double *qzy); /計(jì)算曲中點(diǎn)坐標(biāo)的函數(shù)void JSZZZB(double LC,int i,double *zbx,double *zby); /里程轉(zhuǎn)坐標(biāo)的函數(shù)1.1.2 編程流程圖1.1.3 定義交點(diǎn)數(shù)據(jù)結(jié)構(gòu)體本文將交點(diǎn)的數(shù)據(jù)存儲(chǔ)于結(jié)構(gòu)體中,結(jié)構(gòu)體的定義如下:struct JDDATAdouble x;double x; /交點(diǎn)的x坐標(biāo)double y;/交點(diǎn)的y坐標(biāo)double R;/交點(diǎn)的半徑double lo;/交點(diǎn)的緩長(zhǎng)double fwj;/交點(diǎn)到下一個(gè)交點(diǎn)連線的方位角double p;/交點(diǎn)的內(nèi)移距double m;/交點(diǎn)的切垂距c
7、har zyp;/交點(diǎn)的左右偏(左偏記為L(zhǎng),右偏記為R)double alpha;/交點(diǎn)的double T;/交點(diǎn)的切線長(zhǎng)double L;/交點(diǎn)的曲線長(zhǎng)double E;/交點(diǎn)的外矢距double KZH;/交點(diǎn)的直緩點(diǎn)里程double KHY;/交點(diǎn)的緩圓點(diǎn)里程double KYH;/交點(diǎn)的圓緩點(diǎn)里程double KHZ;/交點(diǎn)的緩直點(diǎn)里程double KQZ;/交點(diǎn)的曲中點(diǎn)里程double ZHx;/直緩點(diǎn)的x坐標(biāo)double ZHy;/直緩點(diǎn)的y坐標(biāo)double HZx;/緩直點(diǎn)的x坐標(biāo)double HZy;/緩直點(diǎn)的y坐標(biāo)double HYx;/緩圓點(diǎn)的x坐標(biāo)double HYy;/
8、緩圓點(diǎn)的y坐標(biāo)double YHx;/圓緩點(diǎn)的x坐標(biāo)double YHy;/圓緩點(diǎn)的y坐標(biāo)double QZx;/曲中點(diǎn)的x坐標(biāo)double QZy;/曲中點(diǎn)的y坐標(biāo)jd20;設(shè)計(jì)線路中有數(shù)個(gè)交點(diǎn),故把每個(gè)交點(diǎn)的數(shù)據(jù)存儲(chǔ)于結(jié)構(gòu)體數(shù)組中,每個(gè)個(gè)體又包含如上列舉的共性屬性。本程序是用的是一個(gè)靜態(tài)數(shù)組jd20,考慮到交點(diǎn)數(shù)據(jù)不是很多,故把容量暫定為20個(gè),但是較有局限性,需要根據(jù)實(shí)際情況反復(fù)地改寫程序。期望的改進(jìn)方法是使用動(dòng)態(tài)數(shù)組<vector>或者是Carray,使得程序能夠隨著實(shí)際情況動(dòng)態(tài)的提供數(shù)組容量,以節(jié)省需要的內(nèi)存空間,但是現(xiàn)下能力有限,在嘗試的過(guò)程中程序報(bào)錯(cuò),不知如何修改,所
9、以最終還是選用了靜態(tài)數(shù)組。1.1.4 交點(diǎn)數(shù)據(jù)的讀入以本選題所設(shè)計(jì)的昌吉贛客專橫崗江家段線路為例,將交點(diǎn)數(shù)據(jù)存儲(chǔ)在”JD.data.txt”中,如圖:第一行的數(shù)據(jù)代表的是起始點(diǎn)的里程,以下每行的數(shù)據(jù)分別代表的是各個(gè)交點(diǎn)的緯度坐標(biāo)、經(jīng)度坐標(biāo)、圓曲線長(zhǎng)度、緩和曲線長(zhǎng)度。利用文件流將數(shù)據(jù)讀入。ifstream input;input.open("JDdata.txt");if (input.fail() /判斷文件讀取是否正常 cout<<"File does not exist"<<endl;cout<<"Exi
10、t program"<<endl;input>>jd0.KZH;int i=0;while (!input.eof()input>>jdi.x>>jdi.y>>jdi.R>>jdi.lo; /將交點(diǎn)數(shù)據(jù)存放于結(jié)構(gòu)體中 i+;cout<<"共檢測(cè)到"<<i<<"個(gè)交點(diǎn)"<<endl;input.close();這一部分程序運(yùn)行完之后,會(huì)出現(xiàn)一個(gè)對(duì)話框,讀取到的交點(diǎn)個(gè)數(shù)會(huì)顯示到對(duì)話框上,而相應(yīng)的交點(diǎn)數(shù)據(jù)已經(jīng)存入到結(jié)構(gòu)體當(dāng)中去了。1
11、.1.5 曲線要素計(jì)算原理及程序的實(shí)現(xiàn)(1) 方位角計(jì)算方位角需要用到兩個(gè)交點(diǎn)的坐標(biāo)數(shù)據(jù)。對(duì)于不同象限的方位角,所對(duì)應(yīng)的計(jì)算方法也會(huì)有所不同。如下程序首先判斷方位角在哪一個(gè)象限,再根據(jù)判斷的結(jié)果進(jìn)行方位角的計(jì)算?,F(xiàn)已在第一象限為例,對(duì)計(jì)算原理進(jìn)行闡釋:fwj (4-1)計(jì)算方位角函數(shù)的定義:double JSFWJ(double x1,double y1,double x2,double y2) double fwj;double dx;double dy;dx=x2-x1;dy=y2-y1;if (dx=0&&dy>0)fwj=0;else if (dx>0&am
12、p;&dy>0)fwj=atan(dx/dy)*180/PI;else if (dx>0&&dy=0)fwj=90;else if (dx>0&&dy<0)fwj=atan(dx/dy)*180/PI+180;else if (dx=0&&dy<0)fwj=180;else if (dx<0&&dy<0)fwj=atan(dx/dy)*180/PI+180;else if (dx<0&&dy=0)fwj=270;else if (dx<0&&am
13、p;dy>0)fwj=atan(dx/dy)*180/PI+360;return fwj;計(jì)算方位角函數(shù)的調(diào)用:for (int n=0;n<i-1;n+)jdn.fwj=JSFWJ(jdn.x,jdn.y,jdn+1.x,jdn+1.y);利用循環(huán)語(yǔ)句將交點(diǎn)的方位角都計(jì)算了出來(lái)。此外,本文中默認(rèn)的一個(gè)交點(diǎn)的方位角是該交點(diǎn)到下一個(gè)交點(diǎn)連線的方位角。(2) 轉(zhuǎn)向角轉(zhuǎn)向角是相鄰兩個(gè)方位角之差,并取絕對(duì)值。計(jì)算轉(zhuǎn)向角函數(shù)的定義:double JSalpha(double fwj1,double fwj2)double alpha;if (fabs(fwj2-fwj1)<180) a
14、lpha=fabs(fwj2-fwj1);else alpha=360-fabs(fwj2-fwj1);return alpha;計(jì)算轉(zhuǎn)向角函數(shù)的調(diào)用:jdcount.alpha=JSalpha(jdcount-1.fwj,jdcount.fwj);其中count是循環(huán)語(yǔ)句的計(jì)數(shù)器,以下內(nèi)容的計(jì)算都用到的循環(huán)的思想,在下文就不再贅述。(3) 判斷左右偏一般來(lái)說(shuō),但是若前方位角角度較小,接近0度,后方位角較大,接近360度,雖然后方位角大于前方位角,但實(shí)際偏轉(zhuǎn)應(yīng)當(dāng)是左偏。所以本文中對(duì)這一情況進(jìn)行了判斷,由于本文是實(shí)際線路為例,考慮到實(shí)際線路轉(zhuǎn)角偏轉(zhuǎn)不會(huì)太大,故以180度為判斷界限,若差值小于18
15、0,則按正常計(jì)算方法進(jìn)行計(jì)算;若差值大于180,則應(yīng)認(rèn)為是出現(xiàn)了上述的特殊情況,則不能按一般情況進(jìn)行計(jì)算判斷左右偏函數(shù)的定義:char JSZYP(double fwj1,double fwj2)char turn;if (abs(fwj2-fwj1)<=180) if (fwj2>fwj1)turn='R'else turn='L'else if(fwj2>fwj1)turn='L'else turn='R'return turn;判斷左右偏函數(shù)的調(diào)用:jdcount.zyp=JSZYP(jdcount-1.f
16、wj,jdcount.fwj);(4) 曲線要素根據(jù)實(shí)際情況,選定線路的交點(diǎn),在符合規(guī)范的條件下,選定合適的半徑和緩和曲線長(zhǎng)度,根據(jù)以下公式進(jìn)行計(jì)算:(4-2)(4-3)(4-4)(4-5)(4-6)(4-7)式中:p為內(nèi)移距,m為切垂距,為緩和曲線角,T為切線長(zhǎng),L為曲線長(zhǎng),E為內(nèi)移距。特征點(diǎn)里程的計(jì)算:ZH點(diǎn)里程為上一點(diǎn)HZ點(diǎn)里程加兩個(gè)交點(diǎn)的距離減去兩個(gè)交點(diǎn)的切線長(zhǎng)。(其中交點(diǎn)0的HZ點(diǎn)里程按起始點(diǎn)里程算,切線長(zhǎng)認(rèn)為是0)HY點(diǎn)里程=ZH(里程)+;YH點(diǎn)里程= ZH(里程)+-;HZ點(diǎn)里程= ZH(里程)+;QZ點(diǎn)里程= ZH(里程)+÷2;曲線要素計(jì)算的部分,程序內(nèi)容比較簡(jiǎn)單
17、,就是定義一個(gè)函數(shù),然后在主函數(shù)中調(diào)用它,得到需要的結(jié)果。詳細(xì)程序請(qǐng)參見附錄。1.1.6 逐樁坐標(biāo)的計(jì)算這里的逐樁坐標(biāo)的計(jì)算,其實(shí)就是給出任意點(diǎn)的里程,要能計(jì)算出這個(gè)點(diǎn)的坐標(biāo)。由于整條線路比較長(zhǎng),故選10米為一個(gè)點(diǎn),也就是計(jì)算10米樁的坐標(biāo)。大致的思路是這樣的:一、得到一個(gè)點(diǎn)的里程,判斷它落在哪一部分的曲線上(直線、圓曲線還是緩和曲線),不同的曲線部分計(jì)算的方法有所不同;二、計(jì)算得到局部坐標(biāo)。三、利用坐標(biāo)轉(zhuǎn)換原理得到整體坐標(biāo)。在直線段部分,坐標(biāo)的計(jì)算比較簡(jiǎn)單,利用方位角和里程差就能輕松求得。在緩和曲線段和圓曲線段,需要用到切線支距法,以?shī)A直線所在直線為x軸,垂直夾直線所在直線的直線為y軸計(jì)算公
18、式:(1) 緩和曲線部分(4-8)(4-9)(2) 圓曲線部分(4-10)(4-11)(4-12)相應(yīng)的,后緩和曲線則以HZ點(diǎn)為坐標(biāo)原點(diǎn)用切線支距法進(jìn)行計(jì)算。(3) 局部坐標(biāo)轉(zhuǎn)換為整體坐標(biāo)轉(zhuǎn)換公式如下:(4-13)需要注意的是,由于左偏還是右偏對(duì)局部坐標(biāo)的計(jì)算是有影響的,所以在計(jì)算前應(yīng)根據(jù)不同的左右偏情況分情況進(jìn)行討論計(jì)算,再根據(jù)具體的情況判斷局部坐標(biāo)系下x,y的正負(fù),保證計(jì)算的正確。(4) 逐樁坐標(biāo)數(shù)據(jù)結(jié)構(gòu)struct randompointdouble x;double y;double LC;point4000;這里用到的也是結(jié)構(gòu)體的思想,把任意點(diǎn)的x坐標(biāo),y坐標(biāo)和里程都放到結(jié)構(gòu)體里面去
19、。逐樁坐標(biāo)計(jì)算程序定義如下:void JSZZZB(double LC,int i,double *zbx,double *zby)for (int count2=1;count2<i;count2+)if (LC>=jdcount2-1.KHZ&&LC<=jdcount2.KZH) /直線段double l=LC-jdcount2-1.KHZ;*zbx=jdcount2-1.HZx+l*sin(jdcount2-1.fwj*PI/180);*zby=jdcount2-1.HZy+l*cos(jdcount2-1.fwj*PI/180);break;else
20、if (LC>=jdcount2.KZH&&LC<=jdcount2.KHY) /前緩段double l=LC-jdcount2.KZH;double hyx=l-pow(l,5)/40/pow(jdcount2.R,2)/pow(jdcount2.lo,2);double hyy;if (jdcount2.zyp='L')hyy=pow(l,3)/6/jdcount2.R/jdcount2.lo;elsehyy=-pow(l,3)/6/jdcount2.R/jdcount2.lo;*zbx=jdcount2.ZHx+hyx*sin(jdcount2
21、-1.fwj*PI/180)-hyy*cos(jdcount2-1.fwj*PI/180);*zby=jdcount2.ZHy+hyx*cos(jdcount2-1.fwj*PI/180)+hyy*sin(jdcount2-1.fwj*PI/180);break;else if (LC>=jdcount2.KHY&&LC<jdcount2.KYH)/圓曲線段double l=LC-jdcount2.KZH;double Qalfa=(l-jdcount2.lo)*180/PI/jdcount2.R+jdcount2.lo*180/2/PI/jdcount2.R; d
22、ouble qx=jdcount2.R*sin(Qalfa*PI/180)+jdcount2.m;double qy;if (jdcount2.zyp='L')qy=jdcount2.R*(1-cos(Qalfa*PI/180)+jdcount2.p;else qy=-(jdcount2.R*(1-cos(Qalfa*PI/180)+jdcount2.p); *zbx=jdcount2.ZHx+qx*sin(jdcount2-1.fwj*PI/180)-qy*cos(jdcount2-1.fwj*PI/180);*zby=jdcount2.ZHy+qx*cos(jdcount2
23、-1.fwj*PI/180)+qy*sin(jdcount2-1.fwj*PI/180);break;else if (LC>=jdcount2.KYH&&LC<jdcount2.KHZ)/后緩段double l=jdcount2.KHZ-LC;double yhx=-(l-pow(l,5)/40/pow(jdcount2.R,2)/pow(jdcount2.lo,2);double yhy;if (jdcount2.zyp='L')yhy=pow(l,3)/6/jdcount2.R/jdcount2.lo;elseyhy=-pow(l,3)/6/j
24、dcount2.R/jdcount2.lo;*zbx=jdcount2.HZx+yhx*sin(jdcount2.fwj*PI/180)-yhy*cos(jdcount2.fwj*PI/180);*zby=jdcount2.HZy+yhx*cos(jdcount2.fwj*PI/180)+yhy*sin(jdcount2.fwj*PI/180); break;函數(shù)的調(diào)用如下:int num=jdi-1.KZH/10;(計(jì)算每10米一個(gè)點(diǎn)的總點(diǎn)位數(shù))for (int j=0;j<num;j+)pointj.LC=jd0.KZH+10*j;JSZZZB(pointj.LC,i,&po
25、intj.x,&pointj.y);這樣就把每10米一個(gè)點(diǎn)的坐標(biāo)給求出來(lái)了。1.1.7 特征點(diǎn)坐標(biāo)特征點(diǎn)坐標(biāo)的計(jì)算同逐樁坐標(biāo)點(diǎn)坐標(biāo)的計(jì)算相同,只是將任意的里程替代為特征點(diǎn)的里程,用到的方法都是一樣的,這里也就不一一贅述了。計(jì)算數(shù)據(jù)的輸出這里依舊是用文件流的方法,將計(jì)算得到的數(shù)據(jù)讀出到"result.txt"。output.open("result.txt");for (int count1=1;count1<i-1;count1+)int k1,k3,k5,k7;double k2,k4,k6,k8;k1=jdcount1.KZH/1000
26、;k2=jdcount1.KZH-k1*1000;k3=jdcount1.KHY/1000;k4=jdcount1.KHY-k3*1000;k5=jdcount1.KYH/1000;k6=jdcount1.KYH-k5*1000;k7=jdcount1.KHZ/1000;k8=jdcount1.KHZ-k7*1000;output<<"alpha="<<jdcount1.alpha<<" "<<"T="<<jdcount1.T<<" "<
27、<"L="<<jdcount1.L<<endl;output<<"直緩點(diǎn)里程="<<"K"<<k1<<"+"<<k2<<endl;output<<"緩圓點(diǎn)里程="<<"K"<<k3<<"+"<<k4<<endl;output<<"圓緩點(diǎn)里程="<&
28、lt;"K"<<k5<<"+"<<k6<<endl;output<<"緩直點(diǎn)里程="<<"K"<<k7<<"+"<<k8<<endl; /輸出特征點(diǎn)的里程output<<"直緩點(diǎn)x坐標(biāo)="<<jdcount1.ZHx<<" "<<"直緩點(diǎn)y坐標(biāo)="<<&quo
29、t; "<<jdcount1.ZHy<<" "<<"緩圓點(diǎn)x坐標(biāo)="<<jdcount1.HYx<<" "<<"緩圓點(diǎn)y坐標(biāo)="<<jdcount1.HYy<<endl;output<<"圓緩點(diǎn)x坐標(biāo)="<<jdcount1.YHx<<" "<<"圓緩點(diǎn)y坐標(biāo)="<<" "
30、<<jdcount1.YHy<<" "<<"緩直點(diǎn)x坐標(biāo)="<<jdcount1.HZx<<" "<<"緩直點(diǎn)y坐標(biāo)="<<jdcount1.HZy<<endl;output<<endl; /輸出特征點(diǎn)坐標(biāo)jdi-1.KZH=jdi-2.KHZ+sqrt(jdi-1.x-jdi-2.x)*(jdi-1.x-jdi-2.x)+(jdi-1.y-jdi-2.y)*(jdi-1.y-jdi-2.y);int k1;
31、int k2;output<<"任意點(diǎn)里程"<<setw(10)<<"x坐標(biāo)"<<setw(20)<<"y坐標(biāo)"<<endl;int num=jdi-1.KZH/10;for (int j=0;j<num;j+)pointj.LC=jd0.KZH+10*j;JSZZZB(pointj.LC,i,&pointj.x,&pointj.y);k1=pointj.LC/1000;k2=pointj.LC-k1*1000;output<<&
32、quot;K"<<k1<<"+"<<k2<<setw(20)<<pointj.x<<setw(15)<<pointj.y<<endl; /輸出逐樁里程及坐標(biāo)output.close();如下圖所示,就是程序運(yùn)行后輸出文件”result.txt”的結(jié)果顯示曲線要素計(jì)算程序代碼#include <iostream>#include <fstream>#include <stdlib.h> #include <cmath> #i
33、nclude <iomanip>using namespace std;const double PI=3.14159;double JSFWJ(double x1,double x2,double y1,double y2);/聲明計(jì)算方位角的函數(shù)double JSp(double lo,double R);/聲明計(jì)算內(nèi)移距p的函數(shù)double JSm(double lo);/聲明計(jì)算切垂距m的函數(shù)char JSZYP(double fwj1,double fwj2);/聲明判斷左右偏函數(shù)double JSalpha(double fwj1,double fwj2);/聲明計(jì)算的
34、函數(shù)double JST(double R,double p,double m,double alpha);/聲明計(jì)算切線長(zhǎng)的函數(shù)double JSL(double R,double lo,double alpha);/聲明計(jì)算曲線長(zhǎng)的函數(shù)double JSE(double R,double p,double alpha);/聲明計(jì)算外矢距的函數(shù)double JSKZH(double K,double x1,double y1,double x2,double y2,double T1,double T2);/聲明計(jì)算直緩點(diǎn)里程的函數(shù)double JSKHY(double KZH,double
35、 lo);/聲明計(jì)算緩圓點(diǎn)里程的函數(shù)double JSKYH(double KZH,double L,double lo);/聲明計(jì)算圓緩點(diǎn)里程的函數(shù)double JSKHZ(double KZH,double L);/聲明計(jì)算緩直點(diǎn)里程的函數(shù)double JSKQZ(double KZH,double L);/聲明計(jì)算曲中點(diǎn)里程的函數(shù)double JSZHx(double x,double fwj,double T);/聲明計(jì)算直緩點(diǎn)x坐標(biāo)的函數(shù)double JSZHy(double y,double fwj,double T);/聲明計(jì)算直緩點(diǎn)y坐標(biāo)的函數(shù)double JSHZx(doub
36、le x,double fwj,double T);/聲明計(jì)算緩直點(diǎn)x坐標(biāo)的函數(shù)double JSHZy(double y,double fwj,double T);/聲明計(jì)算緩直點(diǎn)y坐標(biāo)的函數(shù)double JSHYx(double lo,double R,double fwj,char zyp,double x);/聲明計(jì)算緩圓點(diǎn)x坐標(biāo)的函數(shù)double JSHYy(double lo,double R,double fwj,char zyp,double y);/聲明計(jì)算緩圓點(diǎn)y坐標(biāo)的函數(shù)double JSYHx(double lo,double R,double fwj,char zyp
37、,double x);/聲明計(jì)算圓緩點(diǎn)x坐標(biāo)的函數(shù)double JSYHy(double lo,double R,double fwj,char zyp,double y);/聲明計(jì)算圓緩點(diǎn)y坐標(biāo)的函數(shù)void JSQZZB(double x,double y,double fwj,double L,double R,double lo,double m,double p,char zyp,double *qzx,double *qzy);/聲明計(jì)算曲中點(diǎn)坐標(biāo)的函數(shù)void JSZZZB(double LC,int i,double *zbx,double *zby);/聲明里程轉(zhuǎn)坐標(biāo)的函數(shù)s
38、truct JDDATA /定義結(jié)構(gòu)體JDDATAdouble x; /交點(diǎn)的x坐標(biāo)double y;/交點(diǎn)的y坐標(biāo)double R;/交點(diǎn)的半徑double lo;/交點(diǎn)的緩長(zhǎng)double fwj;/交點(diǎn)到下一個(gè)交點(diǎn)連線的方位角double p;/交點(diǎn)的內(nèi)移距double m;/交點(diǎn)的切垂距char zyp;/交點(diǎn)的左右偏(左偏記為L(zhǎng),右偏記為R)double alpha;/交點(diǎn)的double T;/交點(diǎn)的切線長(zhǎng)double L;/交點(diǎn)的曲線長(zhǎng)double E;/交點(diǎn)的外矢距double KZH;/交點(diǎn)的直緩點(diǎn)里程double KHY;/交點(diǎn)的緩圓點(diǎn)里程double KYH;/交點(diǎn)的圓緩點(diǎn)里
39、程double KHZ;/交點(diǎn)的緩直點(diǎn)里程double KQZ;/交點(diǎn)的曲中點(diǎn)里程double ZHx;/直緩點(diǎn)的x坐標(biāo)double ZHy;/直緩點(diǎn)的y坐標(biāo)double HZx;/緩直點(diǎn)的x坐標(biāo)double HZy;/緩直點(diǎn)的y坐標(biāo)double HYx;/緩圓點(diǎn)的x坐標(biāo)double HYy;/緩圓點(diǎn)的y坐標(biāo)double YHx;/圓緩點(diǎn)的x坐標(biāo)double YHy;/圓緩點(diǎn)的y坐標(biāo)double QZx;/曲中點(diǎn)的x坐標(biāo)double QZy;/曲中點(diǎn)的y坐標(biāo)jd20;struct randompointdouble x;double y;double LC;point4000;int main
40、()ifstream input;input.open("04291.txt");if (input.fail()cout<<"File does not exist"<<endl;cout<<"Exit program"<<endl;input>>jd0.KZH;int i=0;while (!input.eof()input>>jdi.x>>jdi.y>>jdi.R>>jdi.lo;i+;cout<<"
41、共檢測(cè)到"<<i<<"個(gè)交點(diǎn)"<<endl;input.close();ofstream output;for (int n=0;n<i-1;n+)jdn.fwj=JSFWJ(jdn.x,jdn.y,jdn+1.x,jdn+1.y);jd0.p=0;jd0.m=0;jd0.alpha=0;jd0.T=0;jd0.L=0;jd0.E=0;jd0.KHY=jd0.KZH;jd0.KYH=jd0.KZH;jd0.KHZ=jd0.KZH;jd0.ZHx=jd0.x;jd0.ZHy=jd0.y;jd0.HZx=jd0.x;jd0.H
42、Zy=jd0.y;jd0.HYx=jd0.x;jd0.HYy=jd0.y;jd0.YHx=jd0.x;jd0.YHy=jd0.y;for (int count=1;count<i-1;count+)jdcount.p=JSp(jdcount.lo,jdcount.R);jdcount.m=JSm(jdcount.lo);jdcount.zyp=JSZYP(jdcount-1.fwj,jdcount.fwj);jdcount.alpha=JSalpha(jdcount-1.fwj,jdcount.fwj);jdcount.T=JST(jdcount.R,jdcount.p,jdcount.
43、m,jdcount.alpha);jdcount.L=JSL(jdcount.R,jdcount.lo,jdcount.alpha);jdcount.E=JSE(jdcount.R,jdcount.p,jdcount.alpha);jdcount.KZH=JSKZH(jdcount-1.KHZ,jdcount-1.x,jdcount-1.y,jdcount.x,jdcount.y,jdcount-1.T,jdcount.T);jdcount.KHY=JSKHY(jdcount.KZH,jdcount.lo);jdcount.KYH=JSKYH(jdcount.KZH,jdcount.L,jdc
44、ount.lo);jdcount.KHZ=JSKHZ(jdcount.KZH,jdcount.L);jdcount.KQZ=JSKQZ(jdcount.KZH,jdcount.L);jdcount.ZHx=JSZHx(jdcount.x,jdcount-1.fwj,jdcount.T);jdcount.ZHy=JSZHy(jdcount.y,jdcount-1.fwj,jdcount.T);jdcount.HZx=JSHZx(jdcount.x,jdcount.fwj,jdcount.T);jdcount.HZy=JSHZy(jdcount.y,jdcount.fwj,jdcount.T);j
45、dcount.HYx=JSHYx(jdcount.lo,jdcount.R,jdcount-1.fwj,jdcount.zyp,jdcount.ZHx);jdcount.HYy=JSHYy(jdcount.lo,jdcount.R,jdcount-1.fwj,jdcount.zyp,jdcount.ZHy);jdcount.YHx=JSYHx(jdcount.lo,jdcount.R,jdcount.fwj,jdcount.zyp,jdcount.HZx);jdcount.YHy=JSYHy(jdcount.lo,jdcount.R,jdcount.fwj,jdcount.zyp,jdcoun
46、t.HZy);JSQZZB(jdcount.ZHx,jdcount.ZHy,jdcount-1.fwj,jdcount.L,jdcount.R,jdcount.lo,jdcount.m,jdcount.p,jdcount.zyp,&jdcount.QZx,&jdcount.QZy);cout<<jdcount.QZx<<" "<<jdcount.QZy<<endl;output.open("result.txt");for (int count1=1;count1<i-1;count1
47、+)int k1,k3,k5,k7;double k2,k4,k6,k8;k1=jdcount1.KZH/1000;k2=jdcount1.KZH-k1*1000;k3=jdcount1.KHY/1000;k4=jdcount1.KHY-k3*1000;k5=jdcount1.KYH/1000;k6=jdcount1.KYH-k5*1000;k7=jdcount1.KHZ/1000;k8=jdcount1.KHZ-k7*1000;output<<"alpha="<<jdcount1.alpha<<" "<<
48、"T="<<jdcount1.T<<""<<"L="<<jdcount1.L<<endl;output<<"直緩點(diǎn)里程="<<"K"<<k1<<"+"<<k2<<endl;output<<"緩圓點(diǎn)里程="<<"K"<<k3<<"+"<
49、<k4<<endl;output<<"圓緩點(diǎn)里程="<<"K"<<k5<<"+"<<k6<<endl;output<<"緩直點(diǎn)里程="<<"K"<<k7<<"+"<<k8<<endl;output<<"直緩點(diǎn)x坐標(biāo)="<<jdcount1.ZHx<<"
50、 "<<"直緩點(diǎn)y坐標(biāo)="<<" "<<jdcount1.ZHy<<" "<<"緩圓點(diǎn)x坐標(biāo)="<<jdcount1.HYx<<" "<<"緩圓點(diǎn)y坐標(biāo)="<<jdcount1.HYy<<endl;output<<"圓緩點(diǎn)x坐標(biāo)="<<jdcount1.YHx<<" "&l
51、t;<"圓緩點(diǎn)y坐標(biāo)="<<" "<<jdcount1.YHy<<" "<<"緩直點(diǎn)x坐標(biāo)="<<jdcount1.HZx<<" "<<"緩直點(diǎn)y坐標(biāo)="<<jdcount1.HZy<<endl;output<<endl;jdi-1.KZH=jdi-2.KHZ+sqrt(jdi-1.x-jdi-2.x)*(jdi-1.x-jdi-2.x)+(jdi-1
52、.y-jdi-2.y)*(jdi-1.y-jdi-2.y);int num=jdi-1.KZH/10;int k1;int k2;output<<"任意點(diǎn)里程"<<setw(10)<<"x坐標(biāo)"<<setw(20)<<"y坐標(biāo)"<<endl;for (int j=0;j<num;j+)pointj.LC=jd0.KZH+10*j;JSZZZB(pointj.LC,i,&pointj.x,&pointj.y);k1=pointj.LC/1000
53、;k2=pointj.LC-k1*1000;output<<"K"<<k1<<"+"<<k2<<setw(20)<<pointj.x<<setw(15)<<pointj.y<<endl;output.close();return 0;double JSFWJ(double x1,double y1,double x2,double y2)/計(jì)算方位角函數(shù)的定義double fwj;double dx;double dy;dx=x2-x1;dy=y2
54、-y1;if (dx=0&&dy>0)fwj=0;else if (dx>0&&dy>0)fwj=atan(dx/dy)*180/PI;else if (dx>0&&dy=0)fwj=90;else if (dx>0&&dy<0)fwj=atan(dx/dy)*180/PI+180;else if (dx=0&&dy<0)fwj=180;else if (dx<0&&dy<0)fwj=atan(dx/dy)*180/PI+180;else if
55、(dx<0&&dy=0)fwj=270;else if (dx<0&&dy>0)fwj=atan(dx/dy)*180/PI+360;return fwj;double JSp(double lo,double R) / 計(jì)算內(nèi)移距p的函數(shù)的定義double p;p=lo*lo/(24*R);return p;double JSm(double lo)double m;m=lo/2;return m;char JSZYP(double fwj1,double fwj2)char turn;if (abs(fwj2-fwj1)<=180)
56、if (fwj2>fwj1)turn='R'else turn='L'else if(fwj2>fwj1)turn='L'else turn='R'return turn;double JSalpha(double fwj1,double fwj2)double alpha;if (fabs(fwj2-fwj1)<180) alpha=fabs(fwj2-fwj1);else alpha=360-fabs(fwj2-fwj1);return alpha;double JST(double R,double p,d
57、ouble m,double alpha)double T;T=(R+p)*tan(alpha*PI/(180*2)+m;return T;double JSL(double R,double lo,double alpha)double L;L=PI*alpha*R/180+lo;return L;double JSE(double R,double p,double alpha)double E;E=(R+p)/cos(alpha*PI/(180*2)-R;return E;double JSKZH(double K,double x1,double y1,double x2,double
58、 y2,double T1,double T2)double KZH;KZH=K+sqrt(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)-T1-T2;return KZH;double JSKHY(double KZH,double lo)double KHY;KHY=KZH+lo;return KHY;double JSKYH(double KZH,double L,double lo)double KYH;KYH=KZH+L-lo;return KYH;double JSKHZ(double KZH,double L)double KHZ;KHZ=KZH+L;return KHZ;double JSKQZ(double KZH,double L)double KQZ;K
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 文學(xué)視角下園林植物的文化寓意探析
- 石河子大學(xué)《土壤肥料學(xué)》2022-2023學(xué)年第一學(xué)期期末試卷
- 石河子大學(xué)《人事測(cè)評(píng)》2021-2022學(xué)年第一學(xué)期期末試卷
- 石河子大學(xué)《地籍測(cè)量》2023-2024學(xué)年第一學(xué)期期末試卷
- 沈陽(yáng)理工大學(xué)《現(xiàn)場(chǎng)總線控制系統(tǒng)》2022-2023學(xué)年期末試卷
- 沈陽(yáng)理工大學(xué)《汽車檢測(cè)與診斷技術(shù)》2023-2024學(xué)年第一學(xué)期期末試卷
- 沈陽(yáng)理工大學(xué)《計(jì)算機(jī)程序設(shè)計(jì)》2022-2023學(xué)年期末試卷
- 沈陽(yáng)理工大學(xué)《工程制圖A》2021-2022學(xué)年第一學(xué)期期末試卷
- 沈陽(yáng)理工大學(xué)《大學(xué)生健康教育》2021-2022學(xué)年第一學(xué)期期末試卷
- 光合同化物的下運(yùn)途徑
- 養(yǎng)老機(jī)構(gòu)心理危機(jī)應(yīng)急救援預(yù)案
- 2024年上海公務(wù)員考試申論試題(A卷)
- 工廠蒸汽管道鋪設(shè)工程合同
- 消防安全知識(shí)培訓(xùn)課件
- 16J914-1 公用建筑衛(wèi)生間
- 物聯(lián)網(wǎng)應(yīng)用技術(shù)職業(yè)生涯規(guī)劃
- 2024年廣東恒健投資控股有限公司招聘筆試參考題庫(kù)含答案解析
- GR326CORE規(guī)范講解
- 新訓(xùn)工作總結(jié)(共5篇)
- 五年級(jí)下冊(cè)牛津英語(yǔ)期中試卷【精】
- (最新整理)案件(線索)移送登記表
評(píng)論
0/150
提交評(píng)論