




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
機床數控技術課程設計說明書指導老師:姓名:班級:學號:2014/01/10目錄一課設任務1二課設要求1三編程語言1四變量說明及程序界面1〔一〕DDA第四象限直線插補變量說明1〔二〕逐點比擬法第1~2象限逆圓弧插補變量說明2〔三〕DDA第四象限直線插補程序界面3〔1〕普通DDA……………...3〔2〕全加載…………………3〔3〕半加載………………...4〔四〕逐點比擬法第1~2象限逆圓弧插補程序界面4五詳細程序設計流程圖………..5〔一〕DDA第四象限直線插補流程圖………………….5〔二〕逐點比擬法第1~2象限逆圓弧插補流程圖………….6六源程序6七參考資料32一課設任務〔1〕DDA法插補第四象限直線;〔2〕逐點比擬法插補第1~2象限順圓弧。二課設要求〔1〕具有數據輸入界面,如起點、終點、圓心、半徑及插補步長等;〔2〕具有插補過程的動態(tài)顯示功能,如單步插補、連續(xù)插補;〔3〕插補的步長可調;三編程語言:MATLAB四變量說明及程序界面〔一〕DDA第四象限直線插補變量名稱說明變量名稱說明X1直線起點橫坐標JvxX被積函數存放器Y1直線起點縱坐標Jrx1X普通DDA積分累加器X2直線終點橫坐標Jrx2X全加載積分累加器Y2直線終點縱坐標Jrx3X半加載積分累加器x繪圖動點橫坐標JvyY被積函數存放器y繪圖動點縱坐標Jry1Y普通DDA積分累加器L插補步長Jry2Y全加載積分累加器N存放器位數Jry3Y半加載積分累加器MxX終點判別計數器X插補動點橫坐標MyY終點判別計數器Y插補動點縱坐標〔二〕逐點比擬法第2~1象限順圓弧插補變量名稱說明變量名稱說明X1圓弧起點橫坐標E終點判別計數器Y1圓弧起點縱坐標F偏差判別x繪圖動點橫坐標X插補動點橫坐標y繪圖動點縱坐標Y插補動點縱坐標r圓弧半徑MxX插補步數X2圓弧終點橫坐標MyY插補步數Y2圓弧終點縱坐標L插補步長A圓心到弦中點的距離a1圓弧起點角坐標x0圓心橫坐標a2圓弧終點角坐標y0圓心縱坐標a繪圖動點角坐標程序界面:〔三〕DDA第四象限直線插補〔1〕普通DDA〔2〕全加載半加載〔四〕逐點比擬第1~2象限逆圓弧插補五詳細程序設計流程圖DDA第四象限直線插補逐點比擬法第1~2象限逆圓弧插補六源程序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]);%定義坐標軸的邊界set(handles.text11,'string','繪圖完成');Mx=ceil(abs(x2-x1)/L);%計算插補步數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)%直線單步插補%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','請選擇插補方式');elseif(Mx<=0)&(My<=0)set(handles.text11,'string','插補結束');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)%轉化后直線在第一象限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)%轉化后直線在第二象限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)%轉化后直線在第三象限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%轉化后直線在第四象限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ù)插補%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','請選擇插補方式');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','插補結束');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);%圓心到弦中點的長度ifsqrt(((x2-x1)^2+(y2-y1)^2))>(2*r)set(handles.text11,'string','無法構成圓弧');elsex0=(x1+x2)/2+A*(y1-y2)/sqrt((x2-x1)^2+(y2-y1)^2);%圓心坐標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]);%坐標軸邊界holdon;set(handles.text11,'string','畫圖完成');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;%計算插補步數end%---Executesonbuttonpressinpushbutton3.functionpushbutton5_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalxyrx0y0MFXYL;ifM<=0set(handles.text11,'string','插補結束!');elseifX>=x0ifY>=y0%相對于圓心在第一象限內插補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%圓內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%相對于圓心在第四象限內插補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%圓內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%圓內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%圓內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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 畢業(yè)生三方就業(yè)合同解析
- 保密合作研發(fā)合同
- 房產贈與合同模板:父母與子女
- 員工合同終止協(xié)商一致書
- 委托代理合同專兼職律師版
- 地鐵站內廣告牌租賃合同
- 度水果貿易合同書
- 保密協(xié)議合同英文樣本
- Module 6 Unit 2 Happy Mid-Autumn Festival(教學設計)-2024-2025學年外研版(三起)英語四年級上冊
- 9《清明》教學設計-2023-2024學年三年級下冊語文統(tǒng)編版
- 諾如病毒-感染性腹瀉預防控制知識課件
- 醫(yī)療器械供貨企業(yè)質量保證體系調查表(模板)
- 春節(jié)后復工安全檢查表
- 《第一章 體育與健康理論知識課件》初中體育與健康
- 客戶關系管理全套ppt課件(完整版)
- 福尼亞胰島素泵操作介紹
- 工程倫理-第章工程與倫理通用PPT課件
- 病理學第二節(jié)細胞和組織損傷的原因和機制
- 稻谷品質測定指標及方法
- 小學四年級上冊口算題大全800題(口算天天練)
- 醫(yī)院醫(yī)保月結算報表
評論
0/150
提交評論