D:/workspaces/sourceforge/mgcd/src/mgcd.h File Reference

API for MGCD library. More...

#include <math.h>

Include dependency graph for mgcd.h:

Classes

struct  AABB2D
 A data structure describing a 2D box. More...
struct  AABB3D
 A data structure describing a 3D box. More...

Typedefs

typedef void(* MGCDHandlePair2D )(Int el1, Int el2, struct AABB2D *els, void *context)
 2DBox pair handler function type definition
typedef void(* MGCDHandlePair3D )(Int el1, Int el2, struct AABB3D *els, void *context)
 3DBox pair handler function type definition

Functions

Int mgcdContactDetect2D (Float *grids, Int gridCount, struct AABB2D *elem, Int elemCount, const char *mstr, MGCDHandlePair2D func, void *context)
 Perform 2D multi grid contact dection.
Int mgcdContactDetect3D (Float *grids, Int gridCount, struct AABB3D *elem, Int elemCount, const char *mstr, MGCDHandlePair3D func, void *context)
 Perform 3D multi grid contact dection.

Detailed Description

API for MGCD library.

Author:
Jialin Li <lijl.scut@gmail.com>, Kejing He <kejinghe@gmail.com>
MGCD stands for Multi Grid Contact Detection. It implements two well known algorithms for 2D and 3D contact detection, NBS and Screening.

Typedef Documentation

void(* MGCDHandlePair2D)(Int el1, Int el2, struct AABB2D *els, void *context)

2DBox pair handler function type definition

User can define a function of this type and provide the function pointer to MGCD 2D detection api to handle the contecting 2D box pairs when a contacting pair is detected

Parameters:
el1 the index of the first box in els
el2 the index of the second box in els
els a pointer to a struct AABB2D array containing all box infomation
context custom data struct used inside the function
See also:
MGCDPairHandler2D

void(* MGCDHandlePair3D)(Int el1, Int el2, struct AABB3D *els, void *context)

3DBox pair handler function type definition

User can define a function of this type and provide the function pointer to MGCD 3D detection api to handle the contecting 3D box pairs when a contacting pair is detected.

Parameters:
el1 The index of the first box of the contacting pair in els
el2 The index of the second box of the contacting pair in els
els A pointer to a struct AABB3D array containing all box infomation
context Custom data struct used inside the function
See also:
MGCDPairHandler3D


Function Documentation

Int mgcdContactDetect2D ( Float *  grids,
Int  gridCount,
struct AABB2D elem,
Int  elemCount,
const char *  mstr,
MGCDHandlePair2D  func,
void *  context 
)

Perform 2D multi grid contact dection.

This function take the basic informations of grid configuration, information of all AABB2Ds the detection perform on and a custom contacting box pair handler as input parameter. It then perform the 2D Multi Grid Contact detection algorithm automatically and return the contacting pair count if no error occur, or error code otherwise.

Parameters:
grids A Float array indecating the cell size of each grid
gridCount An integer indecation the number of grids
elem A AABB2D array, describing the position and size of all objects
elemCount Number of AABB2Ds
mstr A string describing what detection algorithm each grid should use -"NBS" : Use NBS algorithm for each grid. -"SCR" : Use Screening algorithm for each grid. -"AUTO" : Default configuration, in this implementation, NBS will be used. -custom : User can provide a method configuration string to customize what algorithm each grid should use. The length of method cofiguration string should equals to gridCount, and each character should be 'a', 'n' or 's', for each representing a selection of algorithm:
  1. 'a' : Automatic selection, in this implementaion NBS will be used
  2. 's' : Screening
  3. 'n' : NBS eg. "asn": this method configuration string tell the MGCD library automatically select a detection algorithm for the finest grid, use NBS for the coarsest grid, and use Screening for the middle grid.
func A custom contacting box pair handler, can be NULL
context Custom data structure used by handler
Returns:
This function return the contacting 2D box pair count if no error occur, or else return a error code who is a negative. -MGCD_METHOD_ERROR Invalid methods configuration, -MGCD_GRID_ERROR Invalid grid configuration, eg. invalid or duplicate cell size or can not find a grid to fit a box in -MGCD_BOX_ERROR invalid box information, eg. negative size of a box
See also:
AABB2D, MGCDPairHandler2D

Int mgcdContactDetect3D ( Float *  grids,
Int  gridCount,
struct AABB3D elem,
Int  elemCount,
const char *  mstr,
MGCDHandlePair3D  func,
void *  context 
)

Perform 3D multi grid contact dection.

This function take the basic informations of grid configuration, information of all AABB3Ds the detection perform on and a custom contacting box pair handler as input parameter. It perform the 3D Multi Grid Contact detection algorithm automatically and return the contacting pair count if no error occur, or error code other wise.

Parameters:
grids A Float array indecating the cell size of each grid
gridCount An integer indecation the number of grids
elem A AABB3D array, describing the position and size of all objects
elemCount Number of AABB3Ds
mstr A string describing what detection algorithm each grid should use -"NBS" : Use NBS algorithm for each grid. -"SCR" : Use Screening algorithm for each grid. -"AUTO" : Default configuration, in this implementation, NBS will be used. -custom : User can provide a method configuration string to customize what algorithm each grid should use. The length of method cofiguration string should equals to gridCount, and each character should be 'a', 'n' or 's', for each representing a selection of algorithm:
  1. 'a' : Automatic selection, in this implementaion NBS will be used
  2. 's' : Screening
  3. 'n' : NBS eg. "asn": this method configuration string tell the MGCD library automatically select a detection algorithm for the finest grid, use NBS for the coarsest grid, and use Screening for the middle grid.
func A custom contacting box pair handler, can be NULL
context Custom data structure used by handler
Returns:
This function return the contacting 3D box pair count if no error occur, or else return a error code who is a negative. -MGCD_METHOD_ERROR Invalid methods configuration -MGCD_GRID_ERROR Invalid grid configuration, eg. invalid or duplicate cell size or can not find a grid to fit a box in -MGCD_BOX_ERROR invalid box information, eg. negative size of a box
See also:
AABB3D, MGCDPairHandler3D


Generated on Thu Sep 6 00:44:55 2007 for MGCD by  doxygen 1.5.3