简体   繁体   English

如何在Three.js中检查两个凸多面体是否相交?

[英]How to check if two convex polyhedrons intersect with each other in Three.js?

I'm working on a problem that need to randomly generate and put convex polyhedrons into a cube/cylinder container at randomly chosen points without overlapping. 我正在研究一个需要随机生成凸多面体并将其随机放置在立方体/圆柱容器中且没有重叠的问题。 I'm using to get a graphic output. 我正在使用来获取图形输出。

A demo. 一个演示。

While putting a polyhedron, how to check whether it intersects with other polyhedrons? 放置多面体时,如何检查它是否与其他多面体相交?

The convex polyhedron involved is simply tetrahedron or hexahedron and is constructed using THREE.ConvexGeometry. 涉及的凸多面体只是四面体或六面体,并且使用THREE.ConvexGeometry构造。 As I need a precise check, bounding box is not enough, I just use it to make sure two polyhedrons are not intersected. 因为我需要精确的检查,所以边界框还不够,我只是用它来确保两个多面体没有相交。

I've done a lot research and found many complicated theories and methods, what I need is to get a Boolean result that tells if there exists an intersection between two convex polyhedrons. 我做了很多研究,发现了许多复杂的理论和方法,我需要得到一个布尔结果,该结果表明两个凸多面体之间是否存在交集。 SAT (Separating Axis Theorem) in 3D is good enough, but Three.js doesn't seem to be capable of doing this. 3D SAT(分离轴定理)足够好,但是Three.js似乎无法做到这一点。 Can anyone tell me how to do this kind of check in a simple way or just explain how to do it with SAT in 3D? 谁能告诉我如何以一种简单的方式进行这种检查,或者仅说明如何使用SAT 3D进行检查?

You can take a look at http://www.realtimerendering.com/intersections.html . 您可以查看http://www.realtimerendering.com/intersections.html Even though the site is from 2011 the intersection algorithms have not changed in the last years. 即使该站点是从2011年开始的,但相交算法在最近几年中都没有改变。 From the demo it seems that once the polyhedrons are placed in the cube, they don't move. 从演示中可以看出,一旦将多面体放置在立方体中,它们就不会移动。 So the SAT algorithm would not be the best solution as it is used for moving polyhedra. 因此,SAT算法不是用于移动多面体的最佳解决方案。

The Gilbert–Johnson–Keerthi is a powerful algorithm that allow to measure distance and check for intersection between convex polyhedrons. Gilbert–Johnson–Keerthi是一种功能强大的算法,可以测量距离并检查凸多面体之间的交集。 Still I believe that it is better to use on simple polyhedron otherwise the computation in the support function might take some time. 我仍然相信最好在简单的多面体上使用,否则支持函数中的计算可能会花费一些时间。 A possible drawback is that you need to have functions able to measure the distance between a point and another point/segment/triangle, I do not know if some are available in three.js. 一个可能的缺点是,您需要具有能够测量一个点与另一个点/段/三角形之间的距离的函数,我不知道three.js中是否提供某些功能。

http://en.wikipedia.org/wiki/Gilbert%E2%80%93Johnson%E2%80%93Keerthi_distance_algorithm http://en.wikipedia.org/wiki/Gilbert%E2%80%93Johnson%E2%80%93Keerthi_distance_algorithm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM