我如何才能知道点是否在3D三角形内? [英] How can I find out if point is within a triangle in 3D?

查看:270
本文介绍了我如何才能知道点是否在3D三角形内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个算法(3D),它可以确定点是否属于一个三角形。而且如果是这样,我想知道三角形中某点与另一点之间的距离。三角形可以稍微旋转,但如果点在三角形之外,则不应将其视为三角形内部。



现在我意识到,我的问题可能不会作出很多意义所以这里是图片,这解释了我想要的。




灰色线条显示,三角形实际面对的方式。



< hr>

实际上我并不是想检查一个点是否在棱镜内,但是当我发现点之后是否位于三角形内(不完全是,可能位于三角形之上或下面),那么我需要找到点与它所属的三角形之间的距离。根据距离不同,如果该点位于三角形内部,函数将最终返回。允许有些不准确。但是,也许我想检查一个点是否在棱镜内,但不知道。我只是在数学上很可怕,所以我不知道正确的术语。 这似乎是3D等同于查询位于三角形内的点的数据结构
您可以在3D中使用相同的方法:在3D中,平面将空间切成两半:一个点位于飞机的一侧或另一侧。楔形是飞机的集合:只需将给定点的which_side_of_the_plane信息与构建楔形物的所有平面结合在一起。


I need an algorithm (3D), which would determine if point belongs to a triangle. And also if it does I want to know the distance between some point in triangle and a another point. Triangles can be slightly rotated, but if point is outside triangles vertical reach then it should not be considered as inside the triangle.

Now I realize, my question probably doesn't make a lot of sense so here's the picture, which explains what I want.

Grey lines display, which way triangle is actually facing.


It's not actually that I want to check if a point is within a prism, but I after i find out if point lies within triangle (not exactly, might be on top of or below) then I need to find the distance between point and a triangle it belongs to. And depending on the distance function will finally return if that point is inside the triangle. A little inaccuracy is allowed. However, maybe I want to check if a point is within a prism, but do not know that. I am just horrible at math so I am not aware of correct terminology.

解决方案

This seems like the 3D equivalent of Data structure to query points which lie inside a triangle. You could use the same method in 3D: in 3D, a plane cuts the space in two halves: a point is either at one side of the plane or at the other side. The wedge-shape is a collection of planes: just combine the which_side_of_the_plane information for a given point with all the planes that build up the wedge.

这篇关于我如何才能知道点是否在3D三角形内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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