贝塞尔曲线绘图方法:

  1. %Program 3.7 Freehand Draw Program Using Bezier Splines
  2. %Click in Matlab figure window to locate first point, and click
  3. % three more times to specify 2 control points and the next
  4. % spline point. Continue with groups of 3 points to add more
  5. % to the curve. Press return to terminate program.
  6. %% This fuction is different from the text book written by the editor of the book.
  7. %% Apart from the original functions, Dr. Wang has added its own codes to the function
  8. %% in order to 1) move the entire graph to positive; 2)
  9. function modifiedbezierdraw
  10. clear all;
  11. close all
  12. clc
  13. plot([0 2],[1,1],'k',[1 1],[0 2],'k');hold on %% Modified to move the entire graph to positive.
  14. %imshow('1588.jpg');hold on
  15. t=0:.02:1;
  16. xlist=[]; ylist=[]; %% Used to store the coordinate list.
  17. [x,y]=ginput(1); % get one mouse click
  18. xlist(1)=x; ylist(1)=y; %% Starting coordinate
  19. while(0 == 0)
  20. [xnew,ynew] = ginput(3); % get three mouse clicks
  21. if length(xnew) < 3
  22. break % if return pressed, terminate
  23. end
  24. xlist(length(xlist)+1:length(xlist)+3)=xnew; ylist(length(ylist)+1:length(ylist)+3)=ynew; %% Store the current three coordinates
  25. x=[x;xnew];y=[y;ynew]; % plot spline points and control pts
  26. plot([x(1) x(2)],[y(1) y(2)],'r:',x(2),y(2),'rs');
  27. plot([x(3) x(4)],[y(3) y(4)],'r:',x(3),y(3),'rs');
  28. plot(x(1),y(1),'bo',x(4),y(4),'bo');
  29. bx=3*(x(2)-x(1)); by=3*(y(2)-y(1)); % spline equations ...
  30. cx=3*(x(3)-x(2))-bx;cy=3*(y(3)-y(2))-by;
  31. dx=x(4)-x(1)-bx-cx;dy=y(4)-y(1)-by-cy;
  32. xp=x(1)+t.*(bx+t.*(cx+t*dx)); % Horner's method
  33. yp=y(1)+t.*(by+t.*(cy+t*dy));
  34. plot(xp,yp) % plot spline curve
  35. x=x(4);y=y(4); % promote last to first and repeat
  36. end
  37. hold off
  38. %% The remaining codes are used to store the coordinates
  39. %% and write them in the format of .txt which can be directly used in PDF.
  40. save('xylist.mat','xlist','ylist');
  41. xlist=xlist*300;
  42. ylist=ylist*300;
  43. fid=fopen('fontmat.txt','w');
  44. for i=0:(length(xlist)-1)/3-1
  45. 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)));
  46. end
  47. fclose(fid);

pdf使用1.7老版本的定义:

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

  1. %PDF-1.7
  2. 1 0 obj
  3. <<
  4. /Length 2 0 R
  5. >>
  6. stream
  7. 151 421 m
  8. 151 421 150 411 169 406 179 406 c
  9. 179 406 195 406 261 404 396 409 c
  10. 396 409 369 378 343 365 183 323 c
  11. 183 323 206 306 328 321 373 327 c
  12. 373 327 355 285 219 264 134 241 c
  13. 134 241 180 227 349 228 408 228 c
  14. 408 228 434 214 429 109 420 95 c
  15. 420 95 401 99 400 111 398 125 c
  16. 398 125 378 178 299 465 284 493 c
  17. 284 493 284 430 282 149 279 102 c
  18. S
  19. endstream
  20. endobj
  21. 2 0 obj
  22. 1000
  23. endobj
  24. 4 0 obj
  25. <<
  26. /Type /Page
  27. /Parent 5 0 R
  28. /Contents 1 0 R
  29. >>
  30. endobj
  31. 5 0 obj
  32. <<
  33. /Kids [4 0 R]
  34. /Count 1
  35. /Type /Pages
  36. /MediaBox [0 0 612 792]
  37. >>
  38. endobj
  39. 3 0 obj
  40. <<
  41. /Pages 5 0 R
  42. /Type /Catalog
  43. >>
  44. endobj
  45. xref
  46. 0 6
  47. 0000000000 65535 f
  48. 0000000100 00000 n
  49. 0000000200 00000 n
  50. 0000000500 00000 n
  51. 0000000300 00000 n
  52. 0000000400 00000 n
  53. trailer
  54. <<
  55. /Size 6
  56. /Root 3 0 R
  57. >>
  58. startxref
  59. 1000
  60. %%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. BC Harry and Magical Computer (拓扑排序)

    Harry and Magical Computer  Accepts: 350  Submissions: 1348  Time Limit: 2000/1000 MS (Java/Others) ...

  2. 剑指Offer13 链表倒数第K个结点

    /************************************************************************* > File Name: 13_KthNod ...

  3. 5059 一起去打CS

    5059 一起去打CS  时间限制: 1 s  空间限制: 32000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 早就和lyk约好了去 ...

  4. C#之ArrayList

    using System.Collections; 新建: ArrayList list = new ArrayList(); 添加元素: int a = 1; list.Add(a); 遍历: fo ...

  5. 文件上传利器SWFUpload入门简易教程

    凡做过网站开发的都应该知道表单file的确鸡肋. Ajax解决了不刷新页面提交表单,但是却没有解决文件上传不刷新页面,当然也有其它技术让不刷新页面而提交文件,该技术主要是利用隐藏的iFrame, 较A ...

  6. 三、android中Handle类的用法

    当我们在处理下载或是其他需要长时间执行的任务时,如果直接把处理函数放Activity的OnCreate或是OnStart中,会导致执行过程中整个Activity无响应,如果时间过长,程序还会挂掉.Ha ...

  7. 收藏的js学习小例子

    1.js模拟java里的Map function Map(){ var obj = {} ; this.put = function(key , value){ obj[key] = value ; ...

  8. asp.net中c# TextBox.MaxLength例子

    TextBox.MaxLength 属性获取或设置文本框中最多允许的字符数文本框中最多允许的字符数.默认值为 0,表示未设置该属性.使用 MaxLength 属性限定可以在 TextBox 控件中输入 ...

  9. C# lock用法

    当我们使用线程的时候,效率最高的方式当然是异步,即各个线程同时运行,其间不相互依赖和等待.但当不同的线程都需要访问某个资源的时候,就需要同步机制了,也就是说当对同一个资源进行读写的时候,我们要使该资源 ...

  10. iOS 中对各种视图的截屏以及分享

    1.一个第三方的工具,主要是对表视图.滚动视图.视图的扩展,用法也很简单 image = [tableview screenshot]; 2.然后将截的图片分享出去,在分享的时候,因为多个地方用到了截 ...