快球网交会 [英] fast sphere-grid intersection

查看:120
本文介绍了快球网交会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个三维网格,三维点为球心和半径,我想快速计算包含或相交的领域的所有细胞。

given a 3D grid, a 3d point as sphere center and a radius, i'd like to quickly calculate all cells contained or intersected by the sphere.

目前我是否球体的(gridaligned)​​外接矩形框,并计算两个单元的这种外接矩形框的最小ANX最大点。然后,对于这两个细胞之间的每一个单元,我做的盒球体相交测试

Currently i take the the (gridaligned) boundingbox of the sphere and calculate the two cells for the min anx max point of this boundingbox. then, for each cell between those two cells, i do a box-sphere intersection test.

如果有将是巨大的东西更有效

would be great if there was something more efficient

谢谢!

推荐答案

有一个版本的Bresenham算法的画圆。考虑在z = 0的二维位置(假设球是在0,0,0现在),并期待在网格点只有XY平面。起点为x = R,Y = 0,按照Bresenham算法最多为y = y_R,X = 0,只不过不是绘画,你只需要使用的结果就知道所有网格点下面的x坐标在圈子里面,倒于x = x_center。把那些在列表中,计算它们或以其他方式说明的。当有两个层面的问题进行,重复使用不同的Z和使用替代R的减少半径R(Z)=开方(R ^ 2-Z ^ 2),直到Z = R上。

There's a version of the Bresenham algorithm for drawing circles. Consider the two dimensional place at z=0 (assume the sphere is at 0,0,0 for now), and look at only the x-y plane of grid points. Starting at x= R, y=0, follow the Bresenham algorithm up to y = y_R, x=0, except instead of drawing, you just use the result to know that all grid points with lower x coordinates are inside the circle, down to x=x_center. Put those in a list, count them or otherwise make note of. When done with two dimensional problem, repeat with varying z and using a reduced radius R(z) = sqrt(R^2-z^2) in place of R, until z=R.

如果球心确实是坐落在一个网格点,你知道这里面或球体的右半边外每个格点的对左边一个镜像伙伴,同样顶部/底部,所以你可以做一半每个维度计数/上市。还可以节省运行布氏只到45度线的时间,因为任何的x,相对于芯Y点有一个伙伴Y,X。如果球体可以在任何地方,你将不得不计算结果为每个八分。

If the sphere center is indeed located on a grid point, you know that every grid point inside or outside the right half of the sphere has a mirror partner on the left side, and likewise top/bottom, so you can do half the counting/listing per dimension. You can also save time running Bresenham only to the 45 degree line, because any x,y point relative to the center has a partner y,x. If the sphere can be anywhere, you will have to compute results for each octant.

这篇关于快球网交会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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