Exemplo n.º 1
0
def test_translation():
    assert_almost_equal(colvec(1, 2, 1),
                        translation(colvec(0, 0)).dot(colvec(1, 2, 1)))
    assert_almost_equal(colvec(4, 6, 1),
                        translation(colvec(3, 4)).dot(colvec(1, 2, 1)))
    assert_almost_equal(colvec(-2, -2, 1),
                        translation(colvec(-3, -4)).dot(colvec(1, 2, 1)))
Exemplo n.º 2
0
def test_change_transform_origin():
    assert np.array_equal(change_transform_origin(translation([3, 4]), [1, 2]),
                          translation([3, 4]))
    assert_almost_equal(
        colvec(1, 2, 1),
        change_transform_origin(rotation(pi), [1, 2]).dot(colvec(1, 2, 1)))
    assert_almost_equal(
        colvec(0, 0, 1),
        change_transform_origin(rotation(pi), [1, 2]).dot(colvec(2, 4, 1)))
    assert_almost_equal(
        colvec(0, 0, 1),
        change_transform_origin(scaling([0.5, 0.5]),
                                [-2, -4]).dot(colvec(2, 4, 1)))
Exemplo n.º 3
0
def test_transform_aabb():
    assert np.array_equal([1, 2, 3, 4],
                          transform_aabb(np.identity(3), [1, 2, 3, 4]))
    assert_almost_equal([-3, -4, -1, -2],
                        transform_aabb(rotation(pi), [1, 2, 3, 4]))
    assert_almost_equal([2, 4, 4, 6],
                        transform_aabb(translation([1, 2]), [1, 2, 3, 4]))
Exemplo n.º 4
0
def test_translation():
    assert_almost_equal(colvec( 1,  2, 1), translation(colvec( 0,  0)).dot(colvec(1, 2, 1)))
    assert_almost_equal(colvec( 4,  6, 1), translation(colvec( 3,  4)).dot(colvec(1, 2, 1)))
    assert_almost_equal(colvec(-2, -2, 1), translation(colvec(-3, -4)).dot(colvec(1, 2, 1)))
Exemplo n.º 5
0
def test_change_transform_origin():
    assert np.array_equal(change_transform_origin(translation([3, 4]), [1, 2]), translation([3, 4]))
    assert_almost_equal(colvec(1, 2, 1), change_transform_origin(rotation(pi), [1, 2]).dot(colvec(1, 2, 1)))
    assert_almost_equal(colvec(0, 0, 1), change_transform_origin(rotation(pi), [1, 2]).dot(colvec(2, 4, 1)))
    assert_almost_equal(colvec(0, 0, 1), change_transform_origin(scaling([0.5, 0.5]), [-2, -4]).dot(colvec(2, 4, 1)))
Exemplo n.º 6
0
def test_transform_aabb():
    assert np.array_equal([1, 2, 3, 4], transform_aabb(np.identity(3), [1, 2, 3, 4]))
    assert_almost_equal([-3, -4, -1, -2], transform_aabb(rotation(pi),        [1, 2, 3, 4]))
    assert_almost_equal([ 2,  4,  4,  6], transform_aabb(translation([1, 2]), [1, 2, 3, 4]))