当前位置: 首页>>代码示例>>C++>>正文


C++ Joint::globalTransformationMatrix方法代码示例

本文整理汇总了C++中Joint::globalTransformationMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Joint::globalTransformationMatrix方法的具体用法?C++ Joint::globalTransformationMatrix怎么用?C++ Joint::globalTransformationMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Joint的用法示例。


在下文中一共展示了Joint::globalTransformationMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: jacobian

GenericMatrix IKSolver::jacobian(std::vector<Joint*>* bones, int type)
{
    //    Joint * effector =  bones->back();
    Joint * effector =  bones->front();
    Joint * joint = effector;
    //int joint_count=0;
    //    if(!(root==NULL)){
    /*while(joint!=NULL){
        //            if(root->getParent()==NULL){
        //                root->DrawObject();
        //            }
        joint_count++;
        joint = joint->parent();
    }*/
    //    }else{
    //        joint_count=1;
    //    }
    //joint = effector;

    GenericMatrix jacobian = GenericMatrix(3,3*bones->size());

    qglviewer::Vec posEffector = effector->globalEffectorPosition();

    for(unsigned int i = 0 ; i < bones->size() ; i++) {
        joint = bones->at(i);
        qglviewer::Vec derivatex,derivatey,derivatez;
        qglviewer::Vec posJoint = joint->globalPosition();
        qglviewer::Vec posrelative = posEffector - posJoint;

        GenericMatrix globalTransform = joint->globalTransformationMatrix().transpose();

        if(type!=2){
            derivatex.setValue(globalTransform.get(0),globalTransform.get(1),globalTransform.get(2));
            derivatey.setValue(globalTransform.get(4),globalTransform.get(5),globalTransform.get(6));
            derivatez.setValue(globalTransform.get(8),globalTransform.get(9),globalTransform.get(10));

            // Cross Product
            derivatex = derivatex^posrelative;
            derivatey = derivatey^posrelative;
            derivatez = derivatez^posrelative;

            double vetx[3] = {derivatex.x,derivatey.x,derivatez.x};
            double vety[3] = {derivatex.y,derivatey.y,derivatez.y};
            double vetz[3] = {derivatex.z,derivatey.z,derivatez.z};


            for(int k=0;k<3;k++){
                jacobian.set( 0 , k+(3*i) , vetx[k] );
                jacobian.set( 1 , k+(3*i) , vety[k] );
                jacobian.set( 2 , k+(3*i) , vetz[k] );
            }
        }else{
            posrelative = ( effector->globalEffectorPosition() - joint->globalPosition() );
            jacobian.set(0, (3*i),      0);
            jacobian.set(0, 1+(3*i),    posrelative.z);
            jacobian.set(0, 2+(3*i),    posrelative.y);
            jacobian.set(1, (3*i),      -posrelative.z);
            jacobian.set(1, 1+(3*i),    0);
            jacobian.set(1, 2+(3*i),    posrelative.x);
            jacobian.set(2, (3*i),      posrelative.y);
            jacobian.set(2, 1+(3*i),    -posrelative.x);
            jacobian.set(2, 2+(3*i),    0);
        }
    }

    //    jacobian.debugPrint("jacobian");
    return jacobian;
}
开发者ID:RicardoBusta,项目名称:animacao-ufc-2012,代码行数:68,代码来源:iksolver.cpp


注:本文中的Joint::globalTransformationMatrix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。