Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi everyone,
I'm ask here for this.

There is a C++ or OpenCV function that from a point and a size, it's able to determine the 8 vertices (x, y, z) of the cube created on that side?
Posted
Comments
Andreas Gieriet 8-Nov-13 10:57am    
So you ask if there is a function or you need to write such a function?
Such a function need additional information unless you assume axis-aligned.
Is the point one of the vertices (whcih?) or the center of the cube?
What exactly is the problem?
Cheers
Andi
Domus1919 8-Nov-13 11:01am    
The point it's a vertex, the size it's one side..it's possible determinate other 7 vertexes?
Andreas Gieriet 8-Nov-13 11:02am    
Axis-aligned?
I must assume so.
Draw it on a sheet of paper: place the cube first so that the lower left vertex is on (0/0/0).
Then make one vertex each on the x-axis, y-axis, z-axis. Then make the remaining 5 vertices.
Finally add the point ot each vertex by adding the point coordinates to each vertex coordinate.
Cheers
Andi
Sergey Alexandrovich Kryukov 8-Nov-13 11:18am    
I never heard from OP it's axis aligned. What a waste!
—SA

If axis aligned, do the following:
1) place the vertex at the origin (0/0/0).
2) the base area is given by the four vertices where z is always 0: (0/0/0), (0/s/0), (s/0/0), (s/s/0)
3) likewise make all vertices in the z-plane (z = s): (0/0/s), (0/s/s), (s/0/s), (s/s/s)
4) move the cube to your point by adding that point to each vertex: (x/y/z) --> (x+a/y+b/z+c)
That's it.
Cheers
Andi
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Nov-13 11:17am    
This is not how a problem was formulated (I answered), but maybe this is what OP wanted... Re-posted... :-)
—SA
Domus1919 8-Nov-13 11:26am    
Thanks to Andreas and Sergey. Ok. It's clear situation now.
You don't need this function from some API. Why do you think that someone will develop function for all partial cases from elementary geometry. I would not make any sense.

I answered to the question on this topic here: C++ how make an Array of recursive Objects like 8-branches tree?[^].

No, this is not just one point and the size. Look thoroughly. Imagine you have a cube in your hand. Isn't it simple enough?

I tried to explain that defining the cube by defining 8 3D point of it was wrong. If your input is those 8 points, the resulting body may or may not be a cube, but if this is a cube, this data is redundant. The situation is even more complex. The 3D points are specified as 3 floating-point numbers, which are approximate. This way, there is no definitive yes-no answer to the question "are those 8 points a vertices of an exact cube". With what accuracy? You don't want to solve related problems, you need to avoid them. But, importantly, arbitrary 8 points mean 23 degrees of freedom. Apparently, this data is redundant to define a cube.

It is apparent that any solid body has exactly 6 degrees of freedom on 3D space. These 6 parameters would define the location of it without redundancy. Another degree of freedom is the size of the cube, as you don't consider it fixed. Take one point and fix it. It takes 3 degrees of freedom, say 3 Cartesian coordinates of it. Where is one of the neighboring vertices? Choose the size of the cube as the length of it rib. Then the second vertex will be anywhere on the sphere centered at the point of the first vertex. To fix the second vertex would take two more degrees of freedom, two angles in whatever system. When you fixed two vertices, you got a solid body freely rotating around the axis. Fix an angle on this axis. This is the 6th degree of freedom. And then, use elementary mathematics to calculate coordinates of 8 vertices, if you still need all of them. (Not sure why. It depends on your problem.) One delicate moment is this: you can consider the vertices/ribs/sides of a cube non-distinguishable. If you perform symmetric operation, say, rotate to 90° the way one face takes the place of another face, you got the same cube.

Anyway, you are the one who wants to do these calculations.

—SA
 
Share this answer
 
Comments
Domus1919 8-Nov-13 11:25am    
Thanks for your answer...I post question here and after I remember your advice in that thread about the three...then, I ask here and in that discussion.

I understand you. Now it's clear. Thanks.
Sergey Alexandrovich Kryukov 8-Nov-13 11:45am    
Very good. You are welcome.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900