Dual-Quaternion-Skinning-Sample-Codes icon indicating copy to clipboard operation
Dual-Quaternion-Skinning-Sample-Codes copied to clipboard

dual_quat_cu.hpp to_transformation

Open jwpleow opened this issue 3 years ago • 0 comments

Hi, was looking at your example for getting the transformation from the dual quaternion:

Transfo to_transformation()
{
    Vec3 t;
    float norm = _quat_0.norm();

    // Rotation matrix from non-dual quaternion part
    Mat3 m = (_quat_0 / norm).to_matrix3();

    // translation vector from dual quaternion part:
    t.x = 2.f*(-_quat_e.w()*_quat_0.i() + _quat_e.i()*_quat_0.w() - _quat_e.j()*_quat_0.k() + _quat_e.k()*_quat_0.j()) / norm;
    t.y = 2.f*(-_quat_e.w()*_quat_0.j() + _quat_e.i()*_quat_0.k() + _quat_e.j()*_quat_0.w() - _quat_e.k()*_quat_0.i()) / norm;
    t.z = 2.f*(-_quat_e.w()*_quat_0.k() - _quat_e.i()*_quat_0.j() + _quat_e.j()*_quat_0.i() + _quat_e.k()*_quat_0.w()) / norm;

    return Transfo(m, t);
}

Shouldn't you have to divide the translation vector by norm square instead of just norm, as you have to normalise the dual quaternion first?

jwpleow avatar Jan 13 '22 04:01 jwpleow