コード例 #1
0
def test_orientations_indexing_assignment(orientations):
    """
    Assign a new value to a quaternion of an `Orientation`
    via the index-operator `[]`.
    """
    orientations[0] = Orientations([0, 0, 0, 1])
    orientations[0] = Orientations.from_view_up([0, 0, 1], [1, 0, 0])
    orientations[0] = [0, 0, 0, 1]
    orientations[:] = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]
    with raises(ValueError):
        orientations[0] = [0, 0, 3]
    with raises(ValueError):
        orientations[0] = orientations
コード例 #2
0
def test_orientations_show(views, ups, positions, orientations):
    """
    Visualize orientations via `Orientations.show()`
    with and without `positions`.
    """
    # default orientation
    Orientations().show()
    # single vectors no position
    view = [1, 0, 0]
    up = [0, 1, 0]
    orientation_single = Orientations.from_view_up(view, up)
    orientation_single.show()
    # with position
    position = Coordinates(0, 1, 0)
    orientation_single.show(position)

    # multiple vectors no position
    orientations.show()
    # with matching number of positions
    orientations.show(positions)

    # select what to show
    orientations.show(show_views=False)
    orientations.show(show_ups=False)
    orientations.show(show_rights=False)
    orientations.show(show_views=False, show_ups=False)
    orientations.show(show_views=False, show_rights=False)
    orientations.show(show_ups=False, show_rights=False)
    orientations.show(positions=positions, show_views=False, show_ups=False)

    # with positions provided as Coordinates
    positions = np.asarray(positions)
    positions = Coordinates(positions[:, 0], positions[:, 1], positions[:, 2])
    orientations.show(positions)
    # with non-matching positions
    positions = Coordinates(0, 1, 0)
    with raises(ValueError):
        orientations.show(positions)
コード例 #3
0
def test_orientations_init():
    """Init `Orientations` without optional parameters."""
    orient = Orientations()
    assert isinstance(orient, Orientations)