如何根据 3D 平面和已知原点计算新的基础(变换矩阵)?

发布于 2025-01-03 13:00:22 字数 143 浏览 3 评论 0原文

给定一个 3D 平面及其上的任意点,我想考虑新基础的原点 (0,0,0),可以: (A) 根据此信息定义基础? (B) 创建一个变换矩阵,允许我在世界空间和新基础之间进行转换?

我可以假设变换是仿射的。

非常感谢!

Given a 3D plane and an arbitrary point on it that I want to consider the origin (0,0,0) of a new basis, it is possible to: (A) define a basis from this information? And (B) create a transformation matrix that allows me to convert between world space and the new basis?

I can assume the transformation is affine.

Thanks very much!

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

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

发布评论

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

评论(1

瑶笙 2025-01-10 13:00:22

简短的答案是肯定的,但由于您只有一个平面,因此新基础的方向将是任意的。

假设您有一个点 k 位于平面 P 上,并且您希望点 k 作为原点。您有 P = (N, d),其中 N 是标准化平面法线,d 是从原点到平面的距离。

确定该平面上任意方向的正交基
定义 3 个向量右 R、上 U 和法线 N

我们已经有了 N,它只不过是法线平面

U = (0,1,0)
// If U is pointing in almost the same direction as N, change it
if (U.N > 0.7071) U = (0, 0, 1);
R = normalise (U x N)
U = normalise (N x R) // U was not orthonormal

现在定义一个 3x3 变换矩阵 M,其中矩阵的 3 行分别是 R、U 和 N。

      R
M = ( U )
      N

现在假设您想要将平面上的点 p 转换为点 p'

p' = M ( p - k )

如果您想用一个矩阵完成所有这些操作,您可以将 M 和平移向量 -k 组合成一个 4x4 齐次矩阵。
注:

  1. 上面的 . 是向量点积
  2. 上面的 x 是向量叉积

HTH

The short answer is yes, but since you only have a plane the orientation of the new basis will be arbitrary.

Lets say you have a point k that lies on the plane P and you want point k as your origin. You have P = (N, d) where N is the normalised plane normal and d is the distance to the plane from the origin.

To determine an orthonormal basis with arbitrary orientation on this plane
Define 3 vectors right R, up U and normal N

We already have N which is nothing but the normal of the plane

U = (0,1,0)
// If U is pointing in almost the same direction as N, change it
if (U.N > 0.7071) U = (0, 0, 1);
R = normalise (U x N)
U = normalise (N x R) // U was not orthonormal

Now define a 3x3 transformation matrix M where the 3 rows of the matrix are R, U and N respectively.

      R
M = ( U )
      N

Now let us say you wanted to transform a point p to a point p' on your plane.

p' = M ( p - k )

If you want to do all this with one matrix you can combine M and the translation vector -k into a 4x4 homogeneous matrix.
Notes:

  1. The .'s above are vector dot products
  2. The x's above are vector cross products

HTH

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