本文整理汇总了C++中Transform::GetDofCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Transform::GetDofCount方法的具体用法?C++ Transform::GetDofCount怎么用?C++ Transform::GetDofCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform::GetDofCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeJ
/*
* Jacobian recursive worker method
*/
void Solver::computeJ(Matd &J, TransformNode *node, Vec4d &pos, Mat4d &trans) {
// Get initial transform data
std::vector<Transform *> transforms = node->mTransforms;
// LEFT MATRIX
Mat4d leftMat;
leftMat.MakeDiag(1.0); // identity
for (int i = 0; i < transforms.size(); i++)
{
Transform *tr = transforms[i];
// Only need to calculate if DOF
if (tr->IsDof())
{
for (int j = 0; j < tr->GetDofCount(); j++)
{
// Get DOF
Dof *dof = tr->GetDof(j);
int dofId = dof->mId;
// Add to our map
leftMap[dofId] = leftMat;
}
}
// Now update leftMat
leftMat = leftMat * tr->GetTransform();
}
// RIGHT MATRIX
Mat4d rightMat;
rightMat.MakeDiag(1.0); // identity
for (int i = transforms.size()-1; i >= 0; i--)
{
Transform *tr = transforms[i];
// Only need to calculate if DOF
if (tr->IsDof())
{
for (int j = tr->GetDofCount()- 1; j >= 0 ; j--)
{
// Get DOF
Dof *dof = tr->GetDof(j);
int dofId = dof->mId;
// Add to our map
rightMap[dofId] = rightMat;
}
}
// Now update leftMat
rightMat = tr->GetTransform() * rightMat;
}
// JACOBIAN
Mat4d pTrans = node->mParentTransform;
// New identity matrix for later use
Mat4d newTransform;
newTransform.MakeDiag(1.0);
for (int i = 0; i < transforms.size(); i++)
{
// Check if DOF, if so compute derivative
Transform *tr = transforms[i];
if (tr->IsDof())
{
for (int j = 0; j < tr->GetDofCount(); j++)
{
Mat4d deriv = tr->GetDeriv(j);
// Get row
Dof * dof = tr->GetDof(j);
int dofId = dof->mId;
Mat4d leftMat = leftMap[dofId];
Mat4d rightMat = rightMap[dofId];
Vec4d value = pTrans * leftMat * deriv * rightMat * trans * pos;
J[dofId] = value;
}
}
newTransform = newTransform * tr->GetTransform();
}
// Calculate J[] values for parent if necessary
TransformNode *parent = node->mParentNode;
// If the parent is non-null and not the current node
if (parent != NULL && parent != node)
{
newTransform = newTransform * trans;
computeJ(J, parent, pos, newTransform);
}
}