📄 getcurv2.html
字号:
<html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document. --> <title>Spline curves</title> <meta name="generator" content="MATLAB 7.1"> <meta name="date" content="2005-07-27"> <meta name="m-file" content="getcurv2"> <link rel="stylesheet" type="text/css" href="../../matlab/demos/private/style.css"> </head> <body> <div class="header"> <div class="left"><a href="matlab:edit getcurv2">Open getcurv2.m in the Editor</a></div> <div class="right"><a href="matlab:echodemo getcurv2">Run in the Command Window</a></div> </div> <div class="content"> <h1>Spline curves</h1> <introduction> <p>Demonstrating the use of CSCVN.</p> </introduction> <h2>Contents</h2> <div> <ul> <li><a href="#1">Selecting the points</a></li> <li><a href="#2">Connecting the points</a></li> <li><a href="#3">3-D spline curves</a></li> <li><a href="#4">Connecting the points</a></li> </ul> </div> <h2>Selecting the points<a name="1"></a></h2> <p>The spline toolbox will draw a smooth curve through a list of points, in the order in which they are received. You could use the Spline Toolbox command GETCURVE if you wanted the input such a list of points interactively. Here, we select random points, storing them in the array XY, one point per c o l u m n . </p><pre class="codeinput">npts = 10;xy = [randn(1,npts); randn(1,npts)];plot(xy(1,:),xy(2,:),<span class="string">'ro'</span>,<span class="string">'LineWidth'</span>,2);text(xy(1,:), xy(2,:),[repmat(<span class="string">' '</span>,npts,1), num2str((1:npts)')])set(gca,<span class="string">'XTick'</span>,[],<span class="string">'YTick'</span>,[])</pre><img vspace="5" hspace="5" src="getcurv2_01.png"> <h2>Connecting the points<a name="2"></a></h2> <p>The curve is constructed by</p><pre>>> cv = cscvn(xy);</pre><p>and plotted by</p><pre>>> fnplt(cv,'r',2)</pre><pre class="codeinput">hold <span class="string">on</span>fnplt(cscvn(xy),<span class="string">'r'</span>,2)hold <span class="string">off</span></pre><img vspace="5" hspace="5" src="getcurv2_02.png"> <h2>3-D spline curves<a name="3"></a></h2> <p>Notice that it's just as easy to create spline curves in three dimensions. This time, we'll do something less random. First, we generate the points: </p><pre class="codeinput">npts = 13;t = linspace(0,8*pi,npts); z = linspace(-1,1,npts); omz = sqrt(1-z.^2);xyz = [cos(t).*omz; sin(t).*omz; z];plot3(xyz(1,:),xyz(2,:),xyz(3,:),<span class="string">'ro'</span>,<span class="string">'LineWidth'</span>,2);text(xyz(1,:),xyz(2,:),xyz(3,:),[repmat(<span class="string">' '</span>,npts,1), num2str((1:npts)')])set(gca,<span class="string">'XTick'</span>,[],<span class="string">'YTick'</span>,[],<span class="string">'ZTick'</span>,[])box <span class="string">on</span></pre><img vspace="5" hspace="5" src="getcurv2_03.png"> <h2>Connecting the points<a name="4"></a></h2> <p>Here is the 3D spline curve through these points provided by CSCVN. By appending the first point to the end of the list, we get a smooth c l o s e d curve. </p><pre class="codeinput">hold <span class="string">on</span>fnplt(cscvn(xyz(:,[1:end 1])),<span class="string">'r'</span>,2)hold <span class="string">off</span><span class="comment">% axis vis3d</span></pre><img vspace="5" hspace="5" src="getcurv2_04.png"> <p class="footer">Copyright 1987-2005 C. de Boor and The MathWorks, Inc.<br> Published with MATLAB® 7.1<br></p> </div> <!--##### SOURCE BEGIN #####%% Spline curves% Demonstrating the use of CSCVN.% Copyright 1987-2005 C. de Boor and The MathWorks, Inc.% $Revision: 1.16.4.2 $%% Selecting the points% The spline toolbox will draw a smooth curve through a list of points, in% the order in which they are received.% You could use the Spline Toolbox command GETCURVE if you wanted the input% such a list of points interactively.% Here, we select random points, storing them in the array XY,% one point per c o l u m n .npts = 10;xy = [randn(1,npts); randn(1,npts)];plot(xy(1,:),xy(2,:),'ro','LineWidth',2);text(xy(1,:), xy(2,:),[repmat(' ',npts,1), num2str((1:npts)')])set(gca,'XTick',[],'YTick',[])%% Connecting the points% The curve is constructed by%% >> cv = cscvn(xy);%% and plotted by%% >> fnplt(cv,'r',2)hold onfnplt(cscvn(xy),'r',2)hold off%% 3-D spline curves% Notice that it's just as easy to create spline curves in three dimensions.% This time, we'll do something less random. First, we generate the points:npts = 13;t = linspace(0,8*pi,npts); z = linspace(-1,1,npts); omz = sqrt(1-z.^2);xyz = [cos(t).*omz; sin(t).*omz; z];plot3(xyz(1,:),xyz(2,:),xyz(3,:),'ro','LineWidth',2);text(xyz(1,:),xyz(2,:),xyz(3,:),[repmat(' ',npts,1), num2str((1:npts)')])set(gca,'XTick',[],'YTick',[],'ZTick',[])box on%% Connecting the points% Here is the 3D spline curve through these points provided by CSCVN.% By appending the first point to the end of the list,% we get a smooth c l o s e d curve.hold onfnplt(cscvn(xyz(:,[1:end 1])),'r',2)hold off% axis vis3ddisplayEndOfDemoMessage(mfilename)##### SOURCE END #####--> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -