简体   繁体   English

我的平面不是垂直的,如何将点云的坐标更新为垂直平面

[英]my plane is not vertical, How to update coordinate of point cloud to lie on a vertical plane

I have a bunch of points lying on a vertical plane. 我有一堆点位于垂直平面上。 In reality this plane should be exactly vertical. 实际上,该平面应该完全垂直。 But, when I visualize the point cloud, there is a slight inclination (nearly 2 degrees) from the verticality. 但是,当我可视化点云时,相对于垂直度会有一点倾斜(接近2度)。 At the moment, I can calculate this inclination only. 目前,我只能计算此倾斜度。 Concerning other errors, I assume there are no shifts or something like that. 关于其他错误,我认为没有任何变化或类似的东西。

So, I want to update coordinates of my point data so that they lie on the vertical plane. 因此,我想更新点数据的坐标,使它们位于垂直平面上。 I think, I should do some kind of transformation. 我认为,我应该进行某种转变。 It may be only via rotation along X-axis. 可能仅通过沿X轴旋转即可。 Not sure what it would be. 不知道会是什么。

I guess, you understood my question. 我想,你明白我的问题了。 Honestly, I am poor at mathematics. 老实说,我在数学方面很差。 So, please let me know how to update my point coordinates to lie on the exact vertical plane. 因此,请让我知道如何更新我的点坐标,使其位于精确的垂直平面上。

Note: AS I am implementing this in c++ and there are many programmers who have sound knowledge on these things, I am posting this question under c++. 注意:由于我是用c ++实现的,因此许多程序员对这些事情都有很好的了解,所以我将这个问题发布在c ++下。

UPDATES 更新

If I say exactly what I have done so far; 如果我确切地说到目前为止我做了什么, I have point cloud data representing a vertical object + its surroundings things. 我有代表垂直对象及其周围事物的点云数据。 (The data is collected by a moving scanner and may have axes deviations from the correct world axes). (数据由移动的扫描仪收集,并且可能与正确的世界坐标轴有所偏差)。 The problem is, I cannot say exactly that there is an error on my data or not. 问题是,我无法确切地说出我的数据是否有错误。 Therefore, I checked this with a vertical planar object (which is the dominated object in my data as well). 因此,我使用垂直平面对象(这也是我数据中的主要对象)检查了此对象。 In reality that plane is truly vertical. 实际上,这架飞机是真正垂直的。 But, when I fit a plane by removing outliers, then that plane is not truly vertical and has nearly 2 degree inclination. 但是,当我通过移除异常值来拟合平面时,该平面并不是真正的垂直,而是具有近2度的倾斜度。 Therefore, I am suspecting that my data has some error. 因此,我怀疑我的数据有一些错误。 So I want to update all my point clouds (including points on the plane and points which represent other objects) in a way to lay that particular planar points exactly on the vertical plane. 因此,我想更新我的所有点云(包括平面上的点和代表其他对象的点),以将特定的平面点准确地放置在垂直平面上。 Then, I guess, all the points will be updated into their correct positions as in the reality. 然后,我想所有点都将更新为实际中的正确位置。 That is all (x,y,z) coordinates should be updated. 那就是所有(x,y,z)坐标都应该更新。

As an example please refer the below figure. 例如,请参考下图。 在此处输入图片说明

left-represents original point cloud (as you can see, points themselves are not vertical) and back line tells the vertical plane which I fitted and red is the zenith line. 左边表示原始点云(如您所见,点本身不垂直),后线表示我拟合的垂直平面,红色是天顶线。 as you can see, there is an inclination of the vertical plane. 如您所见,垂直平面存在一定的倾斜度。 So, I want to update whole my data in the right figure. 因此,我想在正确的图中更新整个数据。 then, after updating if i fit a plane again (removing outliers), then it is exactly parallel to the zenith line. 然后,在更新之后,如果我再次适合平面(移除异常值),则它与天顶线完全平行。 please help me. 请帮我。

I may be able to help you out, considering I worked with planes recently. 考虑到我最近在飞机上工作,我也许可以为您提供帮助。 First of all, how come the points aren't coplanar from the get go? 首先,这些点从一开始就为什么不是共面的? I'd make the points coplanar in the first place instead of them being at an inclination (from what origin?), and then having to fix them. 我首先要使这些点共面,而不是使它们倾斜(从哪个起源?),然后必须对其进行修复。 Also, having the points be coplanar on your first go would increase efficiency. 同样,在每次尝试时使点共面会提高效率。

