Filling in a spherical triangle

조회 수: 4 (최근 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