# Sphere & AABB

Sphere:   | P – C | <= R

AABB :A  { V3d inf, sup;}

//摘自Real Time Rendering

d = 0;

for each i [x, y, z]

{

if ( C.i < A.inf.i )

{

d += (C.i –A.inf.i)^2;
}

else

if ( C.i > A.sup.i )

{

d += (C.i –A.sup.i)^2;
}

}

if ( d > R^2 )return No Intersection;

return Intersectant;

# Sphere & OBB

Sphere:   | P – Q | <= R

OBB :     {  V3d C, U, V, W;

V3d L; }      //C是中心点坐标，U、V、W是三个轴方向，L的三个分量是U、V、W是三个方向的半长，表示Box长宽高各一半大小

Method(1)

做空间变换，使得变成Sphere & AABB的相交判断，这种做法是Real Time Rendering上写的

Method(2)

S = Q – C;

x = S • U;

y = S • V;

z = S • W;

d = 0;

for each i [x, y, z]

{

if ( i < -L.i )

{

d += (i + L.i)^2;

}

else

if (i > L.i )

{

d += (i –L.i)^2;

}

}

if ( d > R^2 )return No Intersection;

return Intersectant;

Ellipsoid & AABB

Ellipsoid:    (x - x0)^2 / a^2 + (y - y0)^2 / b^2 + (z - z0)^2 / c^2 <= 1       (a>0, b>0, c>0)

AABB   :  A  { V3d inf, sup;}

Method(1)

做空间变换，将Ellipsoid变换成Sphere，然后做Sphere & AABB的相交判断

Method(2)

P0 = { x0, y0, z0 };

d = 0;

for each i [x, y, z], j ∈ [a, b, c]

{

if ( P0.i < A.inf.i )

{

d += (P0.i –A.inf.i)^2 / j^2;
}

else

if ( P0.i > A.sup.i )

{

d += (P0.i –A.sup.i)^2 / j^2;
}

}

if ( d > 1 )  return No Intersection;

return Intersectant;

# Ellipsoid& OBB

Ellipsoid:    (x - x0)^2 / a^2 + (y - y0)^2 / b^2 + (z - z0)^2 / c^2 <= 1       (a>0, b>0, c>0)

OBB   :  {   V3d C, U, V, W;

V3d L; }

Method(1)

做空间变换，将Ellipsoid变换成Sphere，然后做Sphere & OBB 的相交判断

Method(2)

做空间变换，将OBB变换成AABB，然后做Ellipsoid & AABB的相交判断

Method(3)

做两次空间变换，将Ellipsoid变换成Sphere，OBB变换成AABB，然后做Sphere & AABB的相交判断

Method(4)

P0 = { x0, y0, z0 };

S = P0 – C;

x = S • U;

y = S • V;

z = S • W;

d = 0;

for each i [x, y, z], j ∈ [a, b, c]

{

if ( i < -L.i )

{

d += (i + L.i)^2 / j^2;

}

else

if ( i > L.i )

{

d += (i –L.i)^2 / j^2;

}

}

if ( d > 1 )  return No Intersection;

return Intersectant;

Line Segment & Sphere, Optimized

Line Seg:  P = P0 + t * V         t ∈ [0, 1]

Sphere :  | P – C | <= R

//摘自Real Time Rendering

L = C – P0;

s = V • L / |V|;

l2 = L^2;

if ( s < 0 && l2 > r^2 )   return No Intersection;

m2 = l2 – s^2;

if ( m2 > r^2 )           return No Intersection;

returnIntersectant;

//q = sqrt(r^2 – m^2);

//if ( l^2 > r^2 ) t = (s – q) / |V|;

//elset = (s + q) / |V|

• 本文已收录于以下专栏：

## opencv 第10天 Detecting and Matching Interest Points

Detecting Harris corners int main() { Mat cornerStrength; Mat image = imread("D:\\images\\church01...

## 多尺度R-CNN(2): Inside-Outside Net: Detecting Objects in Context with Skip Pooling and Recurrent Neural

CNN高层特征具有丰富的语义信息，低层特征具有较高空间分辨率，研究如何融合不同层之间的特征，是物体检测领域热门的方向。近期很多工作通过融合多层来提升检测和分割的性能，按照融合与预测的先后顺序，分类为早...

## Detecting cryptographic misuse with Argus static analysis framework

In the last post I talked about Argus static analysis framework and his capabilities for analyzing...

## Tutorial: Detecting When A User Blows Into The Mic

http://mobileorchard.com/tutorial-detecting-when-a-user-blows-into-the-mic/   byDan Grigsbyon19. Aug...

## Tutorial: Detecting When A User Blows Into The Mic(检测麦克音量)

http://mobileorchard.com/tutorial-detecting-when-a-user-blows-into-the-mic/ If, a couple of yea...

## 【Abstract-1】Lost and Found: Detecting Small Road Hazards for Self-Driving Vehicles

Lost and Found: Detecting Small Road Hazards for Self-Driving VehiclesLost and Found：自动驾驶车辆的道路小危害检测P...

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)