Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Matlab to draw a lovely Jack-o'- lantern

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use Matlab to draw a lovely pumpkin, the text is very detailed, has a certain reference value, interested friends must read!

Effect and Principle

The effects are as follows:

Adjust the data and change it to triangular eyes:

principle

The pumpkin body function comes from a graph of Zhiyou [Nine Chapters Algorithm], which is roughly a piecewise function of the melon body and handle, and then rotates around the z axis to get a curved surface. I have made fine adjustments to the values. The original image and the original data:

implementation method

Here I deliberately kept the grid to make the pumpkin look a little bit like a rag doll.(You can also rewrite it according to your own preferences, such as setting 'EdgeColor' to 'none' and lighting it up.)

% construct grid [t,p]=meshgrid(linspace(0,2*pi,200),linspace(0,pi-.05,200));% bivariate piecewise function foutline=@(t,p)(p.14).* (cos(20.* t)+70).* (p.* (pi-p+.1)).^. 2;% spherical coordinates converted to X,Y,Zh=cos(p).* foutline(t,p);R=sin(p).* foutline(t,p);R=R;X=cos(t).* R;Y=sin(t).* R;% Color matrix construction CMap=ones([size(t),3]);tMap=ones(size(t));c1=[253,158,3]./ 255;c2=[76,103,86]./ 255;for i=1:3 tMap(:,:)=c1(i); tMap(p50&maskX130&maskY45&maskX90&maskY85&maskX90&maskY45&maskX90&maskY80&maskX90&maskY45&maskX90&maskY-35))=1;% mask(maskX>45&maskX90&maskY80&maskX90&maskY45&maskX90&maskY80&maskX90&maskY

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report