首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Delaunay图的角度计算

Delaunay图的角度计算
EN

Stack Overflow用户
提问于 2016-07-04 13:48:25
回答 1查看 362关注 0票数 1

我用MATLAB绘制了一个Delaunay图,如下所示:-

我想计算一下图中的所有角度。对于所有无序形式的点,我都有x和y值,我不知道如何对这些点进行排序,因为x和y值对于同一行中的那些点是接近的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-04 15:23:10

这样做的一个方法是:

代码语言:javascript
复制
x = randn(1,4)*10;
y = randn(1,4)*10;

%calculate the triangulation
tri = delaunay(x,y);

%Plot the graph
triplot(tri,x,y)
hold on

plot(x,y,'ro')
text(x,y,strsplit(num2str(1:length(x))))


% Determine each angle
for i = 1:size(tri,1)
    per = perms(tri(i,:));
    [~, ind] = unique(per(:,2)); %avoid to calculate two time the same angle.
    per = per(ind,:); %the 3 * 3 points that create the angle of each triangle
    for j = 1:3
       P_1 = per(j,1);
       P1 = [x(P_1),y(P_1)];
       P_2 = per(j,2);
       P2 = [x(P_2),y(P_2)];
       P_3 = per(j,3);
       P3 = [x(P_3),y(P_3)];
       ANG = rad2deg(atan2(abs(det([P3-P2;P1-P2])),dot(P3-P2,P1-P2))); %P2 is the point in the middle
       fprintf('Node %d %d %d angle %f\n',P_1, P_2, P_3, ANG)
    end
end
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38186329

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档