機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)說(shuō)明書(shū)_第1頁(yè)
機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)說(shuō)明書(shū)_第2頁(yè)
機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)說(shuō)明書(shū)_第3頁(yè)
機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)說(shuō)明書(shū)_第4頁(yè)
機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)說(shuō)明書(shū)_第5頁(yè)
已閱讀5頁(yè),還剩22頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)說(shuō)明書(shū)指導(dǎo)老師:姓名:班級(jí):學(xué)號(hào):2014/01/10目錄一課設(shè)任務(wù)1二課設(shè)要求1三編程語(yǔ)言1四變量說(shuō)明及程序界面1〔一〕DDA第四象限直線插補(bǔ)變量說(shuō)明1〔二〕逐點(diǎn)比擬法第1~2象限逆圓弧插補(bǔ)變量說(shuō)明2〔三〕DDA第四象限直線插補(bǔ)程序界面3〔1〕普通DDA……………...3〔2〕全加載…………………3〔3〕半加載………………...4〔四〕逐點(diǎn)比擬法第1~2象限逆圓弧插補(bǔ)程序界面4五詳細(xì)程序設(shè)計(jì)流程圖………..5〔一〕DDA第四象限直線插補(bǔ)流程圖………………….5〔二〕逐點(diǎn)比擬法第1~2象限逆圓弧插補(bǔ)流程圖………….6六源程序6七參考資料32一課設(shè)任務(wù)〔1〕DDA法插補(bǔ)第四象限直線;〔2〕逐點(diǎn)比擬法插補(bǔ)第1~2象限順圓弧。二課設(shè)要求〔1〕具有數(shù)據(jù)輸入界面,如起點(diǎn)、終點(diǎn)、圓心、半徑及插補(bǔ)步長(zhǎng)等;〔2〕具有插補(bǔ)過(guò)程的動(dòng)態(tài)顯示功能,如單步插補(bǔ)、連續(xù)插補(bǔ);〔3〕插補(bǔ)的步長(zhǎng)可調(diào);三編程語(yǔ)言:MATLAB四變量說(shuō)明及程序界面〔一〕DDA第四象限直線插補(bǔ)變量名稱說(shuō)明變量名稱說(shuō)明X1直線起點(diǎn)橫坐標(biāo)JvxX被積函數(shù)存放器Y1直線起點(diǎn)縱坐標(biāo)Jrx1X普通DDA積分累加器X2直線終點(diǎn)橫坐標(biāo)Jrx2X全加載積分累加器Y2直線終點(diǎn)縱坐標(biāo)Jrx3X半加載積分累加器x繪圖動(dòng)點(diǎn)橫坐標(biāo)JvyY被積函數(shù)存放器y繪圖動(dòng)點(diǎn)縱坐標(biāo)Jry1Y普通DDA積分累加器L插補(bǔ)步長(zhǎng)Jry2Y全加載積分累加器N存放器位數(shù)Jry3Y半加載積分累加器MxX終點(diǎn)判別計(jì)數(shù)器X插補(bǔ)動(dòng)點(diǎn)橫坐標(biāo)MyY終點(diǎn)判別計(jì)數(shù)器Y插補(bǔ)動(dòng)點(diǎn)縱坐標(biāo)〔二〕逐點(diǎn)比擬法第2~1象限順圓弧插補(bǔ)變量名稱說(shuō)明變量名稱說(shuō)明X1圓弧起點(diǎn)橫坐標(biāo)E終點(diǎn)判別計(jì)數(shù)器Y1圓弧起點(diǎn)縱坐標(biāo)F偏差判別x繪圖動(dòng)點(diǎn)橫坐標(biāo)X插補(bǔ)動(dòng)點(diǎn)橫坐標(biāo)y繪圖動(dòng)點(diǎn)縱坐標(biāo)Y插補(bǔ)動(dòng)點(diǎn)縱坐標(biāo)r圓弧半徑MxX插補(bǔ)步數(shù)X2圓弧終點(diǎn)橫坐標(biāo)MyY插補(bǔ)步數(shù)Y2圓弧終點(diǎn)縱坐標(biāo)L插補(bǔ)步長(zhǎng)A圓心到弦中點(diǎn)的距離a1圓弧起點(diǎn)角坐標(biāo)x0圓心橫坐標(biāo)a2圓弧終點(diǎn)角坐標(biāo)y0圓心縱坐標(biāo)a繪圖動(dòng)點(diǎn)角坐標(biāo)程序界面:〔三〕DDA第四象限直線插補(bǔ)〔1〕普通DDA〔2〕全加載半加載〔四〕逐點(diǎn)比擬第1~2象限逆圓弧插補(bǔ)五詳細(xì)程序設(shè)計(jì)流程圖DDA第四象限直線插補(bǔ)逐點(diǎn)比擬法第1~2象限逆圓弧插補(bǔ)六源程序functionvarargout=f2(varargin)%F2MATLABcodeforf2.fig%F2,byitself,createsanewF2orraisestheexisting%singleton*.%%H=F2returnsthehandletoanewF2orthehandleto%theexistingsingleton*.%%F2('CALLBACK',hObject,eventData,handles,...)callsthelocal%functionnamedCALLBACKinF2.Mwiththegiveninputarguments.%%F2('Property','Value',...)createsanewF2orraisesthe%existingsingleton*.Startingfromtheleft,propertyvaluepairsare%appliedtotheGUIbeforef2_OpeningFcngetscalled.An%unrecognizedpropertynameorinvalidvaluemakespropertyapplication%stop.Allinputsarepassedtof2_OpeningFcnviavarargin.%%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone%instancetorun(singleton)".%%Seealso:GUIDE,GUIDATA,GUIHANDLES%Edittheabovetexttomodifytheresponsetohelpf2%LastModifiedbyGUIDEv2.509-Jan-201410:52:17%Begininitializationcode-DONOTEDITgui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',@f2_OpeningFcn,...'gui_OutputFcn',@f2_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});end%Endinitializationcode-DONOTEDIT%---Executesjustbeforef2ismadevisible.functionf2_OpeningFcn(hObject,eventdata,handles,varargin)%Thisfunctionhasnooutputargs,seeOutputFcn.%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%varargincommandlineargumentstof2(seeVARARGIN)%Choosedefaultcommandlineoutputforf2handles.output=hObject;%Updatehandlesstructureguidata(hObject,handles);%UIWAITmakesf2waitforuserresponse(seeUIRESUME)%uiwait(handles.figure1);%---Outputsfromthisfunctionarereturnedtothecommandline.functionvarargout=f2_OutputFcn(hObject,eventdata,handles)%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Getdefaultcommandlineoutputfromhandlesstructurevarargout{1}=handles.output;%---Executesonbuttonpressinpushbutton1.functionpushbutton1_Callback(hObject,eventdata,handles)%繪制直線globalx1y1x2y2LNxyMxMyJvxJrx1Jrx2Jrx3JvyJry1Jry2Jry3XY;x1=str2double(get(handles.edit1,'string'));y1=str2double(get(handles.edit2,'string'));x2=str2double(get(handles.edit3,'string'));y2=str2double(get(handles.edit4,'string'));L=str2double(get(handles.edit7,'string'));N=str2double(get(handles.edit6,'string'));ifx1<=0|y1>=0|x2<=0|y2>=0set(handles.text11,'string','直線不在第四象限!');%判斷直線是否在第四象限elseifx1==x2y=y1:(y2-y1)/100:y2;x=y.*0+x1;plot(x,y,'k');holdon;elsex=x1:(x2-x1)/100:x2;plot(x,y,'k');holdon;endxmin=min(x);xmax=max(x);ymin=min(y);ymax=max(y);axisequal;axis([xmin-Lxmax+Lymin-Lymax+L]);%定義坐標(biāo)軸的邊界set(handles.text11,'string','繪圖完成');Mx=ceil(abs(x2-x1)/L);%計(jì)算插補(bǔ)步數(shù)My=ceil(abs(y2-y1)/L);Jvx=abs(x2-x1);%給存放器賦值Jrx2=2^N-1;Jrx3=2^(N-1);Jvy=abs(y2-y1);Jry1=0;Jry2=2^N-1;Jry3=2^(N-1);X=x1;Y=y1;end%hObjecthandletopushbutton1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)functionedit1_Callback(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit1astext%str2double(get(hObject,'String'))returnscontentsofedit1asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit1_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit2_Callback(hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit2astext%str2double(get(hObject,'String'))returnscontentsofedit2asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit2_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit3_Callback(hObject,eventdata,handles)%hObjecthandletoedit3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit3astext%str2double(get(hObject,'String'))returnscontentsofedit3asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit3_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit4_Callback(hObject,eventdata,handles)%hObjecthandletoedit4(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit4astext%str2double(get(hObject,'String'))returnscontentsofedit4asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit4_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit4(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit5_Callback(hObject,eventdata,handles)%hObjecthandletoedit5(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit5astext%str2double(get(hObject,'String'))returnscontentsofedit5asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit5_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit5(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit6_Callback(hObject,eventdata,handles)%hObjecthandletoedit6(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit6astext%str2double(get(hObject,'String'))returnscontentsofedit6asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit6_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit6(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit7_Callback(hObject,eventdata,handles)%hObjecthandletoedit7(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit7astext%str2double(get(hObject,'String'))returnscontentsofedit7asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit7_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit7(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end%---Executesonbuttonpressinpushbutton2.functionpushbutton2_Callback(hObject,eventdata,handles)%直線單步插補(bǔ)%hObjecthandletopushbutton2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalx1y1x2y2LNxyMxMyJvxJrx1Jrx2Jrx3JvyJry1Jry2Jry3XY;if(get(handles.radiobutton1,'Value')==0)...&(get(handles.radiobutton2,'Value')==0)...&(get(handles.radiobutton3,'Value')==0)set(handles.text11,'string','請(qǐng)選擇插補(bǔ)方式');elseif(Mx<=0)&(My<=0)set(handles.text11,'string','插補(bǔ)結(jié)束');elseJrx1=Jvx+Jrx1;Jry1=Jvy+Jry1;Jrx2=Jvx+Jrx2;Jry2=Jvy+Jry2;Jrx3=Jvx+Jrx3;Jry3=Jvy+Jry3;ifget(handles.radiobutton1,'Value')==1%普通DDAif(x1<=x2)&(y1<=y2)%轉(zhuǎn)化后直線在第一象限if(Jrx1>=2^N)Jrx1=Jrx1-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry1>=2^N)Jry1=Jry1-2^N;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;elseif(x1>x2)&(y1<=y2)%轉(zhuǎn)化后直線在第二象限if(Jrx1>=2^N)Jrx1=Jrx1-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry1>=2^N)Jry1=Jry1-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;elseif(x1>x2)&(y1>y2)%轉(zhuǎn)化后直線在第三象限if(Jrx1>=2^N)Jrx1=Jrx1-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry1>=2^N)Jry1=Jry1-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;y=zeros(1,100)+Y;endplot(x,y,'r');holdon;else%轉(zhuǎn)化后直線在第四象限if(Jrx1>=2^N)Jrx1=Jrx1-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry1>=2^N)Jry1=Jry1-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;endelseifget(handles.radiobutton2,'Value')==1%全加載if(x1<=x2)&(y1<=y2)if(Jrx2>=2^N)Jrx2=Jrx2-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry2>=2^N)Jry2=Jry2-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;elseif(x1>x2)&(y1<=y2)if(Jrx2>=2^N)Jrx2=Jrx2-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry2>=2^N)Jry2=Jry2-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;elseif(x1>x2)&(y1>y2)if(Jrx2>=2^N)Jrx2=Jrx2-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry2>=2^N)Jry2=Jry2-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;elseif(Jrx2>=2^N)Jrx2=Jrx2-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry2>=2^N)Jry2=Jry2-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;endelse%半加載if(x1<=x2)&(y1<=y2)if(Jrx3>=2^N)Jrx3=Jrx3-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry3>=2^N)Jry3=Jry3-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;elseif(x1>x2)&(y1<=y2)if(Jrx3>=2^N)Jrx3=Jrx3-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry3>=2^N)Jry3=Jry3-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;elseif(x1>x2)&(y1>y2)if(Jrx3>=2^N)Jrx3=Jrx3-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry3>=2^N)Jry3=Jry3-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;elseif(Jrx3>=2^N)Jrx3=Jrx3-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry3>=2^N)Jry3=Jry3-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;endendendend%---Executesonbuttonpressinpushbutton3.functionpushbutton3_Callback(hObject,eventdata,handles)%直線連續(xù)插補(bǔ)%hObjecthandletopushbutton3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalx1y1x2y2LNxyMxMyJvxJrx1Jrx2Jrx3JvyJry1Jry2Jry3XY;if(get(handles.radiobutton1,'Value')==0)...&(get(handles.radiobutton2,'Value')==0)...&(get(handles.radiobutton3,'Value')==0)set(handles.text11,'string','請(qǐng)選擇插補(bǔ)方式');elsewhile(Mx>0)|(My>0)Jrx1=Jvx+Jrx1;Jry1=Jvy+Jry1;Jrx2=Jvx+Jrx2;Jry2=Jvy+Jry2;Jrx3=Jvx+Jrx3;Jry3=Jvy+Jry3;ifget(handles.radiobutton1,'Value')==1if(x1<=x2)&(y1<=y2)if(Jrx1>=2^N)Jrx1=Jrx1-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry1>=2^N)Jry1=Jry1-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);elseif(x1>x2)&(y1<=y2)if(Jrx1>=2^N)Jrx1=Jrx1-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry1>=2^N)Jry1=Jry1-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);elseif(x1>x2)&(y1>y2)if(Jrx1>=2^N)Jrx1=Jrx1-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry1>=2^N)Jry1=Jry1-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);elseif(Jrx1>=2^N)Jrx1=Jrx1-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry1>=2^N)Jry1=Jry1-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);endelseifget(handles.radiobutton2,'Value')==1if(x1<=x2)&(y1<=y2)if(Jrx2>=2^N)Jrx2=Jrx2-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry2>=2^N)Jry2=Jry2-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);elseif(x1>x2)&(y1<=y2)if(Jrx2>=2^N)Jrx2=Jrx2-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry2>=2^N)Jry2=Jry2-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);elseif(x1>x2)&(y1>y2)if(Jrx2>=2^N)Jrx2=Jrx2-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry2>=2^N)Jry2=Jry2-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);elseif(Jrx2>=2^N)Jrx2=Jrx2-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry2>=2^N)Jry2=Jry2-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);endelseif(x1<=x2)&(y1<=y2)if(Jrx3>=2^N)Jrx3=Jrx3-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry3>=2^N)Jry3=Jry3-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);elseif(x1>x2)&(y1<=y2)if(Jrx3>=2^N)Jrx3=Jrx3-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry3>=2^N)Jry3=Jry3-2^N;Y=Y+L;y=linspace(Y-L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);elseif(x1>x2)&(y1>y2)if(Jrx3>=2^N)Jrx3=Jrx3-2^N;X=X-L;x=linspace(X+L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry3>=2^N)Jry3=Jry3-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);elseif(Jrx3>=2^N)Jrx3=Jrx3-2^N;X=X+L;x=linspace(X-L,X,100);Mx=Mx-1;elsex=zeros(1,100)+X;endif(Jry3>=2^N)Jry3=Jry3-2^N;Y=Y-L;y=linspace(Y+L,Y,100);My=My-1;elsey=zeros(1,100)+Y;endplot(x,y,'r');holdon;pause(0.1);endendendset(handles.text11,'string','插補(bǔ)結(jié)束');end%---Executesonbuttonpressinpushbutton3.functionpushbutton4_Callback(hObject,eventdata,handles)%繪制圓弧%hObjecthandletopushbutton3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalx1y1xyrx2y2Ax0y0MFXYMxMyLa1a2a;x1=str2double(get(handles.edit1,'string'));y1=str2double(get(handles.edit2,'string'));x2=str2double(get(handles.edit3,'string'));y2=str2double(get(handles.edit4,'string'));r=str2double(get(handles.edit5,'string'));L=str2double(get(handles.edit7,'string'));A=sqrt(r^2-((x2-x1)^2+(y2-y1)^2)/4);%圓心到弦中點(diǎn)的長(zhǎng)度ifsqrt(((x2-x1)^2+(y2-y1)^2))>(2*r)set(handles.text11,'string','無(wú)法構(gòu)成圓弧');elsex0=(x1+x2)/2+A*(y1-y2)/sqrt((x2-x1)^2+(y2-y1)^2);%圓心坐標(biāo)y0=(y1+y2)/2-A*(x1-x2)/sqrt((x2-x1)^2+(y2-y1)^2);a1=atan((y1-y0)/(x1-x0));a2=atan((y2-y0)/(x2-x0));if(x1<x0&y1>y0)a1=pi-abs(a1);elsea1=a1;endif(x2<x0&y0<y2)a2=pi-abs(a2);elseif(x2<x0&y2<y0)a2=pi+a2;elsea2=a2;enda=a1:0.01:a2;x=x0+r.*cos(a);y=y0+r.*sin(a);plot(x,y,'k');xmin=min([x,x0]);xmax=max([x,x0]);ymin=min([y,y0]);ymax=max([y,y0]);axisequal;axis([xmin-Lxmax+Lymin-Lymax+L]);%坐標(biāo)軸邊界holdon;set(handles.text11,'string','畫(huà)圖完成');F=0;X=x1;Y=y1;if(y1<=y0&x1>x0)Mx=ceil((x1-x2)/L)+ceil(2*abs(x0+r-x1)/L);elseif(x2<x0&y0>=y2)Mx=ceil((x1-x2)/L)+ceil(2*abs(x2-x0+r)/L);elseMx=ceil((x1-x2)/L);endif(x2<x0&x0<x1)My=ceil(abs(y0+r-y1)/L)+ceil(abs(y0+r-y2)/L);elseMy=ceil(abs(y1-y2)/L);endM=Mx+My;%計(jì)算插補(bǔ)步數(shù)end%---Executesonbuttonpressinpushbutton3.functionpushbutton5_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalxyrx0y0MFXYL;ifM<=0set(handles.text11,'string','插補(bǔ)結(jié)束!');elseifX>=x0ifY>=y0%相對(duì)于圓心在第一象限內(nèi)插補(bǔ)ifF>=0%圓外X=X-L;x=linspace(X+L,X,100);y=x.*0+Y;plot(x,y,'r')F=(X-x0)^2+(Y-y0)^2-r^2;else%圓內(nèi)Y=Y+L;y=linspace(Y-L,Y,100);x=y.*0+X;plot(x,y,'r')F=(X-x0)^2+(Y-y0)^2-r^2;endelse%相對(duì)于圓心在第四象限內(nèi)插補(bǔ)ifF>=0%圓外Y=Y+L;y=linspace(Y-L,Y,100);x=y.*0+X;plot(x,y,'r');F=(X-x0)^2+(Y-y0)^2-r^2;else%圓內(nèi)X=X+L;x=linspace(X-L,X,100);y=x.*0+Y;plot(x,y,'r');F=(X-x0)^2+(Y-y0)^2-r^2;endendelseifY>=y0;%第二象限ifF>=0%圓外Y=Y-L;y=linspace(Y+L,Y,100);x=y.*0+X;plot(x,y,'r');F=(X-x0)^2+(Y-y0)^2-r^2;else%圓內(nèi)X=X-L;x=linspace(X+L,X,100);y=x.*0+Y;plot(x,y,'r');F=(X-x0)^2+(Y-y0)^2-r^2;endelse%第三象限ifF>=0%圓外X=X+L;x=linspace(X-L,X,100);y=x.*0+Y;plot(x,y,'r');F=(X-x0)^2+(Y-y0)^2-r^2;else%圓內(nèi)Y=Y-L;y=linspace(Y+L,Y,100);x=y.*0+X;plot(x,y,'r');F=(X-x0)^2+(Y-y0)^2-r^2;endendendM=M-1;end%---Executesonbuttonpressinpushbutton6.functionpushbutton6_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton6(seeGCBO)%

溫馨提示

  • 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ù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論