本文整理汇总了C++中SimTK::UnitVec3方法的典型用法代码示例。如果您正苦于以下问题:C++ SimTK::UnitVec3方法的具体用法?C++ SimTK::UnitVec3怎么用?C++ SimTK::UnitVec3使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimTK
的用法示例。
在下文中一共展示了SimTK::UnitVec3方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeForce
/**
* Apply the actuator force to BodyA and BodyB.
*/
void TorqueActuator::computeForce(const State& s,
Vector_<SpatialVec>& bodyForces,
Vector& generalizedForces) const
{
if(_model==NULL) return;
const SimbodyEngine& engine = getModel().getSimbodyEngine();
const bool torqueIsGlobal = getTorqueIsGlobal();
const Vec3& axis = getAxis();
double force = 0;
if( isForceOverriden(s) ) {
force = computeOverrideForce(s);
} else {
force = computeActuation(s);
}
setForce(s, force );
if(!_bodyA)
return;
setForce(s, force );
Vec3 torque = force*UnitVec3(axis);
if (!torqueIsGlobal)
engine.transform(s, *_bodyA, torque, engine.getGroundBody(), torque);
applyTorque(s, *_bodyA, torque, bodyForces);
// if bodyB is not specified, use the ground body by default
if(_bodyB)
applyTorque(s, *_bodyB, -torque, bodyForces);
// get the angular velocity of the body in ground
Vec3 omegaA(0), omegaB(0);
engine.getAngularVelocity(s, *_bodyA, omegaA);
engine.getAngularVelocity(s, *_bodyB, omegaB);
// the "speed" is the relative angular velocity of the bodies
// projected onto the torque axis.
setSpeed(s, ~(omegaA-omegaB)*axis);
}