贝塞尔曲线绘图方法:

%Program 3.7 Freehand Draw Program Using Bezier Splines
%Click in Matlab figure window to locate first point, and click
% three more times to specify 2 control points and the next
% spline point. Continue with groups of 3 points to add more
% to the curve. Press return to terminate program.
%% This fuction is different from the text book written by the editor of the book.
%% Apart from the original functions, Dr. Wang has added its own codes to the function
%% in order to 1) move the entire graph to positive; 2)
function modifiedbezierdraw
clear all;
close all
clc
plot([0 2],[1,1],'k',[1 1],[0 2],'k');hold on %% Modified to move the entire graph to positive.
%imshow('1588.jpg');hold on
t=0:.02:1;
xlist=[]; ylist=[]; %% Used to store the coordinate list.
[x,y]=ginput(1); % get one mouse click
xlist(1)=x; ylist(1)=y; %% Starting coordinate
while(0 == 0)
[xnew,ynew] = ginput(3); % get three mouse clicks
if length(xnew) < 3
break % if return pressed, terminate
end
xlist(length(xlist)+1:length(xlist)+3)=xnew; ylist(length(ylist)+1:length(ylist)+3)=ynew; %% Store the current three coordinates
x=[x;xnew];y=[y;ynew]; % plot spline points and control pts
plot([x(1) x(2)],[y(1) y(2)],'r:',x(2),y(2),'rs');
plot([x(3) x(4)],[y(3) y(4)],'r:',x(3),y(3),'rs');
plot(x(1),y(1),'bo',x(4),y(4),'bo');
bx=3*(x(2)-x(1)); by=3*(y(2)-y(1)); % spline equations ...
cx=3*(x(3)-x(2))-bx;cy=3*(y(3)-y(2))-by;
dx=x(4)-x(1)-bx-cx;dy=y(4)-y(1)-by-cy;
xp=x(1)+t.*(bx+t.*(cx+t*dx)); % Horner's method
yp=y(1)+t.*(by+t.*(cy+t*dy));
plot(xp,yp) % plot spline curve
x=x(4);y=y(4); % promote last to first and repeat
end
hold off
%% The remaining codes are used to store the coordinates
%% and write them in the format of .txt which can be directly used in PDF.
save('xylist.mat','xlist','ylist');
xlist=xlist*300;
ylist=ylist*300;
fid=fopen('fontmat.txt','w');
for i=0:(length(xlist)-1)/3-1
fprintf(fid,'%d %d %d %d %d %d %d %d c\n',fix(xlist(i*3+1)), fix(ylist(i*3+1)), fix(xlist(i*3+2)), fix(ylist(i*3+2)), fix(xlist(i*3+3)), fix(ylist(i*3+3)), fix(xlist(i*3+4)), fix(ylist(i*3+4)));
end
fclose(fid);

pdf使用1.7老版本的定义:

注意stream区间,第一行m为起点,即第一行c的首两个整数。使用程序会得到一份txt文件。复制并替换带c的行数即可。末尾S需保留。

%PDF-1.7
1 0 obj
<<
/Length 2 0 R
>>
stream
151 421 m
151 421 150 411 169 406 179 406 c
179 406 195 406 261 404 396 409 c
396 409 369 378 343 365 183 323 c
183 323 206 306 328 321 373 327 c
373 327 355 285 219 264 134 241 c
134 241 180 227 349 228 408 228 c
408 228 434 214 429 109 420 95 c
420 95 401 99 400 111 398 125 c
398 125 378 178 299 465 284 493 c
284 493 284 430 282 149 279 102 c
S
endstream
endobj
2 0 obj
1000
endobj
4 0 obj
<<
/Type /Page
/Parent 5 0 R
/Contents 1 0 R
>>
endobj
5 0 obj
<<
/Kids [4 0 R]
/Count 1
/Type /Pages
/MediaBox [0 0 612 792]
>>
endobj
3 0 obj
<<
/Pages 5 0 R
/Type /Catalog
>>
endobj
xref
0 6
0000000000 65535 f
0000000100 00000 n
0000000200 00000 n
0000000500 00000 n
0000000300 00000 n
0000000400 00000 n
trailer
<<
/Size 6
/Root 3 0 R
>>
startxref
1000
%%EOF

