JaveFX TriangleMesh Pyramid - it works, but why?

The creation of a 4-sided pyramid is explained β€œslightly” in several texts as follows:

pyramid.getPoints().addAll(0,0,0); //0 = top pyramid.getPoints().addAll(0, height, -hypotenuse/2); //1 = closest pyramid.getPoints().addAll(-hypotenuse/2, height, 0); //2 = leftest pyramid.getPoints().addAll(hypotenuse/2, height, 0); //3 = furthest pyramid.getPoints().addAll(0, height, hypotenuse/2); //4 = rightest pyramid.getTexCoords().addAll(0, 0); pyramid.getFaces().addAll(0,0,2,0,1,0); //Left front side pyramid.getFaces().addAll(0,0,1,0,3,0); //??? pyramid.getFaces().addAll(0,0,3,0,4,0); //Right back side pyramid.getFaces().addAll(0,0,4,0,2,0); //??? pyramid.getFaces().addAll(4,0,1,0,2,0); //Bottom triangle at front??? pyramid.getFaces().addAll(4,0,3,0,1,0); //Bottom triangle right??? 

It works, but I don’t understand it.

enter image description here

The second person added has vertices 0, 1, 3, so (reference figure) ... he cuts the pyramid in half. As far as I can judge. The same thing with the 4th person, only now the cut is orthogonal to the second person. And then the last 2 faces, which should be triangles, making up the square base of the pyramid. The first goes from peak 4 to peak 1 to peak 2, so ... this is the front triangle of the base of the pyramid (this is what I think). Therefore, I expect that the vertices 2,3,4 form the back triangle of the base of the pyramid, but in the last line of code we see the vertices 4,3,1, which (by my logic) make up the right triangle of the base pyramid, i.e. does not complement the front triangle of the base of the pyramid. Can someone explain this simple geometric puzzle? And is there a suitable independent resource that I can learn?

Significant Duty - Michael

+1
source share
1 answer

The correct numbering of the vertices (apologies for the roughly drawn image):

enter image description here

which you can see quite clearly by plotting vertices 1-4 in the xz plane:

 1: (0, -h/2) 2: (-h/2, 0) 3: (h/2, 0) 4: (0, h/2) 

enter image description here

So the edges

 (0,2,1) (0,1,3) (0,3,4) (0,4,2) (4,1,2) (4,3,1) 

specify the desired triangles.

+1
source

Source: https://habr.com/ru/post/1274036/


All Articles