贝塞尔曲线绘图方法:

%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. ServiceLoader的使用

    ServiceLoader与ClassLoader是Java中2个即相互区别又相互联系的加载器.JVM利用ClassLoader将类载入内存,这是一个类声明周期的第一步(一个java类的完整的生命周期 ...

  2. hdu 4738 桥

    题目:还是自己看题目吧 trick:当不连通时不需要人去炸.否则,当桥的费用为0时当然需要一个人去炸... #include <set> #include <map> #inc ...

  3. CSS3笔记

    CSS/CSS3在线手册:http://www.css119.com/book/css/   CSS3实现水平垂直居中:http://bbs.html5cn.org/thread-87300-1-1. ...

  4. Asp.Net复习篇之Asp.Net生命周期与Asp.Net页的生命周期

    Asp.Net生命周期与Asp.Net页的生命周期是一个比较重要的话题,有时可能似乎知道一些,但又说不出个所以然,而且时常把这两个概念混淆.现在也是该好好理清思路,把这两个概念搞懂. Asp.Net生 ...

  5. 【转】Ajax 基础学习

    今天简单的学习了 Ajax 的基础知识,总结在这里.部分代码不是原创,特此说明. [Ajax 简介] AJAX = Asynchronous JavaScript and XML(异步的 JavaSc ...

  6. C# 输出24小时格式时间

    比如   MessageBox.Show(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")); 会输出  2014-4-3 5:08:4[1 ...

  7. shell 脚本执行,出现错误bad interpreter: No such file or directory

    出现bad interpreter:No such file or directory的原因是文件格式的问题.这个文件是在Windows下编写的.换行的方式与Unix不一样,但是在VI下面如果不Set ...

  8. MVC小例子

    [约定胜于配置] 1. 右键Mode数据层添加新建项,用linq连接数据库 (不要在控制层上直接操控linq,要在数据层新建一个类,来对数据库进行操作) 2. 右键Mode数据层添加类,来完成对数据库 ...

  9. XenApp简单部署

    作者:MR.Yangwj 目录 XenApp简单部署... 1 一.         XenApp安装... 1 (一)      服务器配置任务... 9 1)     许可证服务器配置... 9 ...

  10. [老老实实学WCF] 第九篇 消息通信模式(上) 请求应答与单向

    老老实实学WCF 第九篇 消息通信模式(上) 请求应答与单向 通过前两篇的学习,我们了解了服务模型的一些特性如会话和实例化,今天我们来进一步学习服务模型的另一个重要特性:消息通信模式. WCF的服务端 ...