我如何反向工程2D点转换成3D? [英] How do I reverse-project 2D points into 3D?

查看:226
本文介绍了我如何反向工程2D点转换成3D?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个2D点,​​在屏幕空间,我需要进行反向工程回到三维空间。我知道,每个4点是3D旋转的刚性矩形的一个角落里,我知道了矩形的大小。从此我怎样才能得到三维坐标?

I have 4 2D points in screen-space, and I need to reverse-project them back into 3D space. I know that each of the 4 points is a corner of a 3D-rotated rigid rectangle, and I know the size of the rectangle. How can I get 3D coordinates from this?

我没有使用任何特定的API,而我没有一个现有的投影矩阵。我只是在寻找基本的数学来做到这一点。当然没有足够的数据到一个二维点到三维,没有其他的参考转换,但我想,如果你有4个点,你知道,他们都是以直角彼此在同一平面上,你知道它们之间的距离,你应该能够理解它从那里出来。不幸的是我不能完全解决如何虽然。

I am not using any particular API, and I do not have an existing projection matrix. I'm just looking for basic math to do this. Of course there isn't enough data to convert a single 2D point to 3D with no other reference, but I imagine that if you have 4 points, you know that they're all at right-angles to each other on the same plane, and you know the distance between them, you should be able to figure it out from there. Unfortunately I can't quite work out how though.

这可能属于摄影的伞下,但谷歌搜索,但没有导致我任何有用的信息。

This might fall under the umbrella of photogrammetry, but google searches for that haven't led me to any helpful information.

推荐答案

从2-D空间将会有可建2有效矩形。如果不知道原来的投影矩阵,你不会知道哪一个是正确的。这是一样的盒子的问题:你看到两个广场,人在里面,另外,与连接到相应的4个顶点外的4个内顶点。你看从自上而下或自下而上的一箱?

From the 2-D space there will be 2 valid rectangles that can be built. Without knowing the original matrix projection, you won't know which one is correct. It's the same as the "box" problem: you see two squares, one inside the other, with the 4 inside vertices connected to the 4 respective outside vertices. Are you looking at a box from the top-down or the bottom-up?

话虽这么说,你正在寻找一个矩阵变换T,其中...

That being said, you are looking for a matrix transform T where...

{{X1,Y1,Z1},{X2,Y2,Z2},{X3,Y3,Z3},{X4,Y4,Z4}}×T = {{X1,Y1},{X2,Y2 },{X3,Y3},{X4,Y4}}

{{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}, {x4, y4, z4}} x T = {{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}}

(4×3)×T的=(4×2)

(4 x 3) x T = (4 x 2)

所以T必须是(3×2)矩阵。因此,我们有6个未知数。

So T must be a (3 x 2) matrix. So we've got 6 unknowns.

现在建立约束制度对T和解决与单纯。要构建的约束,你知道,一条通过前两个点必须平行线传递给第二个两分。你知道,一条线穿过点1和3必须平行于通过点2和4。您知道,一条线穿过1和2必须是垂直的线穿过点2和3的线你知道的长度从图1和2的线路必须等于线的长度从3和4的你知道从1和3中的线的长度必须等于该行的长度从2和4。

Now build a system of constraints on T and solve with Simplex. To build the constraints, you know that a line passing through the first two points must be parallel to the line passing to the second two points. You know a line passing through points 1 and 3 must be parallel to the lines passing through points 2 and 4. You know a line passing through 1 and 2 must be orthogonal to a line passing through points 2 and 3. You know that the length of the line from 1 and 2 must equal the length of the line from 3 and 4. You know that the length of the line from 1 and 3 must equal the length of the line from 2 and 4.

为了使这更容易,你知道的矩形,所以你知道所有边的长度。

To make this even easier, you know about the rectangle, so you know the length of all the sides.

这应该给你足够的约束来解决这个问题。

That should give you plenty of constraints to solve this problem.

当然,要回,你可以找到T-倒数。

Of course, to get back, you can find T-inverse.

@ 罗布:是的,有无限多的预测,而不是项目的无穷数,其中的点必须满足的要求矩形。

@Rob: Yes, there are an infinite number of projections, but not an infinite number of projects where the points must satisfy the requirements of a rectangle.

@ nlucaroni :是的,如果你有在投影四点,这是唯一可以解决的。如果矩形项目仅​​有2点(即矩形的平面正交于投射面),那么这不能得到解决。

@nlucaroni: Yes, this is only solvable if you have four points in the projection. If the rectangle projects to just 2 points (i.e. the plane of the rectangle is orthogonal to the projection surface), then this cannot be solved.

嗯...我要回家写这个小宝石。这听起来很有趣。

Hmmm... I should go home and write this little gem. This sounds like fun.

更新:

  1. 除非你解决点​​中的一个有预测无限多。如果您在原始矩形的点修复,那么有两种可能的原始矩形。

这篇关于我如何反向工程2D点转换成3D?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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