How are the geometrical properties of polyhedrals defined?

#1

Hello there,

I’m trying to understand how the geometrical properties (center of mass/center of rotation, local main axis of the polyhedral, …) of polyhedrals, and I haven’t found anything in what seems to be the main documentation page for this (Create Polyhedra - Babylon.js Documentation). I have found out that properties, such as origin, or sizes are not consistent among different polyhedral geometries. I have created a playground to demonstrate this:
Babylon.js Playground

Both the tetrahedron and the pyramid share the same size, and yet it can be seen that they are not equal at all in any of the axes (X, Y, Z). Also, the pyramid seems to have some weird orientation, as it is rotated around the three main axes. I am mainly interested in knowing the geometrical properties of the pyramid, more specifically on these three:

  1. Where is the “center” of the pyramid, and what is the vector that points to it from the origin (depending on the figure size)
  2. How are the main local axes of the pyramid located, and how are they rotated comparing to the World axes?
  3. How does ‘size’ work?

I know it’s quite an specific question, but I’m sure there is someone around here who can give me a hand. Thanks :slight_smile:

#2

Hi @grolivas, welcome to the forum… and SORRY it has taken SO LONG to get a response.

A long time ago… maybe 3 years… @jerome and I plotted a scheme… to get more “polyhedra” available for BJS. We didn’t have a pile of formulas… but we DID know of a math-God chap named Professor Hart (with the help of a 3js pro named Professor Stemkoski)… who had created a JSON file of hard-coded “shapes”. Jerome asked permissions and kissed butts… until he got permission to use that file in non-commercial BJS applications.

Here is an early playground by Jerome… with the current URL to that file.

https://www.babylonjs-playground.com/#21QRSK#17

Scroll-down in the JS file a bit… and you will find the “J” series shapes… with the “J” standing-for “Johnson Solids”. (J1 to J92).

These days, most of BJS’s “odd shapes” are created with “builders”. Here is the source code for the PolyhedronBuilder… Babylon.js/polyhedronBuilder.ts at master · BabylonJS/Babylon.js · GitHub

See the “J” numbers in line 10? That tells us that these shapes are using Professor Hart’s hard-coded coordinates… to make these shapes. You can see the hard-coded vert-positions… below that.

I adjusted your PG demo (thx for making that, nice work)… to be camera facing +z and laying flat on the horizon… AND I turned-on showBoundingBox for both mesh. https://www.babylonjs-playground.com/#65ISRL#1

As you can see, Professor Hart’s hard-coded coordinates (vert positions)… don’t align with BJS bounding boxes very well at all.

About 2 years ago, BJS attained some corporate funding, and I am HOPING that some paid worker will gun-down the proper formulas to dynamically “grow” these shapes with Math. But, currently, they are not done that way, and they are still using Professor Hart’s hard-coords.

In fact, BJS MIGHT BE in violation of Professor Hart’s preferences… as far as the use of these hard-coded shapes.

I’m not allowed to assign work-tasks to Microsoft-paid BabylonJS workers… but I HOPE they place this issue… as a high priority.

When I and Jerome first set-out on this mission, we never really expected these shapes to be “generated” by local BJS math. We were just darned glad to be able to SEE them… inside a BJS scene. Symmetrical shapes are interesting to look-at, and are high-performance as “adornments” within BJS scenes. They are pretty, and, like snails, conch shells, pine cones, etc… are somehow eye-catchers and drool-inducers. As a species, we LOVE symmetrical geometry just like we love musical harmonies.

So… yeah… no hope. But wait…
…there IS SOME hope. You can “eyeball-orient” these mesh… into reasonable flat-ground orientations… and then… you can call mesh.bakeCurrentTransformIntoVertices(); This “bake” resets the mesh.rotation and mesh.position values to 0,0,0, and resets mesh.scaling to 1,1,1 (yet doesn’t change the mesh AT ALL).

Essentially, you can use this “bake” to “square-up” the mesh with the scene’s world-space up/forward vectors. Even though the bounding boxes will STILL not align with the mesh or the world/scene… in any “sane” way, the mesh could “look” squared-up with the world.

So, it is the lack of math formulas to dynamically “grow” these mesh, and the usage of Professor Hart’s hard-coords… that causes us to have poor world/bbox alignments for these type of mesh. They are more “clone” than they are originals.

I think Professor Hart might have used MathLab software to build these, and perhaps those MathLab formulas DO exist somewhere, and COULD be converted to pure JS formulas for our MeshBuilder system. But, for now, that is not the case, and Professor Hart did not offer-them-up to Jerome when Jerome exchanged emails with Professor Hart and Professor Stemkoski.

I wish I had better news… but… back when we first saw these shapes… our ONLY concern was to make them ANY-BIT usable in BJS scenes. Although Jerome and I both DREAMED of having the formulas to dynamically create these shapes… we were not able to locate them (although we didn’t search for them TOO intensely).

SO… size is likely doing a simple uniform-scaling (scaling all dimensions equal proportions) and does not mean much more than that. Likely, you can’t count-on size to match any boundingBox extends-sizes or anything wonderful like that. Sorry for that bad news. I hope, someday, we can gather the formulas and use BJS JS to grow the shapes.

I hope I have been helpful. Sorry again for the slow replies. Have questions? Just ask. Be well, party on!

4 Likes