检查平面点在哪一边 [英] Check which side of a plane points are on

查看:43
本文介绍了检查平面点在哪一边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取一组 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 个点的平面,我使用(伪代码):

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.

这篇关于检查平面点在哪一边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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