如何有效地旋转和平移 3D 平面

发布于 2024-08-22 08:04:49 字数 272 浏览 13 评论 0原文

我有一个由法线 (n) 和距离 (d)(距原点)定义的平面。我想把它改造成一个新的系统。 漫长的路是这样的: 1) 将距离 (d) 与法线 (n) 相乘,得到 aa 向量 (p) 2) 旋转(R)和平移(v)向量(p)得到(p') 3)标准化(p')以获得法线 4)使用另一种算法来找到新平面和原点之间的最小距离(d')

我还没有尝试过,但我想它应该可以工作。 问题: 没有更快的方法来获取 n' 和 d' 吗? 如果平移 (v) 为 0,那么我可以跳过 4)。但如果不为0呢?有没有更简单的方法来获得新的 d'?

I have a plane defined by a normal (n) and a distance (d) (from the origin). I would like to transform it into a new system.
The long way is like this:
1) multiply distance (d) with normal (n) resulting in a a vector (p)
2) rotate (R) and translate (v) the vector (p) to get (p')
3) normalize (p') to get the normal
4) use another algorithm to find the smallest distance (d') between the new plane and the origin

I haven't tried this but I guess it should work.
QUestion:
Isn't there a faster way to get n' and d'?
If the translation (v) is 0 than I can skip 4). But if it is not 0? Is there an easier way to get the new d'?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

财迷小姐 2024-08-29 08:04:49

您需要小心,因为法线不一定像点那样变换,并且距离是到原点的垂直距离,因此您必须计算d'= d + nv.如果您所做的只是平移和旋转,那么您可以旋转法线并计算新的垂直距离。但是,如果您以不同的方式缩放轴,或者进行一般的投影变换,那么您需要以不同的方式对待事物。

适用于所有情况的方法是使用齐次坐标,因此所有变换都是 4x4 矩阵,并且点和平面都是 4 向量:

point p=(x,y,z)        -> homogeneous (x,y,z,1), equiv. to (x*W, y*W, z*W, W)
plane q=[n=(a,b,c), d] -> homogeneous [a,b,c,d], equiv. to [a*K, b*K, c*K, d*K)

  -> point p is on plane q iff:  p.q=0   (using homogeneous coords, as above) 

通常,您会将所有变换矩阵乘以一个 4x4 矩阵 T,并使用它每个点上的矩阵,以确定其最终的变换位置。诀窍是,您需要使用 T 的转置来变换平面坐标。从下面可以看出,这保留了点和平面之间的重合:

point p' = T p
plane q' = (T^-1)^t q

  -> point p' is on plane q' when:  p'.q'=0

  then, note:  p'.q' = p^t T^t (T^-1)^t q = p^t q = p.q
  so:  p'.q'=0  whenever p.q=0

You need to be careful because normals don't necessarily transform like points do, and the distance is the perpendicular distance to the origin, so you have to compute d'= d + n.v. If all you're doing is translation and rotation, then you can rotate the normal and compute a new perpendicular distance. But, if you're scaling your axes differently, or doing a general projective transformation, then you need to treat things differently.

The way that works for everything is to use homogeneous coordinates, so all your transforms are 4x4 matrices, and both your points and your planes are 4-vectors:

point p=(x,y,z)        -> homogeneous (x,y,z,1), equiv. to (x*W, y*W, z*W, W)
plane q=[n=(a,b,c), d] -> homogeneous [a,b,c,d], equiv. to [a*K, b*K, c*K, d*K)

  -> point p is on plane q iff:  p.q=0   (using homogeneous coords, as above) 

Generally, you will multiply all your transformation matrices into one 4x4 matrix T, and use that matrix on every point, to determine its final transformed position. The trick is, you need to use the inverse transpose of T to transform your plane coordinates. From the following, you can see that this preserves incidence between points and planes:

point p' = T p
plane q' = (T^-1)^t q

  -> point p' is on plane q' when:  p'.q'=0

  then, note:  p'.q' = p^t T^t (T^-1)^t q = p^t q = p.q
  so:  p'.q'=0  whenever p.q=0
梦亿 2024-08-29 08:04:49
n' = n*R^T
d' = d - n*R^T*trans
n' = n*R^T
d' = d - n*R^T*trans
っ〆星空下的拥抱 2024-08-29 08:04:49

如果人们想要更多细节,我将扩展上面的答案。给定由其定义的平面
法线 n = [abc]^T 及其距原点的距离 d(假设 n 的大小为 1)和同质点 p

在此处输入图像描述

我们可以计算 p 的有符号欧几里得距离
平面如下

“在此处输入图像描述”

并注意,如果我们使用可逆变换 A 来变换 p,则变换后点的距离
如果我们通过 A 的逆转置来变换平面,则保留。

对于 A 由 3x3 旋转 R 组成的情况
3x1 翻译t我们有

在此处输入图像描述

因此我们有

在此处输入图像描述

因此新常态和 d' 是

在此处输入图像描述

I am going to expand on the answers above in case folks want a few more details. Given the plane defined by its
normal n = [a b c]^T and its distance d from the origin (assuming n has magnitude 1) and homogeneous point p

enter image description here

We can compute the signed Euclidean distance of p from the
plane as follows

enter image description here

and note that if we transform p with an invertible transformation A then the distance of the transformed point
is preserved if we transform the plane by the inverse transpose of A.

For the case where A is composed of a 3x3 rotation R and
a 3x1 translation t we have

enter image description here

Thus we have

enter image description here

Therefore the new normal and d' are

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文