如何有效地旋转和平移 3D 平面
我有一个由法线 (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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要小心,因为法线不一定像点那样变换,并且距离是到原点的垂直距离,因此您必须计算
d'= d + nv.如果您所做的只是平移和旋转,那么您可以旋转法线并计算新的垂直距离。但是,如果您以不同的方式缩放轴,或者进行一般的投影变换,那么您需要以不同的方式对待事物。
适用于所有情况的方法是使用齐次坐标,因此所有变换都是 4x4 矩阵,并且点和平面都是 4 向量:
通常,您会将所有变换矩阵乘以一个 4x4 矩阵 T,并使用它每个点上的矩阵,以确定其最终的变换位置。诀窍是,您需要使用 T 的转置来变换平面坐标。从下面可以看出,这保留了点和平面之间的重合:
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:
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:
如果人们想要更多细节,我将扩展上面的答案。给定由其定义的平面
法线 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
We can compute the signed Euclidean distance of p from the
plane as follows
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
Thus we have
Therefore the new normal and d' are