Exemple #1
0
def test_vec2_sub():
    a = math.Vector(1, 0)
    b = math.Vector(2, 1)

    assert a - b == math.Vector(-1, -1)
    assert b - a == math.Vector(1, 1)
    assert b - 1 == math.Vector(1, 0)
Exemple #2
0
def test_vec2_floordiv():
    a = math.Vector(5, 6)
    b = math.Vector(2, 3)

    assert a // b == math.Vector(2, 2)
    assert b // a == math.Vector(0, 0)
    assert a // 2 == math.Vector(2, 3)
Exemple #3
0
def test_vec2_truediv():
    a = math.Vector(5, 6)
    b = math.Vector(2, 3)

    assert a / b == math.Vector(2.5, 2)
    assert b / a == math.Vector(.4, .5)
    assert a / 2 == math.Vector(2.5, 3)
Exemple #4
0
def test_vec3_floordiv():
    a = math.Vector(5, 6, 10)
    b = math.Vector(2, 3, 25)

    assert a // b == math.Vector(2, 2, 0)
    assert b // a == math.Vector(0, 0, 2)
    assert a // 2 == math.Vector(2, 3, 5)
Exemple #5
0
def test_vec3_mod():
    a = math.Vector(10, 10, 4)
    b = math.Vector(2, 3, 25)

    assert a % b == math.Vector(0, 1, 4)
    assert b % a == math.Vector(2, 3, 1)
    assert a % 4 == math.Vector(2, 2, 0)
Exemple #6
0
def test_vec3_sub():
    a = math.Vector(1, 2, 3)
    b = math.Vector(0, 1, 1)

    assert a - b == math.Vector(1, 1, 2)
    assert b - a == math.Vector(-1, -1, -2)
    assert a - 3 == math.Vector(-2, -1, 0)
Exemple #7
0
def test_vec3_truediv():
    a = math.Vector(5, 6, 10)
    b = math.Vector(2, 3, 25)

    assert a / b == math.Vector(2.5, 2, .4)
    assert b / a == math.Vector(.4, .5, 2.5)
    assert a / 2 == math.Vector(2.5, 3, 5)
Exemple #8
0
def test_vec3_eq():
    a = math.Vector(1, 2, 3)
    b = math.Vector(1, 2, 3)
    c = math.Vector(3, 2, 1)

    assert a == b
    assert a != c
Exemple #9
0
def test_vec2_eq():
    a = math.Vector(1, 1)
    b = math.Vector(1, 1)
    c = math.Vector(-1, 0)

    assert a == b
    assert a != c
Exemple #10
0
def test_vec2_mod():
    a = math.Vector(10, 10)
    b = math.Vector(2, 3)

    assert a % b == math.Vector(0, 1)
    assert b % a == math.Vector(2, 3)
    assert a % 4 == math.Vector(2, 2)
Exemple #11
0
def test_from_angles():
    quat = math.Quaternion.from_angles(0, 90, 0)
    quat2 = math.Quaternion.from_angles(90, 0, 180)

    assert math.Vector(1, 0, 0) * quat == math.Vector(0, 0, -1)
    assert math.Vector(1, 0, 0) * quat2 == math.Vector(-1, 0, 0)

    assert math.Vector(0, 1, 0) * quat == math.Vector(0, 1, 0)
    assert math.Vector(0, 1, 0) * quat2 == math.Vector(0, 0, 1)
Exemple #12
0
def test_rotate_vector():
    quat = math.Quaternion(x=0, y=0.707106, z=0, w=0.707106)
    quat2 = quat * quat

    assert math.Vector(1, 0, 0) * quat == math.Vector(0, 0, -1)
    assert math.Vector(1, 0, 0) * quat2 == math.Vector(-1, 0, 0)

    assert math.Vector(0, 1, 0) * quat == math.Vector(0, 1, 0)
    assert math.Vector(0, 1, 0) * quat2 == math.Vector(0, 1, 0)
def test_rot_vec():
    a = math.Vector(1, 0, 0)
    b = math.Vector(0, 1, 0)
    c = math.Vector(0, 0, 1)

    rot = math.Rotator(90, 0, 0)
    assert a * rot == a
    assert b * rot == c
    assert c * rot == -b

    rot = math.Rotator(0, 90, 0)
    assert a * rot == -c
    assert b * rot == b
    assert c * rot == a

    rot = math.Rotator(0, 0, 90)
    assert a * rot == b
    assert b * rot == -a
    assert c * rot == c