Sorry if this is the answer you're not looking for, but I need more information before I can help you out. 抱歉,这不是您要找的答案,但是在需要您帮助之前,我需要更多信息。 Also, 3D math is hard. 另外,3D数学很难。 If you work with it enough, it starts to get pounded into your head, where you will NEVER forget it, especially if you went through the headaches I had to go through. 如果您使用得足够多,它就会开始沉入您的脑海,您将永远不会忘记它,尤其是当您经历了我不得不经历的头痛时。

I did a bit of thinking on it, and since you want to rotate along the x-axis, your rotation will be done on the xz-plane, which means we can make this a 2D problem. 我对此进行了一些思考,并且由于您想沿x轴旋转,因此您的旋转将在xz平面上完成,这意味着我们可以将其视为2D问题。 After doing a bit of research on Wikipedia, this may be your solution. 在对Wikipedia进行了一些研究之后,这可能是您的解决方案。

new z = ((x - intended x) * sin(angle)) + (z * cos(angle)) + intended x

What I'm doing here is subtracting our intended x value from our current x value, so that we make (intended x, 0) our point of origin to rotate around. 我在这里所做的是从当前的x值中减去我们期望的x值,以便使(原为x,0)原点旋转。 After the point is rotated, I add (intended x, 0) back to our coordinate so that we get the correct result. 旋转点之后,我将(打算x,0)添加回我们的坐标,以便获得正确的结果。

Depending on where you got your points from (some kind of measurement, I guess) and what you want to do with them, there are several different things you could do with your data. 取决于您从何处获得积分(我想是某种测量方法)以及您想对它们进行什么处理,您可以对数据进行多种处理。

The search keyword "regression plane" might help - there are several ways of finding planes approximating point clouds, and several ways to "snap" points to planes. 搜索关键字“回归平面”可能会有所帮助-有几种找到近似点云的平面的方法,还有几种“捕捉”点到平面的方法。

Edit : You want to apply a rotation around the axis defined by the cross product of the normal vector on your regression plane and the normal of your desired plane, and a point your choice. 编辑 :您想围绕由回归平面上的法线向量和所需平面的法线的叉积定义的轴应用旋转,并选择一个点。 From your illustration I take it that you probably want the bottom of your vertical planar object to be the point of reference for the rotation. 从您的插图中,我认为您可能希望垂直平面对象的底部成为旋转的参考点。

So you've got your point of reference, you now the axis around which you want to rotate, and the angle. 这样便有了参考点,现在有了要旋转的轴和角度。 All you need to do is: 您需要做的只是:

  1. Translation (to get to your point of reference) 翻译(以供参考)
  2. Rotation 回转

I read your question again, and hopefully this answer will help you out. 我再次阅读了您的问题,希望这个答案对您有所帮助。 If there's anything else I need to know, please tell me. 如果还有其他需要知道的内容,请告诉我。

Now, In order to rotate anything, there must be a center point to rotate around. 现在,要旋转任何东西,必须有一个旋转的中心点。 Now you've already been able to detect the angle of inclination, so now we need a formula for rotating a point a certain angle around an origin. 现在您已经能够检测到倾斜角度,因此现在我们需要一个公式来使点围绕原点旋转一定角度。 In addition, since this problem only occurs on a 2D plane, we can use this basic formula to readjust the points. 此外,由于此问题仅发生在2D平面上,因此我们可以使用此基本公式重新调整点。 For any two axis x and y: 对于任何两个轴x和y:

Theta is the angle that you will rotate around in a counter-clockwise direction. Theta是您将沿逆时针方向旋转的角度。 x' and y' are your new points. x'和y'是您的新观点。 x.origin and y.origin are the coordinates for the point you will be going around. x.origin和y.origin是您要绕过的点的坐标。 Now I don't know if my math is 100% correct on this but if it's not, hopefully you can change a thing or two and it will work. 现在我不知道我的数学对此是否100%正确,但是如果不是,那么希望您可以更改一两件事,并且它会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM