本文整理汇总了C++中Interaction::has2Bodies方法的典型用法代码示例。如果您正苦于以下问题:C++ Interaction::has2Bodies方法的具体用法?C++ Interaction::has2Bodies怎么用?C++ Interaction::has2Bodies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interaction
的用法示例。
在下文中一共展示了Interaction::has2Bodies方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: quatAux
void NewtonEulerFrom1DLocalFrameR::computeJachq(double time, Interaction& inter, SP::BlockVector q0)
{
DEBUG_BEGIN("NewtonEulerFrom1DLocalFrameR::computeJachq(double time, Interaction& inter, SP::BlockVector q0 ) \n");
DEBUG_PRINTF("with time = %f\n",time);
DEBUG_PRINTF("with inter = %p\n",&inter);
_jachq->setValue(0, 0, _Nc->getValue(0));
_jachq->setValue(0, 1, _Nc->getValue(1));
_jachq->setValue(0, 2, _Nc->getValue(2));
if (inter.has2Bodies())
{
_jachq->setValue(0, 7, -_Nc->getValue(0));
_jachq->setValue(0, 8, -_Nc->getValue(1));
_jachq->setValue(0, 9, -_Nc->getValue(2));
}
for (unsigned int iDS =0 ; iDS < q0->getNumberOfBlocks() ; iDS++)
{
SP::SiconosVector q = (q0->getAllVect())[iDS];
double sign = 1.0;
DEBUG_PRINTF("NewtonEulerFrom1DLocalFrameR::computeJachq : ds%d->q :", iDS);
DEBUG_EXPR_WE(q->display(););
::boost::math::quaternion<double> quatGP;
if (iDS == 0)
{
::boost::math::quaternion<double> quatAux(0, _Pc1->getValue(0) - q->getValue(0), _Pc1->getValue(1) - q->getValue(1),
_Pc1->getValue(2) - q->getValue(2));
quatGP = quatAux;
}
else
{
sign = -1.0;
//cout<<"NewtonEulerFrom1DLocalFrameR::computeJachq sign is -1 \n";
::boost::math::quaternion<double> quatAux(0, _Pc2->getValue(0) - q->getValue(0), _Pc2->getValue(1) - q->getValue(1),
_Pc2->getValue(2) - q->getValue(2));
quatGP = quatAux;
}
DEBUG_PRINTF("NewtonEulerFrom1DLocalFrameR::computeJachq :GP :%lf, %lf, %lf\n", quatGP.R_component_2(), quatGP.R_component_3(), quatGP.R_component_4());
DEBUG_PRINTF("NewtonEulerFrom1DLocalFrameR::computeJachq :Q :%e,%e, %e, %e\n", q->getValue(3), q->getValue(4), q->getValue(5), q->getValue(6));
::boost::math::quaternion<double> quatQ(q->getValue(3), q->getValue(4), q->getValue(5), q->getValue(6));
::boost::math::quaternion<double> quatcQ(q->getValue(3), -q->getValue(4), -q->getValue(5), -q->getValue(6));
::boost::math::quaternion<double> quat0(1, 0, 0, 0);
::boost::math::quaternion<double> quatBuff;
::boost::math::quaternion<double> _2qiquatGP;
_2qiquatGP = quatGP;
_2qiquatGP *= 2 * (q->getValue(3));
quatBuff = (quatGP * quatQ) + (quatcQ * quatGP) - _2qiquatGP;
DEBUG_PRINTF("NewtonEulerFrom1DLocalFrameR::computeJachq :quattBuuf : %e,%e,%e \n", quatBuff.R_component_2(), quatBuff.R_component_3(), quatBuff.R_component_4());
_jachq->setValue(0, 7 * iDS + 3, sign * (quatBuff.R_component_2()*_Nc->getValue(0) +
quatBuff.R_component_3()*_Nc->getValue(1) + quatBuff.R_component_4()*_Nc->getValue(2)));
//cout<<"WARNING NewtonEulerFrom1DLocalFrameR set jachq \n";
//_jachq->setValue(0,7*iDS+3,0);
for (unsigned int i = 1; i < 4; i++)
{
::boost::math::quaternion<double> quatei(0, (i == 1) ? 1 : 0, (i == 2) ? 1 : 0, (i == 3) ? 1 : 0);
_2qiquatGP = quatGP;
_2qiquatGP *= 2 * (q->getValue(3 + i));
quatBuff = quatei * quatcQ * quatGP - quatGP * quatQ * quatei - _2qiquatGP;
_jachq->setValue(0, 7 * iDS + 3 + i, sign * (quatBuff.R_component_2()*_Nc->getValue(0) +
quatBuff.R_component_3()*_Nc->getValue(1) + quatBuff.R_component_4()*_Nc->getValue(2)));
}
}