필터 지우기
필터 지우기

Draw sphere with slats

조회 수: 1 (최근 30일)
viet le
viet le 2016년 9월 2일
댓글: Thorsten 2016년 9월 2일
I would like to draw a hemisphere with slats as attached figures. 12 identical slits created in hemisphere, and width slit and width slat are equal.
  댓글 수: 2
michio
michio 2016년 9월 2일
Stephen23
Stephen23 2016년 9월 2일
Duplicate:
@viet le: please do not post duplicate questions. This actually makes it harder for us to help you, because it makes it hard for us to keep track of what information and explanations you have given, and also what answer and advice you have already been given.
If you want to add information to a question than please add comments to your original question.

댓글을 달려면 로그인하십시오.

채택된 답변

Thorsten
Thorsten 2016년 9월 2일
편집: Thorsten 2016년 9월 2일
function hemispherewithstripes
clf
Nstripes = 12;
stripecolor = 'r';
Nhemicircles = 2*Nstripes;
r = 1; % radius of half-sphere
Npoints = 100; % number of points along each hemicircle
angle = linspace(0, pi, Npoints);
% xyz coordinates of a single hemicircle
x = r*cos(angle) + 1;
y = zeros(size(angle));
z = r*sin(angle);
% rotate hemicirclec
%rotation angle:
theta = linspace(-pi/2, pi/2, Nhemicircles);
% xyz coordinates of rotated hemicircles; preallocate for speed
XYZ(Npoints, 3, Nstripes) = 0;
for i = 1:Nhemicircles
% rotation matrix along x-direction:
Rotx = [1 0 0;
0 cos(theta(i)) sin(theta(i));
0 -sin(theta(i)) cos(theta(i))];
XYZ(:,:,i) = [x(:) y(:) z(:)]*Rotx;
% uncomment to plot hemicircles
% plot3(XYZ(:,1,i), XYZ(:,2,i), XYZ(:,3,i), 'k'), hold on
end
hold on
% plot patch between every two hemicircles
for i=1:2:Nhemicircles
patch([XYZ(:,1,i)' flipud(XYZ(:,1,i+1))'],...
[XYZ(:,2,i)' flipud(XYZ(:,2,i+1))'],...
[XYZ(:,3,i)' flipud(XYZ(:,3,i+1))'],...
stripecolor, 'EdgeColor', stripecolor)
end
view(3) % set default 3D viewing axes
  댓글 수: 2
Stephen23
Stephen23 2016년 9월 2일
편집: Stephen23 2016년 9월 2일
See my answer to the original question for a much simpler solution:
Thorsten
Thorsten 2016년 9월 2일
You're right, much simpler solution.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by