# Point In Cylinder

Point   :   P

Cylinder:   |(P – O) - ((P – O) • N) * N | <= R

0 <= (P – O)• N <= L

Structure:  { V3d   O;

float R;

V3d   N;

Float L;  }

V = P – O;

dp = V • N;

if ( dp < 0 || dp > L )     return Outside;

T = V –dp * N;

if ( T^2 > R^2 )            return Outside;

return Inside;

Point In Cone

Point   :   P

Cone    :   |(P – O) – ((P – O) • N) * N| <= ((P – O) • N) * R / L

0 <= (P – O)• N <= L

The Data Structure of Cone is same as Cylinder.

V = P – O;

dp = V • N;

if ( dp < 0 || dp > L )     return Outside;

T = V –dp * N;

r = dp * R / L

if ( T^2 > r^2 )            return Outside;

return Inside;

Sphere & Cylinder

Sphere  :   | P – C | <= r

Cylinder:   |(P – O) - ((P – O) • N) * N | <= R

0 <= (P – O)• N <= L

OC = C – O;

dp = OC • N

if ( (dp > L + r) || (dp < -r) )      return No Intersection;

T = OC - dp * N;

if ( dp > L )

{

f = sqrt( r^2 – (dp - L)^2 );

if ( T^2 > (R + f)^2 )              return No Intersection;

return Intersectant;

}

else if ( dp >= 0 )

{

if ( T^2 > (R + r)^2 )              return No Intersection;

return Intersectant;

}

else

{

f = sqrt( r^2 – dp^2 );

if ( T^2 > (R + f)^2 )              return No Intersection;

return Intersectant;

}

Line Segment & Cylinder

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

Cylinder:   |(P – O) - ((P – O) • N) * N | <= R

0 <= (P – O)• N <= L

OP = P – O = P0 + t * V – O = (P0 – O) + t * V;

dp = OP • N

dp0 = (P0 – O)• N          t = 0

if ( dp0 > L )      return No Intersection;

dp1 = (P0 – O + V)• N      t = 1

if ( dp1 < 0 )      return No Intersection;

|(P0 – O) + t * V – (((P0 – O) + t * V) • N) * N | <= R

|(P0 – O) + t * V – ((P0 – O) • N) * N – ((t * V) • N) * N | <= R

|(P0 – O) – ((P0 – O) • N) * N + t * V - t * (V • N) * N | <= R

|((P0 – O) – ((P0 – O) • N) * N) + t * (V - (V • N) * N) | <= R

F = (P0 – O) – ((P0 – O) • N) * N;

G = V - (V • N) * N;

G^2 * t^2 + 2 * (F • G) * t + F^2 – R^2 = 0;

A = G^2;

B = 2 * (F • G);

C = F^2 – R^2;

if ( A > 0 )    //V is not parallel to N

{

Δ= B^2 – 4AC;

if ( Δ < 0 )               return No Intersection;

t = (-B ± sqrt(B^2 – 4AC)) / 2A;

t1 <= t2;

if ( t2 < 0 || t1 > 1 )    return No Intersection;

return Intersectant;

}

if ( C <= 0 )                 return Intersectant;

return No Intersection;

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

## UE4的Collision与Physics

Collision和Physics都是各种Mesh的属性，和Unity3D很像，Collision和Physics是两个独立的Component，Collision仅仅掌管碰撞发生的检测和回调，而Ph...

## 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...

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