简体   繁体   English

有没有办法在给定顶点的情况下找到 3D 形状的所有边缘?

[英]Is there a way to find all the edges of a 3D shape given its vertices?

I have a list of vertices of a simple 3D shape like a pyramid, a cube or a dodecahedron, is there an algorithm to find all the connections between the "outer vertices" that make up a face?我有一个简单的 3D 形状的顶点列表,如金字塔、立方体或十二面体,是否有一种算法可以找到构成面的“外部顶点”之间的所有连接?

for example, once projected a pyramid to 2D I have a matrix of 8 coordinates x,y for each vertice: int[] coords = new int [8][2] and came up with this way of calculating them例如,一旦将金字塔投影到 2D 我有一个每个顶点的 8 个坐标 x,y 的矩阵: int[] coords = new int [8][2]并想出了这种计算它们的方法

for(int i = 0; i<4; i++){
    for(int a = 1; a<=4; a++){
        if(i+a!=3){
            if(a>i){
                edges.add(new Line( coords[i][0] * GROWTH + displacement ,
                                    coords[i][1] * GROWTH + displacement,
                                    coords[a][0] * GROWTH + displacement,
                                    coords[a][1] * GROWTH + displacement));
                                    }
                                }
                            }
                        }

This only works with pyramids, I wonder if there's a way of calculating all the edges of a given [n][2] set of coordinates representing a projected 3D shape.这仅适用于金字塔,我想知道是否有一种方法可以计算给定 [n][2] 组坐标的所有边缘,这些坐标表示投影的 3D 形状。

There is no unique answer to your question, check Four ways to crate a mesh for a sphere您的问题没有唯一答案,请查看为球体创建网格的四种方法

Here I translate the first approach, that is similar to geographical coordinates, based on latitude and longitude.这里我翻译第一种方法,也就是类似于地理坐标,基于经纬度。

for(int i = 0; i<num_parallels; i++){
    for(int a = 1; a<=4; num_meridians++){
        double y1 = PI * i / num_parallels;
        double y2 = l1 + PI / num_parallels;
        double x1 = 2.0 * PI * i / num_meridians;
        double x2 = x1 + 2.0 * PI / num_meridians;
        add_sphere_line(x1, y1, x1, y2); // a parallel
        add_sphere_line(x1, y1, x2, y1); // a meridian
   }
}

The function to add a sphere line function添加球面线

void add_sphere_line(double x1, double y1, double x2, double y2){
  add_3d_line(
   // starting point in 3D coordinates
   Math.cos(x1) * Math.sin(y1), Math.cos(y1), Math.sin(x1) * Math.sin(y1),
   // end point in 3D coordinates
   Math.cos(x2) * Math.sin(y2), Math.cos(y2), Math.sin(x2) * Math.sin(y2)
  );
}

Since you mention you projected the pyramid to 2D I imagine you can workout the projection of these arbitrary lines to 2D as well.既然您提到您将金字塔投影到 2D,我想您也可以将这些任意线投影到 2D。

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

相关问题 如何使用JUNG对顶点和边缘进行着色和成形 - how to use JUNG to color & shape vertices and edges 给定 3d 空间中的一组点,找到彼此距离内的所有点组 - Given a set of points in 3d space, find all sets of points within a distance of eachother 这看起来像是一种在图中找到没有出边的顶点的有效方法(JGrapthT)吗? - Does this look like an efficient way to find vertices which have no outgoing edges in a graph (JGrapthT)? 二维几何形状顶点坐标检测 - 2D geometric shape vertices coordinates detection 获取旋转和缩放的长方体顶点的 3D 坐标,在所有轴上具有缩放、中心位置和旋转 - Get 3D coordinates of vertices of rotated and scaled cuboid with scale, center position and rotation on all axis 从给定的3D数组中找到null的数组索引 - Find the array Index of null from the given 3D array 有没有办法使用 java 中的坐标裁剪给定的 3d 图像? - is there a way to crop a given 3d image using coordinates in java? 如何找出多边形中的边,面,顶点的数量 - How to find out the number of edges, faces, vertices in a polygon 如何在arangodb中使用Tinkerpop蓝图API来获取所有顶点和边缘 - how to use Tinkerpop blueprints API in arangodb to get all vertices and edges 查找给定坐标的四边形的面积 - Find area of quadrilateral given coordinates the of vertices
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM