def quaternion_to_rotation(i, j, k, p, name):
    """ Convert quaternion data to rotation matrix """
    # http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/index.htm
    # Rotation matrix = [ XX XY XZ YX YY YZ ZX ZY ZZ ] #
    xx = 2.0*i**2
    yy = 2.0*j**2
    zz = 2.0*k**2
    xy = 2.0*i*j
    zp = 2.0*k*p
    xz = 2.0*i*k
    yp = 2.0*j*p
    yz = 2.0*j*k
    xp = 2.0*i*p

    matrix = [0] * 9
    matrix[0] = 1.0-yy-zz
    matrix[1] = xy-zp
    matrix[2] = xz+yp
    matrix[3] = xy+zp
    matrix[4] = 1.0-xx-zz
    matrix[5] = yz-xp
    matrix[6] = xz-yp
    matrix[7] = yz+xp
    matrix[8] = 1.0-xx-yy
    return matrix