matlab实现贝塞尔曲线绘图pdf查看的更多相关文章

  1. matlab练习程序(贝塞尔曲线)

    下面三个公式分别是一次.二次和三次贝塞尔曲线公式: 通用的贝塞尔曲线公式如下: 可以看出,系数是由一个杨辉三角组成的. 这里的一次或者二次三次由控制点个数来决定,次数等于控制点个数-1. 实现的效果如 ...

  2. 深度掌握SVG路径path的贝塞尔曲线指令

    一.数字.公式.函数.变量,哦,NO! 又又一次说起贝塞尔曲线(英语:Bézier curve,维基百科详尽中文释义戳这里),我最近在尝试实现复杂的矢量图形动画,发现对贝塞尔曲线的理解馒头那么厚,是完 ...

  3. canvas贝塞尔曲线

    贝塞尔曲线 Bézier curve(贝塞尔曲线)是应用于二维图形应用程序的数学曲线. 曲线定义:起始点.终止点.控制点.通过调整控制点,贝塞尔曲线的形状会发生变化. 1962年,法国数学家Pierr ...

  4. 贝塞尔曲线(UIBezierPath)属性、方法汇总

    UIBezierPath主要用来绘制矢量图形,它是基于Core Graphics对CGPathRef数据类型和path绘图属性的一个封装,所以是需要图形上下文的(CGContextRef),所以一般U ...

  5. iOS开发之画图板(贝塞尔曲线)

    贝塞尔曲线,听着挺牛气一词,不过下面我们在做画图板的时候就用到贝塞尔绘直线,没用到绘制曲线的功能.如果会点PS的小伙伴会对贝塞尔曲线有更直观的理解.这篇博文的重点不在于如何用使用贝塞尔曲线,而是利用贝 ...

  6. 用html5的canvas画布绘制贝塞尔曲线

    查看效果:http://keleyi.com/keleyi/phtml/html5/7.htm 完整代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHT ...

  7. iOS开发 贝塞尔曲线

    iOS开发 贝塞尔曲线UIBezierPath - 陌云 时间 2014-03-14 11:04:00  博客园-所有随笔区 原文  http://www.cnblogs.com/moyunmo/p/ ...

  8. iOS开发 贝塞尔曲线UIBezierPath

    最近项目中需要用到用贝塞尔曲线去绘制路径 ,然后往路径里面填充图片,找到这篇文章挺好,记录下来 自己学习! 转至 http://blog.csdn.net/guo_hongjun1611/articl ...

  9. Android中贝塞尔曲线的绘制方法

    贝塞尔曲线,很多人可能不太了解,什么叫做贝塞尔曲线呢?这里先做一下简单介绍:贝塞尔曲线也可以叫做贝济埃曲线或者贝兹曲线,它由线段与节点组成,节点是可拖动的支点,线段像可伸缩的皮筋.一般的矢量图形软件常 ...

随机推荐

  1. 以NameValueCollection 修改URL中的查询参数

    以NameValueCollection 修改URL中的查询参数 本文参考于:http://www.c-sharpcorner.com/Blogs/9421/add-remove-or-modify- ...

  2. Kinect For Windows V2开发日志四:使用OpenCV显示深度图像

    代码示例: #include <Kinect.h> #include <iostream> #include <opencv2\highgui.hpp> using ...

  3. 为Asp.Net Web Api添加Http基本认证

    Asp.net Web Api提供了RESTFul web服务的编程接口.默认RESTFul 服务没有提供任何验证或者基于角色的验证,这显然不适合Put.Post.Delete这些操作.Aps.net ...

  4. codeforces 676C C. Vasya and String(二分)

    题目链接: C. Vasya and String time limit per test 1 second memory limit per test 256 megabytes input sta ...

  5. hdu 4612 Warm up 桥缩点

    4612Warm hdu up 题目:给出一个图,添加一条边之后,问能够在新图中得到的最少的桥的数量. 分析:我们可以双联通分量进行缩点,原图变成了一棵树.问题变成了:求树中添加一条边之后,使得不在圈 ...

  6. Linux之apt-get无sudo权限安装软件

    apt-get source package cd package ./configure --prefix=$HOME make make install

  7. Understand

    快捷键: Ctrl+Shift+H 折叠 Ctrl+Alt+F 替换

  8. AjaxPro.2使用小结

    这是我最近没事的时候研究的东东,使用AjaxPro.2.dll,从前台调用后台Ajax方法,希望对各位亲有帮助哦.. 1.首先将AjaxPro.2.dll从网上下载下来,打开VS项目,点击项目,右键- ...

  9. Android Studio 1.3新版体验

    Google发布的Android Studio最新版是 1.3 版,上周的I/O大会中三位Google工程师对Android Studio作了将近1小时的演讲: 之前一直习惯用Eclipse luna ...

  10. hihocoder#1054 : 滑动解锁(深度优先搜索)

    描述 滑动解锁是智能手机一项常用的功能.你需要在3x3的点阵上,从任意一个点开始,反复移动到一个尚未经过的"相邻"的点.这些划过的点所组成的有向折线,如果与预设的折线在图案.方向上 ...