用数学方法算基元碰撞检测 (2)

2D Point In 2D Fan

Point:     P

Fan :      | P – C | <= R,     ( α<=θ<=β, R >= 0)

 

Method(1): W = P – C

           if ( W^2 > R^2 )    return OutSide;

 

   Assume: P1 = (R*cosα + C.x, R*sinα + C.y)

           P2 = (R*cosβ + C.x, R*sinβ + C.y)

 

           U = P1 – C

           V = P2 – C

   Here:   | U | = | V | = R,  (U & V is 2 edges of the Fan)

 

           if ( R> 0 )

            {

               if ( (U x W) * (W x V) < 0 )    return Outside;

            }

 

 return Inside;

 

Method(2): W = P – C

           if ( W^2 > R^2 )    return OutSide;

 

   Assume: β –α <= π

           U = P1 – C

           V = P2 – C

           

           Nu.x = -U.y;

           Nu.y = U.x;

           If ( Nu•W > 0 )     return OutSide;

 

           Nv.x = V.y;

           Nv.y = -V.x;

           if ( Nv•W > 0 )     return OutSide;

 

           return  Inside;

 

           if  (β–α > π)   Invert The Above Result;

 

AABB & AABB

AABB:  A   { V3d inf, sup;}        (inf->infimum, sup-> supremum)

AABB:  B   { V3d inf, sup;}

 

           if ( A.inf.x > B.sup.x || A.inf.y > B.sup.y || A.inf.z > B.sup.z

 ||  A.sup.x < B.inf.x || A.sup.y < B.inf.y || A.sup.z < B.inf.z )

 {

   return  No Intersection;

 }

 

 return Intersectant;

 

 

Point In AABB

Point: P

AABB:  A   { V3d inf, sup;}

 

       if ( P.x >= A.inf.x && P.x <= A.sup.x

         && P.y >= A.inf.y && P.y <= A.sup.y

 && P.z >= A.inf.z && P.z <= A.sup.z )

{

return Inside;

}

 

return Outside;

 

Point In Convex Polyhedron

Point:             P

Convex Polyhedron: Plane 0, Plane 1, … Plane n-1  (n>=3)

                   Plane i: (Pi, Ni)       (Ni points outside of the Convex Polyhedron) (i >= 0 && i < n)

 

                   for ( i = n; i-- > 0; )

                    {

                       Vi = P – Pi;

                       if ( Vi•Ni > 0 )

                        {

                        return Outside;

                        }

                    }

 

                       return Inside;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值