def test_from_vec():
    pytest.skip()
    a = math.Vector(1, 0, 0)
    b = math.Vector(0, 1, 0)
    c = math.Vector(0, 0, 1)

    rot = math.Rotator.from_vectors(a, b)
    assert a * rot == b
    rot = math.Rotator.from_vectors(a, c)
    assert a * rot == c

    rot = math.Rotator.from_vectors(b, a)
    assert b * rot == a
    rot = math.Rotator.from_vectors(b, c)
    assert b * rot == c

    rot = math.Rotator.from_vectors(c, a)
    assert c * rot == a
    rot = math.Rotator.from_vectors(c, b)
    assert c * rot == b
Exemple #15
0
def test_vec2_floor_ceil():
    a = math.Vector(.5, 5.2)
    b = math.Vector(-.5, -5.2)

    assert floor(a) == math.Vector(0, 5)
    assert ceil(a) == math.Vector(1, 6)

    assert floor(b) == math.Vector(-1, -6)
    assert ceil(b) == math.Vector(0, -5)
Exemple #16
0
def test_vec3_floor_ceil():
    a = math.Vector(.5, 5.2, 0)
    b = math.Vector(-.5, -5.2, 0)

    assert floor(a) == math.Vector(0, 5, 0)
    assert ceil(a) == math.Vector(1, 6, 0)

    assert floor(b) == math.Vector(-1, -6, 0)
    assert ceil(b) == math.Vector(0, -5, 0)
Exemple #17
0
def test_vec2_trunc():
    a = math.Vector(-1.5, 1.5)

    assert trunc(a) == math.Vector(-1, 1)
Exemple #18
0
def test_vec2_round():
    a = math.Vector(1.12345, 5.12345)

    assert round(a) == math.Vector(1, 5)
    assert round(a, 2) == math.Vector(1.12, 5.12)
Exemple #19
0
def test_vec2_abs():
    a = math.Vector(3, 4)

    assert abs(a) == 5
Exemple #20
0
def test_vec2_neg():
    a = math.Vector(2, -2)

    assert -a == math.Vector(-2, 2)
Exemple #21
0
def test_vec2_pow():
    a = math.Vector(1, 2)
    b = math.Vector(1, 9)

    assert a**2 == math.Vector(1, 4)
    assert b**.5 == math.Vector(1, 3)
Exemple #22
0
def test_vec3_trunc():
    a = math.Vector(-1.5, 1.5, 8)

    assert trunc(a) == math.Vector(-1, 1, 8)
Exemple #23
0
def test_vec2():
    a = math.Vector(1, 2)
    assert a.x == 1
    assert a.y == 2
Exemple #24
0
def test_vec3_dot():
    a = math.Vector(3, 4, 5)
    b = math.Vector(1, 3, 2)

    assert a | b == 25
Exemple #25
0
def test_vec2_mul():
    a = math.Vector(3, 5)
    b = math.Vector(2, 3)

    assert a * b == b * a == math.Vector(6, 15)
    assert a * 2 == math.Vector(6, 10)
Exemple #26
0
def test_vec3_neg():
    a = math.Vector(0, 1, -1)

    assert -a == math.Vector(0, -1, 1)
Exemple #27
0
def test_vec3_to2d():
    a = math.Vector(1, 2, 3)

    assert a.to_dim(2) == math.Vector(1, 2)
Exemple #28
0
def test_vec3_abs():
    a = math.Vector(3, 4, 12)

    assert abs(a) == 13
Exemple #29
0
def test_vec2_add():
    a = math.Vector(1, 0)
    b = math.Vector(0, 1)

    assert a + b == b + a == math.Vector(1, 1)
    assert a + 1 == math.Vector(2, 1)
Exemple #30
0
def test_vec3_round():
    a = math.Vector(1.12345, 0.12345, -.62345)

    assert round(a) == math.Vector(1, 0, -1)
    assert round(a, 2) == math.Vector(1.12, .12, -.62)