如何有效地旋转和平移 3D 平面 [英] How to efficiently rotate and translate a plane in 3D

查看:41
本文介绍了如何有效地旋转和平移 3D 平面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由法线 (n) 和距离 (d)(距原点)定义的平面.我想把它改造成一个新的系统.长路是这样的:1) 将距离 (d) 与法线 (n) 相乘得到一个向量 (p)2) 旋转 (R) 并平移 (v) 向量 (p) 得到 (p')3) 归一化 (p') 得到法线4)用另一种算法求新平面到原点的最小距离(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

我还没有尝试过这个,但我想它应该可以工作.题:没有更快的方法来获得 n' 和 d' 吗?如果翻译 (v) 为 0,则我可以跳过 4).但是如果不是0呢?有没有更简单的方法来获得新的 d'?

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'?

推荐答案

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

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.

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

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) 

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

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

这篇关于如何有效地旋转和平移 3D 平面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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