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


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

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


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

示例1: solve

void IKSolver::solve(std::vector<Joint*>* bones, qglviewer::Vec goal, int type)
{
    //cout << type << endl;
    Joint* effector = bones->front();
    qglviewer::Vec posEffector = effector->globalEffectorPosition();

    if ((goal-posEffector).norm()<GOAL_DISTANCE_ERROR) return;

    Joint *root;
    root = effector;
    //    int joint_count=0;
    //    if(!(root==NULL)){
    //        while(root!=NULL){
    //            joint_count++;
    //            root = root->parent();
    //        }
    //    }else{
    //        joint_count=1;
    //    }
    //    root = effector;

    GenericMatrix jacobianMatrix = pseudoJacobian(bones,type);

    qglviewer::Vec e;
    if(type==1){
        if((goal-posEffector).norm()<MAX_DISTANCE_FRAME){
            return;
        }else{
            e = ((goal-posEffector)*MAX_DISTANCE_FRAME);
            //e = ( ((goal-posEffector)*MAX_DISTANCE_FRAME) / ((goal-posEffector).norm()) );
        }

    }else{
        e = (goal-posEffector)*D;
    }

    GenericMatrix position = GenericMatrix(3,1);

    position.set( 0 , 0 , e.x);
    position.set( 1 , 0 , e.y);
    position.set( 2 , 0 , e.z);


    GenericMatrix application = (jacobianMatrix * position);
    //    application.debugPrint("application");


    int i = 0;
    for(int j = 0 ; j < bones->size() ; j++ ) {
        // Smoothing Factor s
        Joint* root = bones->at(j);
        double s=1;
        double angle;
        qglviewer::Vec vector;
        qglviewer::Quaternion qresult = root->orientation();

        if(type == 2){
            vector = qglviewer::Vec(1,0,0);
            angle = ( application.get(i,0)/**(180.0/M_PI)*/ );
            qresult = qglviewer::Quaternion(vector,angle) * qresult;
            i++;

            vector = qglviewer::Vec(0,1,0);
            angle = ( application.get(i,0)/**(180.0/M_PI)*/ );
            qresult = qglviewer::Quaternion(vector,angle) * qresult;
            i++;

            vector = qglviewer::Vec(0,0,1);
            angle = ( application.get(i,0)/**(180.0/M_PI)*/ );
            qresult = qglviewer::Quaternion(vector,angle) * qresult;
            i++;
        }else{
            vector = qglviewer::Vec(1,0,0);
            angle = ( application.get(i,0)/**(180.0/M_PI)*/ );
            qresult = qresult * qglviewer::Quaternion(vector,angle);
            i++;

            vector = qglviewer::Vec(0,1,0);
            angle = ( application.get(i,0)/**(180.0/M_PI)*/ );
            qresult = qresult * qglviewer::Quaternion(vector,angle);
            i++;

            vector = qglviewer::Vec(0,0,1);
            angle = ( application.get(i,0)/**(180.0/M_PI)*/ );
            qresult = qresult * qglviewer::Quaternion(vector,angle);
            i++;
        }

        root->setNewOrientation( qresult );
    }

}
开发者ID:RicardoBusta,项目名称:animacao-ufc-2012,代码行数:92,代码来源:iksolver.cpp


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