Mathematica中文论坛-非官方

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 9226|回复: 0
打印 上一主题 下一主题

matlab 散点边界,外表面, boundary, alphashape 儿子的papa

[复制链接]

532

主题

602

帖子

3031

积分

论坛元老

Rank: 8Rank: 8

积分
3031
跳转到指定楼层
楼主
发表于 2016-6-14 21:03:00 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 meatball1982 于 2016-6-14 21:06 编辑

用matlab 找散点的表面。3D或是2D.有boundary函数和 alphaShape函数。

  1. clear all
  2. clc
  3. clf

  4. %% outline
  5. % find the out surface of vdw points

  6. %% main
  7. % % % load position of LYS
  8. % % pos=load('../data/LYS/LYS_xyz');
  9. % %
  10. % % n_at=length(pos(:,1));
  11. % %
  12. % % tm=load('../data/LYS/LYS_vdw.txt');
  13. % % r_mat=tm(:,3)/2;
  14. % %
  15. % % save Mat_post_pos_rand.mat pos r_mat

  16. %% load data
  17. load Mat_post_pos_rand.mat
  18. n_at=length(pos(:,1));

  19. % sphere surface ---------------------------------
  20. [sp_x,sp_y,sp_z]=sphere(30);
  21. [n_sp_x,n_sp_y]=size(sp_x);

  22. % for store points pos
  23. x_mat=[];
  24. y_mat=[];
  25. z_mat=[];

  26. for i=1:n_at
  27.     % generate sphere surface points -------------
  28.     at_x=sp_x*r_mat(i)+pos(i,1);
  29.     at_y=sp_y*r_mat(i)+pos(i,2);
  30.     at_z=sp_z*r_mat(i)+pos(i,3);
  31.    
  32.     x_mat=[x_mat;at_x(:)];
  33.     y_mat=[y_mat;at_y(:)];
  34.     z_mat=[z_mat;at_z(:)];
  35. end




  36. % % boundary version ------------------------------------
  37. % % boundary 2D------------------
  38. % n_layer=61;
  39. % z_lin=linspace(min(unique(z_mat)),max(unique(z_mat)),n_layer);
  40. %
  41. % for i=1:(n_layer-1)
  42. %     ind=z_lin(i)<=z_mat & z_mat< z_lin(i+1);
  43. %     x_lay=x_mat(ind);
  44. %     y_lay=y_mat(ind);
  45. %     z_lay=z_mat(ind);
  46. %     clf
  47. %     h=gcf;
  48. %     set(h,'position',[1100,100,400, 300]);
  49. %     plot(x_lay,y_lay,'.')
  50. %     axis equal
  51. %     k=boundary(x_lay,y_lay,0.8);
  52. %     hold on
  53. %     plot(x_lay(k),y_lay(k),'r-');
  54. %     axis equal
  55. %     axis tight
  56. %     axis([-5 7 -6 7])
  57. % %     h=gcf;
  58. % %     fig_na=['../imgs/LYS/VDW/boundary/fig_points_2D_',mat2str(i)];
  59. % %     fun_work_li_035_myfig_out(h,fig_na,3);
  60. % end

  61. % % boundary 3D ------------------
  62. % k=boundary([x_mat';y_mat';z_mat']');
  63. % h=gcf;
  64. % set(h,'position',[1100,100,800, 600]);
  65. % plot3(x_mat(k),y_mat(k),z_mat(k),'r.')
  66. % axis equal
  67. % axis tight
  68. % view(-20,30)
  69. % % h=gcf;
  70. % % fig_na=['../imgs/LYS/VDW/boundary/fig_boundary_3D'];
  71. % % fun_work_li_035_myfig_out(h,fig_na,3);


  72. % % alphaShape version -----------------------------------
  73. % shp=alphaShape(x_mat,y_mat,z_mat,0.55);
  74. % % boundary surface points ind
  75. % ind=unique(shp.boundaryFacets);
  76. % shp_P=shp.Points;
  77. %
  78. % h=gcf;
  79. % set(h,'position',[1100,100,800, 600]);
  80. %
  81. % plot3(x_mat,y_mat,z_mat,'b.')
  82. % % plot3(shp_P(ind,1),shp_P(ind,2),shp_P(ind,3),'r.')
  83. % plot(shp,'edgecolor','none','facecolor','r','facealpha',0.4)
  84. % axis equal
  85. % axis tight
  86. % view(-20,30)
  87. % % h=gcf;
  88. % % fig_na=['../imgs/LYS/VDW/fig_alphashape_3D'];
  89. % % fun_work_li_035_myfig_out(h,fig_na,3);
  90. %
  91. % plot3(x_mat,y_mat,z_mat,'b.')
  92. % axis equal
  93. % axis tight
  94. % view(-20,30)
  95. % % h=gcf;
  96. % % fig_na=['../imgs/LYS/VDW/fig_points_3D'];
  97. % % fun_work_li_035_myfig_out(h,fig_na,3);
  98. %
  99. %
  100. % plot3(shp_P(ind,1),shp_P(ind,2),shp_P(ind,3),'r.')
  101. % axis equal
  102. % axis tight
  103. % view(-20,30)
  104. % % h=gcf;
  105. % % fig_na=['../imgs/LYS/VDW/fig_alphashape_3D_poi'];
  106. % % fun_work_li_035_myfig_out(h,fig_na,3);

  107. %% logs
复制代码


fig_points_3D.jpg (502.38 KB, 下载次数: 804)

fig_points_3D.jpg

fig_alphashape_3D_poi.jpg (439.11 KB, 下载次数: 817)

fig_alphashape_3D_poi.jpg

Mat_post_pos_rand.mat.zip

1.05 KB, 下载次数: 1

数据。

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|Mathematica中文论坛-非官方 ( 辽ICP备16001491号-1

GMT+8, 2024-4-28 18:41 , Processed in 0.127667 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表