检查其中一架飞机的一侧点上一架、点上、飞机

2023-09-08 01:15:24 作者:Temptat10n ゜ 夜

我想利用3D点阵列和平面和高达划分点为基础,他们在飞机上的哪一边2阵列。之前,我要大举进入调试我想发布什么,我打算做,以确保我如何做到这将工作的认识。

I'm trying to take an array of 3D points and a plane and divide the points up into 2 arrays based on which side of the plane they are on. Before I get to heavily into debugging I wanted to post what I'm planning on doing to make sure my understanding of how to do this will work.

基本上我有3点的飞机,我用(伪code):

Basically I have the plane with 3 points and I use (pseudo code):

var v1 = new vector(plane.b.x-plane.a.x, plane.b.y-plane.a.y, plane.b.z-plane.a.z);
var v2 = new vector(plane.c.x-plane.a.x, plane.c.y-plane.a.y, plane.c.z-plane.a.z);

我拿这两个向量的交叉产品,以获得正常的载体。

I take the cross product of these two vectors to get the normal vector.

然后,我通过我点的数组并把它们变成矢量和计算的点积对正常的。

Then I loop through my array of points and turn them into vectors and calculate the dot product against the normal.

然后,我用的点积来确定侧面的一点是。

Then i use the dot product to determine the side that the point is on.

这听起来像它会工作?

推荐答案

A * X + B * Y + C * Z + D = 0 是公式确定你的飞机。

Let a*x+b*y+c*z+d=0 be the equation determining your plane.

替换为 [X,Y,Z] 坐标点入公式(我指的左侧的 A * X + B * Y + C * Z + D )并查看结果的符号。

Substitute the [x,y,z] coordinates of a point into the left hand side of the equation (I mean the a*x+b*y+c*z+d) and look at the sign of the result.

是在飞机上的同一侧具有相同符号的分

The points having the same sign are on the same side of the plane.

说实话,我也没检验你写的细节。我猜你同意我的建议是简单的。

Honestly, I did not examine the details of what you wrote. I guess you agree that what I propose is simpler.