Plotting a sphere consisting of planes

Hi folks,
i want to plot a sphere consisting of triangular planes. The cartesian coordinates of the planes are given by their respective corner points A, B and C which have their own 3D-coordinates A(Ax, Ay, Az), B(Bx, By, Bz) and C(Cx, Cy, Cz). The usual plot-Function does not produce reasonable results.
Does anyone has a suggestion?

2 件のコメント

darova
darova 2020 年 4 月 6 日
Can you show some of your attempts? Do you have a picture of the result? Can you make a simple drawing or something?
Paul
Paul 2020 年 4 月 6 日
The plotted result should be similar to the picture from the description of the icosphere-function in the MathWorks File Exchange (see attachement).
My attempt:
A = surfacessphere; %coordinates of the triangular faces are stored in the surfaces_sphere.txt
Ax = A(:,5); %
Ay = A(:,6); %Defining columns of Matrix A as columnvectors
Az = A(:,7); %
Bx = A(:,8); %
By = A(:,9); %Defining columns of Matrix A as columnvectors
Bz = A(:,10); %
Cx = A(:,11); %
Cy = A(:,12); %Defining columns of MAtrix A as columnvectors
Cz = A(:,13); %
plot3(Ax,Bx,Cx); %
plot3(Ay,By,Cy); %Plotting
plot3(Az,Bz,Cz); %

サインインしてコメントする。

回答 (1 件)

darova
darova 2020 年 4 月 6 日

0 投票

Use patch for this problem
% create data of format
% Ax Ay Az
% Ax Ay Az
% ...
% Bx By Bz
% Bx By Bz
% ...
% Cx Cy Cz
% Cx Cy Cz
% ...
fv.vertices = reshape(A(:,5:13),[],3);
% create connection list of format
% 1 n+1 2n+1
% 2 n+2 2n+2
% 3 n+3 2n+3
% ...
n = size(A,1);
fv.faces = [1:n; (1:n)+n; (1:n)+2*n]';
fv.facecolor = 'yellow';
patch(fv)

4 件のコメント

Paul
Paul 2020 年 4 月 7 日
Thank you, your answer helped a lot!
I was trying to apply these functions to the geometry of a cylinder also consisting of triangular planes. The result should be displayed in the xz-plane and look like the plot in the attachement.
The coordinates of the planes are given by their vertices: A(Ax,Ay,Az), B(Bx, By, Bz) and C(Cx, Cy, Cz) for one triangular plane.
I've attached the textfile in which the coordinates are stored.
How can I change the previous script in order to get a result as in the picture in the attachement?
darova
darova 2020 年 4 月 7 日
Everything is the same. Why shouldn't it be different? The script i wrote i just plot triangles, it doesn't know what shape is. Are you asking of how to read data?
Paul
Paul 2020 年 4 月 20 日
Unfortunately the result of the submitted script looks like the attacheted picture and not like the cylinder in the xz-plane (attachement). Reading data is not the problem:) (i think)
darova
darova 2020 年 4 月 20 日
I made a wrong script, sorry. Try this:
A1 = importdata('surfaces_cylinder.txt');
A = A1.data;
ii = [5 8 11];
patch(A(:,ii)',A(:,ii+1)',A(:,ii+2)','y')
axis vis3d

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2020 年 4 月 6 日

コメント済み:

2020 年 4 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by