我有一道 3D 数学问题,但似乎无法解决。
我有3点的数据。 数据是平面上的 (2D) 坐标,漂浮在 3D 空间中的某处。 我还知道投影的(2D)坐标。 这会产生以下数据数组:
[[[x1,y1], [px1,py1],
[[x2,y2], [px2,py2],
[[x3,y3], [px3,py3]]
其中法线(x1 等)坐标代表平面上的坐标,其他(px1 等)代表投影坐标。
我想做的是投影一个新 2D 坐标([x4,y4])。
。
到目前为止我尝试过的:
当然,你需要一双眼睛来进行投影,所以我将其设置为 [xe,ye,-1]。 xe 和 ye 是已知的。 (这是照片参考,所以我只是将眼睛放在照片的中心。)
在眼睛下方我放置了投影面(z=0)。 这给出了以下投影坐标:
[[[x1,y1], [px1,py1,0],
[[x2,y2], [px2,py2,0],
[[x3,y3], [px3,py3,0]]
我无法对平面上的坐标执行相同的操作,因为我对该平面一无所知。
我还认为我可以为从眼睛穿过投影坐标的线制定一个参数化公式。 对于 line1 来说:
line1x = xe+(px1-xe)*t1
line1y = ye+(py1-ye)*t1
line1z = -1+t1 // = -1+(0--1)*t1
我也知道 3D 中点之间的距离。 这与 2D 中的相同。 这意味着 point1 和 point2 之间的距离将为 sqrt((x1-x2)^2+(y1-y2)^2)。
我还随时知道线(line1 和 line2)之间的距离。 即 sqrt((line1x-line2x)^2+(line1y-line2y)^2+(line1z-line2z)^2)。
然而,我真的不知道从这里该怎么走……甚至不知道这是否是正确的路线。
。
我希望你明白我想要做什么,并且你可以帮助我。
提前致谢!
I have a 3D math problem which I just can't seem to solve.
I have data of 3 points. The data is a (2D) coordinate on a plane, floating somewhere in 3D space. I also know the (2D) coordinate of the projection. That results in the following array of data:
[[[x1,y1], [px1,py1],
[[x2,y2], [px2,py2],
[[x3,y3], [px3,py3]]
Where the normal (x1 etc.) coordinates stand for the coordinates on the plane and the other (px1 etc.) for the projected coordinates.
What I would like to do is project a new 2D coordinate ([x4,y4]).
.
What I tried so far:
Ofcourse you need an eye for projection, so I set that to [xe,ye,-1]. The xe and ye are known. (It is photo referencing, so I just placed the eye in the center of the photograph.)
Beneath the eye I placed the projection surface (z=0). That gives the following projection coordinates:
[[[x1,y1], [px1,py1,0],
[[x2,y2], [px2,py2,0],
[[x3,y3], [px3,py3,0]]
I can't do the same for the coordinates on the plane, since I don't know anything about that plane.
I also figured that I could make a parameterized formula of the lines running from the eye through the projection coordinates. For line1 that would be:
line1x = xe+(px1-xe)*t1
line1y = ye+(py1-ye)*t1
line1z = -1+t1 // = -1+(0--1)*t1
I also know the distance between the points in 3D. That's the same as in 2D. That means the distance between point1 and point2 would be sqrt((x1-x2)^2+(y1-y2)^2).
I also know the distance between the lines (line1 and line2) at any time. That is sqrt((line1x-line2x)^2+(line1y-line2y)^2+(line1z-line2z)^2).
However, I don't really know how to go from here... Or even whether this is the right route to take.
.
I hope you understand what I want to be able to do, and that you can help me.
Thanks in advance!
发布评论
评论(5)
有一个函数 Projection,它可以对点进行变换,使得 Projection([x1, y1]) = [px1, py1] , Projection([x2, y2]) = [px2, py2], Projection([x3, y3]) = [px3, py3]。 如果我理解正确的话,作者想知道如何找到这个投影函数,以便他可以将 [x4, y4] 转换为 [px4, py4]。
由于我们在这里处理的是平面,因此投影函数如下所示:
使用它我们可以创建 2 个方程组来求解。
第一个
x1 * ax + y1 * bx + cx = px1
x2 * ax + y2 * bx + cx = px2
x3 * ax + y3 * bx + cx = px3
求解 ax、bx 和 cx 给我们
第二个
x1 * ay + y1 * by + cy = py1
x2 * ay + y2 * by + cy = py2
x3 * ay + y3 * by + cy = py3
求解 ay、by 和 cy 给我们
注意:我使用了 此工具用于求解方程组。
There is a function Projection, which can transform points so that Projection([x1, y1]) = [px1, py1] , Projection([x2, y2]) = [px2, py2], Projection([x3, y3]) = [px3, py3]. If I understand correctly, author wants to know how to find this Projection function, so that he can trasnform [x4, y4] into [px4, py4].
Since we are dealing with planes here, the Projection function looks like this:
Using that we can make 2 equation systems to solve.
The first one
x1 * ax + y1 * bx + cx = px1
x2 * ax + y2 * bx + cx = px2
x3 * ax + y3 * bx + cx = px3
Solving for ax, bx and cx gives us
The second one
x1 * ay + y1 * by + cy = py1
x2 * ay + y2 * by + cy = py2
x3 * ay + y3 * by + cy = py3
Solving for ay, by and cy gives us
Note: I used this tool to solve equation systems.
您应该使用 同应函数 和 齐次坐标,一般用于3D透视操作。
You should use homographic functions and homogeneous coordinates, which are generaly used for 3D perspective operations.
写出
A1、A2、A3 的求解。 然后
进行第一次编辑。
(A1,A2,A3)是线性方程组Mat*(A1,A2,A3)=(x4,y4,1)的解。
这可以通过多种方式解决。 例如使用 Cramer 的 规则。
第二次编辑。
我插入的1不是Z坐标,而是输入坐标的齐次扩展(必须是欧几里得坐标)。 (A1,A2,A3) 是三角形顶点形成的基中的齐次坐标。
第三次编辑。
3D平面和投影平面之间的对应关系是投影变换。 它可以定义为在输入平面 (x,y,1)(在您的坐标系中)中的齐次坐标上运行的 3x3 矩阵 T,并在投影平面中生成坐标 (u,v,t)。 那么 px=u/t 和 py=v/t。
如果一个点在输入平面的三个点(不在同一直线上)形成的基础上具有齐次坐标(A1,A2,A3),则其投影在投影基础上具有相同的齐次坐标。
1 小时前,这对我来说似乎很清楚,但现在我开始怀疑:也许需要知道一对额外的点才能找到问题的单一解决方案......如果你能找到它,请看看JG Semple 和 GT Kneebone 所著的《代数射影几何》一书。
Write
solving for A1,A2,A3. Then
1st edit.
(A1,A2,A3) is the solution of the linear system Mat*(A1,A2,A3)=(x4,y4,1).
This can be solved in various ways. For example using Cramer's rules.
2nd edit.
The 1's I inserted are not Z coordinates, but homogeneous extensions of the input coordinates (which must be Euclidean coordinates). (A1,A2,A3) are homogeneous coordinates in the basis formed by the triangle vertices.
3rd edit.
The correspondence between the 3D plane and the projection plane is a projective transformation. It can be defined as a 3x3 matrix T operating on homogeneous coordinates in the input plane (x,y,1) (in your coordinate system) and producing coordinates (u,v,t) in the projection plane. Then px=u/t and py=v/t.
If a point has homogeneous coordinates (A1,A2,A3) in the basis formed by three points of the input plane (not on the same line) then its projection has the same homogeneous coordinates in the projected basis.
It seemed quite clear to me 1 hour ago, but now I'm beginning to doubt: maybe knowing one additional pair of points is needed to have a single solution to the problem... If you can find it, have a look at the book "Algebraic Projective Geometry" by J.G. Semple and G.T. Kneebone.
我真的不明白这个问题? 您是否试图在 3d 空间中定位一个物体,您知道该物体位于平面上(例如墙壁或地板),并且您拥有的唯一输入是 3 个点(您知道其中在 3d 空间中之间的距离)相机图像?
在这种情况下,您将有 3 个这样的方程,其中 localCoordinates 是对象空间中的点坐标(给出点之间的已知距离),而 world 是 3d 空间中的对象位置。
这将产生一个包含 6 个未知数(3d 中的旋转和位置)和 6 个方程(每个点 2 个)的方程组。 然而它是非线性的,所以你必须使用数值方法来解决它。 尝试牛顿拉普森方法。
I don't really understand the problem? Are you trying to locate an object in 3d-space that you know is located on a plane (a wall or floor for example) and the only input you have is 3 points(of which you know the distances between in 3d-space) from a camera-image?
In that case you will have 3 equations like this where localCoordinates is the points coordinates in objectspace(gives the known distance between the points) and world is the objects position in 3d-space.
This will yield an equation system with 6 unknown(rotation and position in 3d) and 6 equations (2 for every point). It will however be non linear so you have to solve it using numerical methods. Try the Newton Rapson method.
这里“有点”晚了,但是评分最高的答案没有考虑到问题的 3D 空间。 我们有一个透视投影问题,平面上的三个点(实际上是任何 3 个 3D 点)被投影(如射影几何中)到相机的表面上。
不可能对该问题给出明确的解决方案(存在多种解决方案)。 在给定 3 个 3D 点及其各自的 2D 透视投影的情况下查找相机位置和姿势的一般问题可以使用原始 RANSAC 论文,给出了最多四种可能的可行解决方案(点在相机前面)。
给定相机姿态,计算附加平面点的投影是微不足道的。
A "bit" late here, but the highest rated answer doesn't take into account the 3D-space of the problem. We have a perspective projection problem, with three points on a plane (actually any 3 3D points) being projected (as in projective geometry) on the surface of a camera.
It is not possible to give an unambiguous solution to this problem (multiple solutions exist). The general problem of finding a camera position and pose given 3 3D points and their respective 2D perspective projections can be solved using the P3P (Perspective-3-Point) algorithm from the original RANSAC paper, which give up to four possible feasible solutions (with the points in front of the camera).
Given a camera pose, it is trivial to calculate the projection of additional plane points.