Ray - Box Intersection
来源:互联网 发布:mac word 登录 编辑:程序博客网 时间:2024/06/04 17:50
We can use a box both as an object and a bounding volume. Kay and Kayjia developed a method based on "slabs" where a slab is the space between two parallel planes. So the intersection of a set of slabs defines a bounding volume or a box.
The method looks at the intersection of each pair of slabs by the ray. It finds tfar and tnear for each pair of slabs. If the overall largest tnear value i.e,. intersection with the near slab, is greater than the smallest tfar value (intersection with far slab) then the ray misses the box, else it hits the box. We can use as the simplest bounding volume the intersection of the sets of two parallel planes where each set has normals along the X, Y, or Z axes.
We will define the box by two coordinates: the box's minimum extent Bl = [ Xl Yl Zl ] and the box's maximum extent Bh = [ Xh Yh Zh ]
Image Reference
The Ray is defined as before in terms of Ro, Rd Then the algorithm is as follows:
set Tnear = - infinity, Tfar = infinity
For each pair of planes P associated with X, Y, and Z do:
(example using X planes)
if direction Xd = 0 then the ray is parallel to the X planes, so
if origin Xo is not between the slabs ( Xo < Xl or Xo > Xh) then return false
else, if the ray is not parallel to the plane then
begin
compute the intersection distance of the planes
T1 = (Xl - Xo) / Xd
T2 = (Xh - Xo) / Xd
If T1 > T2 swap (T1, T2) /* since T1 intersection with near plane */
If T1 > Tnear set Tnear =T1 /* want largest Tnear */
If T2 < Tfar set Tfar="T2" /* want smallest Tfar */
If Tnear > Tfar box is missed so return false
If Tfar < 0 box is behind ray return false end
end of for loop If Box survived all above tests, return true with intersection point Tnear and exit point Tfar.
Example: Figure (left)
set tnear = -infinity, tfar = infinityFor X planesRay not parallelCompute intersection T1 <- Tx1, T2 <- Tx2
T2 > T1 so no swapT1 > Tnear so Tnear <-- T1 (Tx1)T2 < T far so Tfar <-- Tx2Tnear < Tfar and Tfar > 0 so do Y planesY planesRay not parallelCompute intersection T1 <-- Ty1, T2 <-- Ty2T1 < Ty2 so no swapT1 not > Tnear so no changeT2 < Tfar, so Tfar = T2(Ty2)Tnear > Tfar -> therefore return false and done Second example from figure (right) set tnear = -infinity, tfar = infinityX planesnot parallel t1 <- tx1, t2 <- tx2 If t1 < t2 so no swap; t1 > tnear so tnear <- t1 ; t2 < tfar so tfar <- t2; If tnear < tfar so OK; If tfar < 0 so OK; now do Y planes not parallel t1 <- ty1, t2 <- ty2 t1 < t2 so no swap; t1 < tnear so no change; t2 < tfar so tfar <- t2; tnear > tfar ? no tfar < 0 ? no Thus, return true with intersection point = tnear = tx1;
- Ray - Box Intersection
- Ray-box intersection algorithm
- 射线—方盒相交计算 Ray-Box Intersection
- 《An Introduction to Ray Tracing》—— 2.4 Ray/Box Intersection
- Ray Box 碰撞检测
- Ray Box求交点
- 碰撞检测之Ray-Box检测
- 射线与平面的相交检测(Ray-Plane intersection test)
- 射线与平面的相交检测(Ray-Plane intersection test)
- Real-Time Rendering (8) - 光线求交(Ray intersection)
- 射线与平面的相交检测(Ray-Plane intersection test)
- 射线与平面的相交检测(Ray-Plane intersection test)
- 射线与平面的相交检测(Ray-Plane intersection test)
- 《An Introduction to Ray Tracing》——2.2 Ray/Sphere Intersection And Mapping
- 《An Introduction to Ray Tracing》——2.3 Ray/Polygon Intersection And Mapping
- 《An Introduction to Ray Tracing》—— 2.5 Ray/Quadric Intersection And Mapping
- Ray
- maya bounding box & detect intersection of two faces/polygons
- redies和memcache区别
- Android 下拉刷新(使用异步任务和ViewTreeObserver监听)
- 整理C# 二进制,十进制,十六进制 互转
- Unity3D NGUI动态创建按钮
- 分区表统计信息用法
- Ray - Box Intersection
- 去IOE运动-正在路上
- C++-----虚析构函数
- Asterisk originate的用途
- 2013:由工地到IT的转变
- 少用触发器规范
- 航班号总结业务
- 色调、亮度和饱和度
- 【JMeter】解决关联值中涉及括号的正则表达式问题