[Physical] physical AABB collision detection

What is AABB?

AABB, refers to the axis aligned bounding box (Axis-aligned bounding boxes). In 3D space, the AABB is a rectangular parallelepiped, is a rectangle in 2D space. Characterized in that the surface normal are parallel to the axis, i.e. when the rotating object, the object will not change with rotation of the AABB, and therefore characteristic, the AABB fastest determines whether the two objects overlap.

AABB expression

"Real-Time Collision Detection Algorithm Technology", mentions three kinds of AABB expression, to name just the most efficient and requires a minimum of storage space - i.e., the center position of bounding boxes and stored radii bounding box (i.e., surrounded edge of the box to the center of the bounding box length distance):

struct AABB {
    Vector3 pos;
    Vector3 r;
}


AABB collision detection between

Whether AABB intersection can be plotted as follows:

Wherein r is the radius, D is the distance between the two centers of the bounding box.

int AABBIntersection(AABB A, AABB B) {
    for(int i=0, i<3, i++){
        if(abs(A.pos-B.pos)>A.r+B.r)   return 0;
    }
    return 1;
}


Collision detection and ray AABB

In the game, there will often need to detect whether an object intersects the rays from a point of issue.
Collision detection between a specific logic AABB similar, but in which a radiation AABB replaced. Ray structure is as follows:

struct Ray {
    Vector3 pos;
    Vector3 direction;
}

AABB collision detection and ray equation:

int RayAABBIntersection(Ray R, AABB A) {
    

}


Guess you like

Origin www.cnblogs.com/liez/p/11965027.html