Filling in a spherical triangle

7 次查看(过去 30 天)
Lorcan O'Connor
Lorcan O'Connor 2021-4-2
回答: darova 2021-4-2
I have a program that generates and plots the edges of spherical triangles on a unit sphere. How can I fill in the interior of the spherical triangle on the surface? I tried generating a large number of points on the interior but it doesn't look very good - is there a way to turn scattered points like that into a many-sided polygon?

回答(2 个)

KSSV
KSSV 2021-4-2
Read about delaunayTraingulation.

darova
darova 2021-4-2
clc,clear
t = [0; 45; 45]*pi/180;
q = [45; 45; 90]*pi/180;
[x,y,z] = sph2cart([t;t(1)],[q;q(1)],1); % convert angles to cartesian coordinates
% interpolate triangle to create more points
tt = [0; cumsum(sqrt(diff(x).^2+diff(y).^2+diff(z).^2))]; % arclength (parameter)
t1 = linspace(tt(1),tt(end),30); % more points
x1 = interp1(tt,x,t1);
y1 = interp1(tt,y,t1);
z1 = interp1(tt,z,t1);
[X,Y,Z] = deal( zeros(5,30) );
% find approximate center of a triangle
x0 = mean(x1);
y0 = mean(y1);
z0 = mean(z1);
% create internal points
for i = 1:size(Z,2)
X(:,i) = linspace(x0,x1(i),size(X,1));
Y(:,i) = linspace(y0,y1(i),size(Y,1));
Z(:,i) = linspace(z0,z1(i),size(Z,1));
end
% points are created in a plane
% move them onto sphere
RR = sqrt(X.^2+Y.^2+Z.^2); % distance from sphere center to point. Should be '1'
X = X./RR;
Y = Y./RR;
Z = Z./RR;
[xs,ys,zs] = sphere(10);
surf(X,Y,Z)
surface(xs,ys,zs,'facecolor','none')
view(45,45)
See more about 3D curve inteprolation: LINK

类别

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