⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yanxing.m

📁 采用MATLAB编写B样条绘制程序
💻 M
字号:
function varargout = yanxing_20042546(varargin)%YANXING M-file for yanxing.fig%      YANXING, by itself, creates a create YANXING or raises the existing%      singleton*.%%      H = YANXING returns the handle to a create YANXING or the handle to%      the existing singleton*.%%      YANXING('Property','Value',...) creates a create YANXING using the%      given property value pairs. Unrecognized properties are passed via%      varargin to yanxing_OpeningFcn.  This calling syntax produces a%      warning when there is an existing singleton*.%%      YANXING('CALLBACK') and YANXING('CALLBACK',hObject,...) call the%      local function named CALLBACK in YANXING.M with the given input%      arguments.%%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one%      instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help yanxing% Last Modified by GUIDE v2.5 09-Nov-2007 15:54:34% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @yanxing_OpeningFcn, ...                   'gui_OutputFcn',  @yanxing_OutputFcn, ...                   'gui_LayoutFcn',  [], ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})   gui_State.gui_Callback = str2func(varargin{1});endif nargout    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else    gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before yanxing is made visible.function yanxing_OpeningFcn(hObject, eventdata, handles, varargin)handles.output = hObject;% Update handles structureguidata(hObject, handles);% --- Outputs from this function are returned to the command line.function varargout = yanxing_OutputFcn(hObject, eventdata, handles)varargout{1} = handles.output;% --------------------------------------------------------------------function file_Callback(hObject, eventdata, handles)% hObject    handle to file (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in create.function create_Callback(hObject, eventdata, handles)% hObject    handle to create (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)axes(handles.axes1);linePoint=[];index=get(handles.style, 'value');k=get(handles.degree, 'value');k=k+1;style=0;controlPoint=handles.controlPoint;%method=get(hObject,'method')%deg=get(hObject,'degree')switch index    case 1%'均匀'         style=0;    case 2%'准均匀'         style=1;    case 3%'分段贝塞尔'         style=2;                       if fix((length(controlPoint)-1)/k)~=(length(controlPoint)-1)/k            warndlg('数据点数必须为次数的整数倍加1个,请重新输入!');        end    case 4%'非均匀'         style=3;        endlinePoint=Dbordv(controlPoint,k,style);%***************************描点********************************   plot(controlPoint(:,1)',controlPoint(:,2)','-r');hold on%axis manual;axis([0 50 20 50]);   if style==0      bb=[];j=1;      for i=1:length(linePoint)          if norm(linePoint(i,:))~=0              bb(j,:)=linePoint(i,:);              j=j+1;          end      end      plot(bb(:,1)',bb(:,2)','b-');hold on       else   plot(linePoint(:,1)',(linePoint(:,2))','b-');hold on   %axis manual;axis([0 50 0 50]);   end %endif% --- Executes on button press in clear.function clear_Callback(hObject, eventdata, handles)hold off;plot(0,0);hold onaxis manual;axis([0 50 0 50]);% --- Executes on button press in point.function point_Callback(hObject, eventdata, handles)set(handles.create,'enable','on');axis manual;axis([0 50 0 50]);hold on;%grid onbut = 1;n=0;while but == 1    [xi,yi,but] = ginput(1);    plot(xi,yi,'ro');text(xi+0.2,yi+1,num2str(n));    n = n+1;controlPoint(n,:) = [xi,yi];endhandles.controlPoint=controlPoint;guidata(hObject,handles);% --- Executes on button press in edit.function edit_Callback(hObject, eventdata, handles)% hObject    handle to edit (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on selection change in style.function style_Callback(hObject, eventdata, handles)% --- Executes on button press in grid.function grid_Callback(hObject, eventdata, handles)grid% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes during object creation, after setting all properties.function popupmenu1_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on selection change in degree.function degree_Callback(hObject, eventdata, handles)% --- Executes during object creation, after setting all properties.function degree_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction method_CreateFcn(hObject, eventdata, handles)% Hint: popupmenu controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --------------------------------------------------------------------function save_Callback(hObject, eventdata, handles)% hObject    handle to save (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)file=uiputfile({'*.jpg';'*.fig'},'Save As')%save(handles.figure1,file)% --- Executes on button press in print.function print_Callback(hObject, eventdata, handles)% hObject    handle to print (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in dispOrNot.function dispOrNot_Callback(hObject, eventdata, handles)% hObject    handle to dispOrNot (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of dispOrNot% --------------------------------------------------------------------function help_Callback(hObject, eventdata, handles)% hObject    handle to help (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)helpdlg({'                           CAGD大作业程序','1.	先使用鼠标输入控制顶点,点描点后,左键描点,右键退出','2.选择控制参数,如所绘曲线的类型,次数等','3.使用修改可以修改控制点的位置,点修改后,用鼠标选择需要修改的点;','  再选择新控制点的位置,即可画出新的曲线','4.勾选打印参数,可以在命令窗口得到曲线的控制参数方便进一步处理!','由于时间仓促,可能还有一些未排除的BUG...',});% --------------------------------------------------------------------function about_Callback(hObject, eventdata, handles)% hObject    handle to about (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)helpdlg({'作者:数学2班 07110402',' 颜星(20042546)','时间:2007.11.09','  yanxing@bit.edu.cn'});

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -