Y-BH

matlab_logo_LR3D

Apr 16th, 2022 (edited)
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.26 KB | None | 0 0
  1. % 创建 MATLAB 徽标
  2. close all
  3. L = 160*membrane(1,100);
  4. f = figure;f.MenuBar='none';f.Color = 'black';
  5. dpi=1.25;scr=[1920 1080];res=[1600 1000];
  6. fig=gcf;fig.Position=[(scr-res)/2,res]/dpi;
  7. p=[-145.5 -229.7];
  8. t=[77.4 60.2];
  9. pt=norm(p-t);
  10. p1=-123;
  11. p2=t(2)-sqrt(pt^2-(p(1)-t(1))^2);
  12. %% Left
  13. ax1 = axes;
  14. s1 = surface(ax1,L);
  15. s1.EdgeColor = 'none';
  16.  
  17. view(3)
  18. ax1.Clipping='off';
  19. ax1.XLim = [1 201];
  20. ax1.YLim = [1 201];
  21. ax1.ZLim = [-53.4 160];
  22. ax1.CameraPosition = [-145.5 -229.7 283.6];
  23. ax1.CameraTarget = [77.4 60.2 63.9];
  24. ax1.CameraUpVector = [0 0 1];
  25. ax1.CameraViewAngle = 36.7;
  26. ax1.Position = [0 0 0.5 1];
  27. ax1.DataAspectRatio = [1 1 .9];
  28. l1 = light;
  29. l1.Position = [160 400 80];
  30. l1.Style = 'local';
  31. l1.Color = [0 0.8 0.8];
  32.  
  33. l2 = light;
  34. l2.Position = [.5 -1 .4];
  35. l2.Color = [0.8 0.8 0];
  36. s1.FaceColor = [0.9 0.2 0.2];
  37. s1.FaceLighting = 'gouraud';
  38. s1.AmbientStrength = 0.3;
  39. s1.DiffuseStrength = 0.6;
  40. s1.BackFaceLighting = 'lit';
  41.  
  42. s1.SpecularStrength = 1;
  43. s1.SpecularColorReflectance = 1;
  44. s1.SpecularExponent = 7;
  45. axis off
  46. %% Right
  47. ax2 = axes;
  48. s2 = surface(ax2,L);
  49. s2.EdgeColor = 'none';
  50.  
  51. view(3)
  52. ax2.Clipping='off';
  53. ax2.XLim = [1 201];
  54. ax2.YLim = [1 201];
  55. ax2.ZLim = [-53.4 160];
  56. ax2.CameraPosition = [p1 p2 283.6];
  57. ax2.CameraTarget = [77.4 60.2 63.9];
  58. ax2.CameraUpVector = [0 0 1];
  59. ax2.CameraViewAngle = 36.7;
  60. ax2.Position = [0.5 0 0.5 1];
  61. ax2.DataAspectRatio = [1 1 .9];
  62. l1 = light;
  63. l1.Position = [160 400 80];
  64. l1.Style = 'local';
  65. l1.Color = [0 0.8 0.8];
  66.  
  67. l2 = light;
  68. l2.Position = [.5 -1 .4];
  69. l2.Color = [0.8 0.8 0];
  70. s2.FaceColor = [0.9 0.2 0.2];
  71. s2.FaceLighting = 'gouraud';
  72. s2.AmbientStrength = 0.3;
  73. s2.DiffuseStrength = 0.6;
  74. s2.BackFaceLighting = 'lit';
  75.  
  76. s2.SpecularStrength = 1;
  77. s2.SpecularColorReflectance = 1;
  78. s2.SpecularExponent = 7;
  79. axis off
  80. %% 动画
  81. T=12;% 旋转一周时间
  82. fps=60; %帧率
  83. TT=3*T*fps; %总帧数
  84. da=360/T/fps;% 一帧旋转的角度
  85. mv = 0;% 是否录制视频,1录制,其它不录制
  86. if mv == 1
  87. v = VideoWriter('D:\Programs\MATLAB\MATLAB-logo-LR.mp4','MPEG-4');
  88. v.Quality = 100;v.FrameRate = 60;
  89. open(v);
  90. end
  91. for ii=1:TT
  92.     rotate(s1,[0 0 1],da)
  93.     rotate(s2,[0 0 1],da)
  94.     pause(1/fps)
  95.     drawnow
  96.     if mv==1;F=getframe(fig);writeVideo(v,F);end
  97. end
  98. if mv == 1;close(v);end
Add Comment
Please, Sign In to add comment