原点到平面的距离(最短) [英] Distance from origin to plane (shortest)

查看:32
本文介绍了原点到平面的距离(最短)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在这个页面上阅读了一些东西(http://gamedeveloperjourney.blogspot.com/2009/04/point-plane-collision-detection.html)

So I was reading over something on this page (http://gamedeveloperjourney.blogspot.com/2009/04/point-plane-collision-detection.html)

作者提到了

 d = - D3DXVec3Dot(&vP1, &vNormal);

其中 vP1 是平面上的一个点,vNormal 是平面的法线.我很好奇这如何让你得到与世界原点的距离,因为结果总是 0.另外,为了清楚(因为我对平面方程的 d 部分仍然有点模糊),平面方程中的 d 是通过世界原点的直线到平面原点的距离吗?

where vP1 is a point on the plane and vNormal is the normal to the plane. I'm curious as to how this gets you the distance from the world origin since the result will always be 0. In addition, just to be clear (since I'm still kind of hazy on the d part of a plane equation), is d in a plane equation the distance from a line through the world origin to the plane's origin?

推荐答案

在一般情况下,点p和平面之间的距离可以通过

In the generic case the distance between a point p and a plane can be computed by

<p - p0, normal>

其中 是点积运算

<a, b> = ax*bx + ay*by + az*bz

其中 p0 是平面上的一个点.

and where p0 is a point on the plane.

n 为单位长度时,向量之间的点积是向量在法线上投影的(有符号)长度

When n is of unity length the dot product between a vector and it is the (signed) length of the projection of the vector on the normal

您报告的公式只是点 p 是原点的特例.在这种情况下

The formula you are reporting is just the special case when the point p is the origin. In this case

distance = <origin - p0, normal> = - <p0, normal>

这种等式在形式上是错误的,因为点积是关于向量的,而不是点……但在数值上仍然成立.写下你得到的显式公式

This equality is formally wrong because the dot product is about vectors, not points... but still holds numerically. Writing down the explicit formula you get that

(0 - p0.x)*n.x + (0 - p0.y)*n.y + (0 - p0.z)*n.z

- (p0.x*n.x + p0.y*n.y + p0.z*n.z)

确实一个很好的存储平面的方法是保存正常的 nk = <p0, n> 的值,其中 p0 是平面上的任意一点(k 的值与你选择平面的哪个点无关).

Indeed a nice way to store a plane is to save the normal n and the value of k = <p0, n> where p0 is any point on the plane (the value of k is independent on which point you choose of the plane).

这篇关于原点到平面的距离(最短)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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