I have several cubes, those cubes have the 8 vertices, for example:
Vet X Y Z
----- CUBE1 -----
(top side)
V1: -0.5 0.5 0.5
V2: 0.5 0.5 0.5
V3: 0.5 0.5 -0.5
V4: -0.5 0.5 -0.5
(bottom side)
V5: -0.5 -0.5 0.5
V6: 0.5 -0.5 0.5
V7: 0.5 -0.5 -0.5
V8: -0.5 -0.5 -0.5
----- CUBE2 -----
(top side)
V1: 0.5 0.5 0.5
V2: 1.5 0.5 0.5
V3: 1.5 0.5 -0.5
V4: 0.5 0.5 -0.5
(bottom side)
V5: 0.5 -0.5 0.5
V6: 1.5 -0.5 0.5
V7: 1.5 -0.5 -0.5
V8: 0.5 -0.5 -0.5
How do I find the point X, Y and Z in the center of this cube?
P.s.: the solution must be independent of the cube coordinates being positive or negative.
In this case the center of the cube1 would be (0, 0, 0) and cube2 would be (1, 0, 0)
I hope a help!
If the cube is aligned with the axis, each coordinate only takes one of two values. All you need is, for each coordinate, to find the middle point of it.
If the cube is not aligned, you sum the 8 vectors $(x, y, z) $ that have the coordinates of a vertex and then divide by 8. This is essentially finding the "average" point, which is the center of the cube.