从一个点和大小创建一个立方体的函数? [英] function that creates a cube from one point and size?

查看:121
本文介绍了从一个点和大小创建一个立方体的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在这里问这个。



有一个C ++或OpenCV函数从一个点开始一个大小,它能够确定在那一侧创建的立方体的8个顶点(x,y,z)?

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?

推荐答案

如果轴对齐,请执行以下操作:

1)将顶点放在原点(0/0/0)。

2)基本区域由四个顶点给出,其中z始终为0 :( 0/0/0),(0 / s / 0),(s / 0/0),(s / s / 0)

3)同样在z平面上制作所有顶点( z = s):( 0/0 / s),(0 / s / s),(s / 0 / s),(s / s / s)

4)将立方体移动到通过将该点添加到每个顶点来表达您的观点:(x / y / z) - > (x + a / y + b / z + c)

就是这样。

干杯

Andi
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


您不需要某些API的此功能。为什么你认为有人会从初等几何中为所有部分情况开发函数。我没有任何意义。



我在这里回答了关于这个主题的问题: C ++如何使一个递归对象数组像8分支树? [ ^ ]。



不,这不仅仅是一个点和大小。仔细看。想象一下,你手中有一个立方体。是不是很简单?



我试图解释通过定义8个3D点定义立方体是错误的。如果您的输入是那8个点,则生成的主体可能是也可能不是多维数据集,但如果这是一个多维数据集,则此数据是多余的。情况更加复杂。 3D点被指定为3个浮点数,它们是近似值。这样,对于精确立方体的顶点是那8个点这个问题,没有明确的是 - 否答案。有什么准确性?你不想解决相关问题,你需要避免它们。但是,重要的是,任意8分意味着23个自由度。显然,这个数据对于定义一个立方体是多余的。



很明显,任何实体在3D空间上都有6个自由度。这6个参数将定义它的位置而没有冗余。另一个自由度是立方体的大小,因为你不认为它是固定的。采取一点并修复它。它需要3个自由度,比如3个笛卡尔坐标。邻近顶点之一在哪里?选择立方体的大小作为肋的长度。然后第二个顶点将位于以第一个顶点为中心的球体上的任何位置。要固定第二个顶点,需要两个自由度,在任何系统中都需要两个角度。当您修复两个顶点时,您将获得一个围绕轴自由旋转的实体。在此轴上固定一个角度。这是第六自由度。然后,如果您仍然需要所有这些,则使用基本数学来计算8个顶点的坐标。 (不知道为什么。这取决于你的问题。)一个微妙的时刻是这样的:你可以认为立方体的顶点/肋骨/侧面是不可区分的。如果你执行对称操作,比如旋转到90°,就像一张脸取代另一张脸一样,你就得到了同样的立方体。



无论如何,你是想要进行这些计算的人。



-SA
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


这篇关于从一个点和大小创建一个立方体的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