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;