def test_quaternion_product():
    """Test equivalence with generating combined rotations using rotation matrices."""
    qp_x90_y90 = generate.quaternion_product(cst.quatx90, cst.quaty90)
    qp_y90_z90 = generate.quaternion_product(cst.quaty90, cst.quatz90)
    qp_z90_z90 = generate.quaternion_product(cst.quatz90, cst.quatz90)

    assert np.allclose(convert.quaternion2rot3d(qp_x90_y90),
                       cst.Rx90.dot(cst.Ry90))
    assert np.allclose(convert.quaternion2rot3d(qp_y90_z90),
                       cst.Ry90.dot(cst.Rz90))
    assert np.allclose(convert.quaternion2rot3d(qp_z90_z90),
                       cst.Rz90.dot(cst.Rz90))
Beispiel #2
0
def test_quat2rot2quat():
    """Test quaternion2rot3d and rotmat_to_quaternion consistency."""
    n = 1000
    orientations = generate.get_random_quat(n)
    for i in range(n):
        orientation = orientations[i]
        rot = convert.quaternion2rot3d(orientation)
        quat = convert.rotmat_to_quaternion(rot)
        assert np.allclose(orientation, quat) \
            or np.allclose(orientation, -quat)
Beispiel #3
0
def test_quaternion2rot3d_invariant():
    """Test the invariance of quaternion2rot3d.

    Test the invariance property of the rotation axis on randomly
    selected axes.
    """
    n = 1000
    orientations = generate.get_random_quat(n)
    for i in range(n):
        orientation = orientations[i]
        rot = convert.quaternion2rot3d(orientation)
        rotated = np.dot(rot, orientation[1:])
        assert np.allclose(rotated, orientation[1:])
Beispiel #4
0
def test_quaternion2rot3d_z():
    """Test quaternion2rot3d for 90deg rotations along z."""
    rot90 = convert.quaternion2rot3d(cst.quatz90)
    assert np.allclose(rot90, cst.Rz90)
Beispiel #5
0
def test_quaternion2rot3d_y():
    """Test quaternion2rot3d for 90deg rotations along y."""
    rot90 = convert.quaternion2rot3d(quaty90)
    assert np.allclose(rot90, Ry90)