def twistSwingToQuaternion(ts):
    'Convert twist/swing1/swing2 rotation in a Vector into a quaternion\n\n    Arguments:\n        ts (Vector): Twist, swing1 and swing2\n\n    '
    t = tan((ts.x * 0.25))
    s1 = tan((ts.y * 0.25))
    s2 = tan((ts.z * 0.25))
    b = (2.0 / ((1.0 + (s1 * s1)) + (s2 * s2)))
    c = (2.0 / (1.0 + (t * t)))
    quat = Quaternion()
    quat.w = ((b - 1.0) * (c - 1.0))
    quat.x = (((- t) * (b - 1.0)) * c)
    quat.y = ((- b) * (((c * t) * s1) + ((c - 1.0) * s2)))
    quat.z = ((- b) * (((c * t) * s2) - ((c - 1.0) * s1)))
    assert quat.isNormalised()
    return quat
Convert twist/swing1/swing2 rotation in a Vector into a quaternion

Arguments:
    ts (Vector): Twist, swing1 and swing2
def twistSwingToQuaternion(ts):
    'Convert twist/swing1/swing2 rotation in a Vector into a quaternion\n\n    Arguments:\n        ts (Vector): Twist, swing1 and swing2\n\n    '
    t = tan((ts.x * 0.25))
    s1 = tan((ts.y * 0.25))
    s2 = tan((ts.z * 0.25))
    b = (2.0 / ((1.0 + (s1 * s1)) + (s2 * s2)))
    c = (2.0 / (1.0 + (t * t)))
    quat = Quaternion()
    quat.w = ((b - 1.0) * (c - 1.0))
    quat.x = (((- t) * (b - 1.0)) * c)
    quat.y = ((- b) * (((c * t) * s1) + ((c - 1.0) * s2)))
    quat.z = ((- b) * (((c * t) * s2) - ((c - 1.0) * s1)))
    assert quat.isNormalised()
    return quat