简体   繁体   English

在python中从3d的顶点列表构造多边形

[英]Constructing a polygon from list of vertices in 3d in python

I have a list of vertices in 3d, in random order. 我有一个随机排列的3d顶点列表。 I need to construct a polygon from them. 我需要从它们构造一个多边形。

I've found a solution for this in 2d, that uses polar coordinates: ordering shuffled points that can be joined to form a polygon (in python) 我在2d中找到了使用极坐标的解决方案: 排序可以组合成多边形的混洗点(在python中)

It calculates the center of the shape, then arranges the vertices by polar coordinate. 它计算形状的中心,然后按极坐标排列顶点。 Problem is, in 3d there are 2 angles involved, if I use spherical coordinates. 问题是,如果我使用球坐标,则在3d中涉及2个角度。 How do I sort my list of vertices in case of sphereical coordinates? 在球面坐标的情况下,如何对顶点列表进行排序?

Are the points lying on a plane? 这些点在飞机上吗? First find the center, then use a vector cross product on the relative positions of a couple randomly chosen points to find the normal to the plane. 首先找到中心,然后在两个随机选择的点的相对位置上使用矢量叉积来找到平面的法线。 Analyze the coordinates of the points relative to the center into components along the normal and perpendicular. 将点相对于中心的坐标分析成沿法线和垂直方向的分量。 The perpendicular components are a 2D problem, for which you've already found a solution. 垂直分量是一个2D问题,您已经找到了解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM