最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - Using Quaternions in Jacobian IK - Stack Overflow

programmeradmin0浏览0评论

I'm working on an Inverse Kinematic system using Jacobian, but I am struggling with creating a Jacobian matirx populated by partial derivatives for/with quaternions. At the moment I am using Euler angles using the current formula:

where V is local x,y or z axis transformed into world space. Here is a snippet of the code for that:

    glm::vec3 forward = transforms[parent].forward();
    glm::vec3 forwardCross = glm::cross(bone, forward);
    ikt.jacobi(index + 0, j + 2) = forwardCross.x;
    ikt.jacobi(index + 1, j + 2) = forwardCross.y;
    ikt.jacobi(index + 2, j + 2) = forwardCross.z;

And after doing Damped Least Squares I add the Theta changes through the eulers.

glm::vec3 oldEul = transforms[child].getEulerRotation();
glm::vec3 eulDelta = { dTheta(jointNum + 0), dTheta(jointNum + 1), dTheta(jointNum + 2) };
transforms[child].setEulerRotation(oldEul + eulDelta);

This method is mostly functional but falls apart approaching singularities/gimble lock.

Does anyone know a method to instead use quaternions to avoid this?

发布评论

评论列表(0)

  1. 暂无评论