MATLAB画一把伞

Matlab 复制代码
% 伞的参数

num_ribs = 5; % 伞骨数量修改为5

R = 1; % 伞的半径

height = 0.5; % 伞的高度

handle_length = 2; % 伞柄长度

semicircle_radius = 0.26; % 伞柄末端半圆的半径

% 生成伞叶网格

theta = linspace(0, 2*pi, 100);

phi = linspace(0, pi/2, 50);

[Theta, Phi] = meshgrid(theta, phi);

% 计算伞叶的坐标

X = R * cos(Theta) .* sin(Phi);

Y = R * sin(Theta) .* sin(Phi);

Z = height * cos(Phi);

% 给伞叶添加一些随机波动,模拟褶皱

noise = 0.009 * randn(size(Z));

Z = Z + noise;

% 绘制伞叶

figure;

surf(X, Y, Z, 'FaceColor', 'interp', 'EdgeColor', 'none');

hold on

% 绘制伞骨

for i = 1:num_ribs

theta_rib = (i - 1) * 2*pi / num_ribs;

x_rib = R * cos(theta_rib) * sin(phi);

y_rib = R * sin(theta_rib) * sin(phi);

z_rib = height * cos(phi);

plot3(x_rib, y_rib, z_rib, 'k', 'LineWidth', 2);

hold on

end

% 绘制伞柄

x_handle = [0, 0];

y_handle = [0, 0];

z_handle = [0, -handle_length+0.5];

plot3(x_handle, y_handle, z_handle+[0.5,0.5], 'k', 'LineWidth', 3);

hold on

x_handle = [0, 0];

y_handle = [0, 0];

z_handle = [0, handle_length*0.1];

plot3(x_handle, y_handle, z_handle+[0.5,0.5], 'k', 'LineWidth', 3);

hold on

% 绘制伞柄末端的半圆

semicircle_theta = linspace(0, pi, 50);

x_semicircle = semicircle_radius * cos(semicircle_theta);

y_semicircle = -handle_length * ones(size(semicircle_theta));

z_semicircle = -semicircle_radius * sin(semicircle_theta);

plot3(x_semicircle+0.15+0.12, y_semicircle+2, z_semicircle-1, 'k', 'LineWidth', 3);

% 设置视角和坐标轴

axis equal;

view(3);

box on;

camlight;

lighting gouraud;
相关推荐
lly20240642 分钟前
jQuery Mobile 表格
开发语言
小文数模43 分钟前
2026年美赛数学建模C题完整参考论文(含模型和代码)
python·数学建模·matlab
惊讶的猫1 小时前
探究StringBuilder和StringBuffer的线程安全问题
java·开发语言
m0_748233171 小时前
30秒掌握C++核心精髓
开发语言·c++
Fleshy数模2 小时前
从数据获取到突破限制:Python爬虫进阶实战全攻略
java·开发语言
Duang007_2 小时前
【LeetCodeHot100 超详细Agent启发版本】字母异位词分组 (Group Anagrams)
开发语言·javascript·人工智能·python
froginwe112 小时前
Redis 管道技术
开发语言
u0109272712 小时前
C++中的RAII技术深入
开发语言·c++·算法
superman超哥3 小时前
Serde 性能优化的终极武器
开发语言·rust·编程语言·rust serde·serde性能优化·rust开发工具
一个响当当的名号3 小时前
lectrue9 索引并发控制
java·开发语言·数据库