You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include<ccd/ccd.h>#include<ccd/quat.h>// for work with quaternions/** Support function for box */voidsupport(constvoid*obj, constccd_vec3_t*dir, ccd_vec3_t*vec)
{
// assume that obj_t is user-defined structure that holds info about// object (in this case box: x, y, z, pos, quat - dimensions of box,// position and rotation)obj_t*obj= (obj_t*)_obj;
ccd_vec3_tdir;
ccd_quat_tqinv;
// apply rotation on direction vectorccdVec3Copy(&dir, _dir);
ccdQuatInvert2(&qinv, &obj->quat);
ccdQuatRotVec(&dir, &qinv);
// compute support point in specified directionccdVec3Set(v, ccdSign(ccdVec3X(&dir)) *box->x*CCD_REAL(0.5),
ccdSign(ccdVec3Y(&dir)) *box->y*CCD_REAL(0.5),
ccdSign(ccdVec3Z(&dir)) *box->z*CCD_REAL(0.5));
// transform support point according to position and rotation of objectccdQuatRotVec(v, &obj->quat);
ccdVec3Add(v, &obj->pos);
}
intmain(intargc, char*argv[])
{
...
ccd_tccd;
CCD_INIT(&ccd); // initialize ccd_t struct// set up ccd_t structccd.support1=support; // support function for first objectccd.support2=support; // support function for second objectccd.max_iterations=100; // maximal number of iterationsintintersect=ccdGJKIntersect(obj1, obj2, &ccd);
// now intersect holds true if obj1 and obj2 intersect, false otherwise
}
so some issues.
v is never defined. vec is never used (I assume v was supposed to be vec)
cube is never defined. i believe obj was intended.
why is a cube called obj_t? that makes reading harder.
the ... in the main function should be removed and replaced with the code that initializes the cubes.
The text was updated successfully, but these errors were encountered:
so some issues.
The text was updated successfully, but these errors were encountered: