目录
物理引擎系统-ode
一、物理引擎系统-ode——dBodyGetForce
二、物理引擎系统-ode——dBodyGetTorque
三、物理引擎系统-ode——dBodyGetTorque
四、物理引擎系统-ode——dBodyGetRelPointPos
五、物理引擎系统-ode——dBodyGetRelPointVel
六、物理引擎系统-ode——dBodyGetRelPointVel
const dReal * dBodyGetForce (dBodyID b)
{
dAASSERT (b);
return b->facc;
}
const dReal * dBodyGetTorque (dBodyID b)
{
dAASSERT (b);
return b->tacc;
}
void dBodySetForce (dBodyID b, dReal x, dReal y, dReal z)
{
dAASSERT (b);
b->facc[0] = x;
b->facc[1] = y;
b->facc[2] = z;
}
void dBodySetTorque (dBodyID b, dReal x, dReal y, dReal z)
{
dAASSERT (b);
b->tacc[0] = x;
b->tacc[1] = y;
b->tacc[2] = z;
}
void dBodyGetRelPointPos (dBodyID b, dReal px, dReal py, dReal pz,
dVector3 result)
{
dAASSERT (b);
dVector3 prel,p;
prel[0] = px;
prel[1] = py;
prel[2] = pz;
prel[3] = 0;
dMULTIPLY0_331 (p,b->R,prel);
result[0] = p[0] + b->pos[0];
result[1] = p[1] + b->pos[1];
result[2] = p[2] + b->pos[2];
}
void dBodyGetRelPointVel (dBodyID b, dReal px, dReal py, dReal pz,
dVector3 result)
{
dAASSERT (b);
dVector3 prel,p;
prel[0] = px;
prel[1] = py;
prel[2] = pz;
prel[3] = 0;
dMULTIPLY0_331 (p,b->R,prel);
result[0] = b->lvel[0];
result[1] = b->lvel[1];
result[2] = b->lvel[2];
dCROSS (result,+=,b->avel,p);
}
void dBodyGetPointVel (dBodyID b, dReal px, dReal py, dReal pz,
dVector3 result)
{
dAASSERT (b);
dVector3 p;
p[0] = px - b->pos[0];
p[1] = py - b->pos[1];
p[2] = pz - b->pos[2];
p[3] = 0;
result[0] = b->lvel[0];
result[1] = b->lvel[1];
result[2] = b->lvel[2];
dCROSS (result,+=,b->avel,p);
}
void dBodyGetPosRelPoint (dBodyID b, dReal px, dReal py, dReal pz,
dVector3 result)
{
dAASSERT (b);
dVector3 prel;
prel[0] = px - b->pos[0];
prel[1] = py - b->pos[1];
prel[2] = pz - b->pos[2];
prel[3] = 0;
dMULTIPLY1_331 (result,b->R,prel);
}
void dBodyVectorToWorld (dBodyID b, dReal px, dReal py, dReal pz,
dVector3 result)
{
dAASSERT (b);
dVector3 p;
p[0] = px;
p[1] = py;
p[2] = pz;
p[3] = 0;
dMULTIPLY0_331 (result,b->R,p);
}
————————————————
版权声明:本文为CSDN博主「N201871643」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/N201871643/article/details/129820174