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

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

问题描述

所以我正在阅读此页面上的内容( 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>是点积运算

<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天全站免登陆