简体   繁体   English

使用2D数组创建具有3D网格的多维数据集

[英]Create a cube with a 3d mesh, using a 2d array

I need to create a cube using a mesh which is using these properties: "A two-dimensional array containing the mesh vertices. Each entry of the array specifies the vertices of one row of the mesh. The arrays for all rows must have the same length. There must be at least two rows, and each row must have at least two vertices" 我需要使用使用以下属性的网格创建一个多维数据集:“一个包含网格顶点的二维数组。该数组的每个条目都指定了网格的一行的顶点。所有行的数组必须具有相同的长度。至少必须有两行,并且每行必须至少有两个顶点”

If you think to a representation of a cube made of paper: 如果您想到纸制立方体的表示:

多维数据集样本

you can see it as 2 meshes, the 3 orizontal square and the 3 vertical. 您可以将其视为2个网格,3个正方形和3个垂直网格。 But in this case I would have to use two meshes, while I need one. 但是在这种情况下,我必须使用两个网格,而我需要一个。 I'd like to do not have overlap, and I was not able to find a solution. 我不想重叠,也找不到解决方案。 The best option I've found consists in filling the array with 9 rows. 我发现最好的选择是用9行填充数组。

Each rows contains two entry, and in this way it is creating the surface of the cube. 每行包含两个条目,并以此方式创建立方体的表面。 I'm attaching few images to explain what it creates with the first rows, till when I reach the overlapping point: 我会附上几张图片来说明它在第一行中所产生的效果,直到到达重叠点为止:

图像表示

I guess this problem has no solution, but in case any of you have any idea I will be open to any proposal. 我想这个问题没有解决办法,但是如果你们有任何想法,我将接受任何建议。

(I'm sorry about the order that may not be accurate) (对于可能不正确的订单,我们深表歉意)

var row0 = [];  
x, y, l
x+t, y, l

var row1=[]        
x, y, l+400
x+t, y, l+400

var row2=[]        
x, y+t, l+400
x+t, y+t, l+400

var row3=[]       
x, y+t, l
x+t, y+t, l

var row4=[]         
x, y, l
x+t, y, l

var row5=[]      
x+t, y, l
x+t, y+t, l

var row6=[]         
x+t, y, l+400
x+t, y+t, l+400

var row7=[]       
x, y+t, l
x, y, l

var row8=[]
x, y+t, l+400
x, y, l+400

With "x,y" two random coordinates that are having a distance of 400."t" as a variable. 使用“ x,y”两个距离为400.t的随机坐标作为变量。 While "l+40"0 indicates the distance in height from the "l". 而“ l + 40” 0表示距“ l”的高度距离。

Source here 来源在这里

You're totally overthinking the problem. 您完全没有考虑这个问题。

Let's step back for a moment: In 3D space each position is specified by 3 values; 让我们退一步:在3D空间中,每个位置都由3个值指定; in a cartesian coordinate system those are usually called X, Y and Z. 在笛卡尔坐标系中,这些通常称为X,Y和Z。

We normally write those down as a row of scalar values: 我们通常将它们记为一行标量值:

x, y, z

A cube consists of 6 faces, each one made up of 4 points, where each point position is shared by 3 faces. 立方体由6个面组成,每个面由4个点组成,每个点的位置由3个面共享。 Let's assume a cube with its center at the origin and a width of 2, then the two faces in the XY-plane would be 假设一个立方体的中心在原点,宽度为2,则XY平面中的两个面为

-1, -1, -1
 1, -1, -1
 1,  1, -1
-1,  1, -1
 1, -1,  1
-1, -1,  1
-1,  1,  1
 1,  1,  1
 …

there are 4 more faces (two in XZ and two in YZ) to make a full cube. 还有4个面(XZ中两个,YZ中两个)组成一个完整的立方体。 What's really important (for your question) is, how these values are written down. 真正重要的(对于您的问题)是如何记下这些值。 Look up to the numbers I wrote. 查找我写的数字。 What do you see? 你看到了什么? A 2D array of numbers (3 numbers in a row), one row for every point the cube's mesh is made up from. 一个2D数字数组(连续3个数字),构成多维数据集网格的每个点一行。 That's all there is. 这就是全部。

A mesh is simply such a list of vertices. 网格就是这样一个顶点列表。 Don't think of it as a "foldable mesh made from paper". 不要将其视为“用纸制成的可折叠网”。 Just a list of positions, where you can also duplicate positions. 只是职位列表,您还可以在其中重复职位。 You may as well write down only the 8 positions once and use a second, 1D array that is a list of how to make a mesh from these positions. 您也可以只写下8个位置一次,并使用第二个1D数组,该数组列出了如何从这些位置制作网格。

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

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