Primitive Collision Detecting (4)

原创 2006年05月18日 01:21:00

 

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...
  • zzk1995
  • zzk1995
  • 2015年10月10日 18:43
  • 5039

Unreal Engine 4 空场景创建 并为物体添加 Collision Volumes

因为新建空场景中没有添加任何光源,为了在未添加光源之前方便查看添加到场景中的游戏物体,可以设置以下选项 调整大小做为地面 添加材质 ...

Web Service and primitive SOA

  • 2014年06月27日 21:26
  • 1.25MB
  • 下载

7series_hdl_primitive_library

  • 2014年10月27日 22:10
  • 12.64MB
  • 下载

【ECCV2016】Detecting Text in Natural Image with Connectionist Text Proposal Network

本文的方法最大亮点在于把RNN引入检测问题(以前一般做识别)。文本检测,先用CNN得到深度特征,然后用固定宽度的anchor来检测text proposal(文本线的一部分),并把同一行anchor对...

opencv 第10天 Detecting and Matching Interest Points

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

Detecting Near-Duplicates for Web Crawling - simhash与重复信息识别

随着信息爆炸时代的来临,互联网上充斥着着大量的近重复信息,有效地识别它们是一个很有意义的课题。例如,对于搜索引擎的爬虫系统来说,收录重复的网页是毫无意义的,只会造成存储和计算资源的浪费;同时,展示重复...

Detecting Texts of Arbitrary Orientations in Natural Images(总结)

Detecting Common Gestures

当用户将一个或多个手指放在屏幕上时,“touch gesture“(触碰手势)就会发生,然后你的应用程序就会把你的 ”触碰“过程解释为一个特有的手势。这个过程分为两个步奏,1.收集 触碰事件的数据。 ...

Detecting and Using LTE Networks

3GPP Long Term Evolution (LTE) is a 4G wireless network technology that supports significantly highe...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Primitive Collision Detecting (4)
举报原因:
原因补充:

(最多只允许输入30个字)