喜.制作游戏并且正在寻找仅在3D空间中的正方形或矩形的光线交叉.有搜索网络,发现了很多解决方案,但我无法理解的是在2D中有线和线段交叉脚本,但我无法弄清楚必须使它成为3D.从它与正方形或矩形相交的一侧并不重要,但它必须能够反转交点矢量,以便以后可以测试距离se的距离,如果它发生在同一光线交叉点上的其他交叉点之前或之后.
将非常感谢python或其他类似脚本语言中的任何示例
编辑:不知道必须修改2D以显示一个exaple但新的和发布两者.
//this is the exaple it test a ray onto a plane then look to se if that point is in the rectangle and saves it to test for distanse later
list Faces; //triangle faces
list Points; //
vector FindPoint(){
//calcute the point of intersection onto the plane and returns it
//if it can intersect
//else return ZERO_VECTOR
}
integer point-in-quadrilateral(){
//return 1 if the point is in the rectangular on the plane
//else return 0
} …Run Code Online (Sandbox Code Playgroud)