Beispiel #1
0
def test_point_tuple():
    t = Tuple(4.3, -4.2, 3.1, 1.0)
    assert t.x == 4.3
    assert t.y == -4.2
    assert t.z == 3.1
    assert t.w == 1.0
    assert t.isVector() == False
    assert t.isPoint() == True
Beispiel #2
0
def test_division():
    a = Tuple(1, -2, 3, -4)
    assert a / 2 == Tuple(0.5, -1, 1.5, -2)
Beispiel #3
0
def test_mult_fraction():
    a = Tuple(1, -2, 3, -4)
    assert a * 0.5 == Tuple(0.5, -1, 1.5, -2)
Beispiel #4
0
def test_mult_scalar():
    a = Tuple(1, -2, 3, -4)
    assert a * 3.5 == Tuple(3.5, -7, 10.5, -14)
Beispiel #5
0
def test_neg():
    a = Tuple(1, -2, 3, -4)
    assert -a == Tuple(-1, 2, -3, 4)
Beispiel #6
0
def test_add_tuples():
    a1 = Tuple(3, -2, 5, 1)
    a2 = Tuple(-2, 3, 1, 0)
    assert a1 + a2 == Tuple(1, 1, 6, 1)
Beispiel #7
0
def test_vector():
    v = Vector(4, -4, 3)
    t = Tuple(4, -4, 3, 0)
    assert v.isVector() == True
    assert v == t
Beispiel #8
0
def test_point():
    p = Point(4, -4, 3)
    t = Tuple(4, -4, 3, 1)
    assert p.isPoint() == True
    assert p == t
Beispiel #9
0
def test_tuple_mult():
    m = Matrix([[1, 2, 3, 4], [2, 4, 4, 2], [8, 6, 4, 1], [0, 0, 0, 1]])
    t = Tuple(1, 2, 3, 1)
    assert m * t == Tuple(18, 24, 33, 1)