예제 #1
0
def test_vector_make():
    v = v3.vector()
    assert v3.is_similar_vector(v3.vector(), v3.vector(0, 0, 0))
    v = v3.random_vector()
    w = v3.vector(v)
    assert v3.is_similar_vector(v, w)
    u = v3.vector(*v)
    assert v3.is_similar_vector(v, u)
    w = v
    u = v3.random_vector()
    v3.set_vector(w, *u)
    assert v3.is_similar_vector(w, v)
예제 #2
0
def test_vector_make():
  v = v3.vector()
  assert v3.is_similar_vector(v3.vector(), v3.vector(0, 0, 0))
  v = v3.random_vector()
  w = v3.vector(v)
  assert v3.is_similar_vector(v, w)
  u = v3.vector(*v)
  assert v3.is_similar_vector(v, u)
  w = v
  u = v3.random_vector()
  v3.set_vector(w, *u)
  assert v3.is_similar_vector(w, v)
예제 #3
0
def test_orthogonality():
    x = v3.vector(v3.random_mag(), 0, 0)
    y = v3.vector(0, v3.random_mag(), 0)
    z = v3.vector(0, 0, v3.random_mag())
    ry_x = v3.transform(v3.rotation(y, v3.radians(90)), x)
    assert v3.is_similar_vector(v3.norm(ry_x), -v3.norm(z))
    assert v3.is_similar_mag(v3.mag(ry_x), v3.mag(x))
    ry_z = v3.transform(v3.rotation(y, v3.radians(90)), z)
    assert v3.is_similar_vector(v3.norm(ry_z), v3.norm(x))
    cross_x_y = v3.cross(x, y)
    assert v3.is_similar_vector(v3.norm(cross_x_y), v3.norm(z))
    assert v3.is_similar_mag(0, v3.dot(cross_x_y, x))
    assert v3.is_similar_mag(0, v3.dot(cross_x_y, y))
    cross_y_x = v3.cross(y, x)
    assert v3.is_similar_vector(v3.norm(cross_y_x), -v3.norm(z))
예제 #4
0
def test_orthogonality():
  x = v3.vector(v3.random_mag(), 0, 0)
  y = v3.vector(0, v3.random_mag(), 0)
  z = v3.vector(0, 0, v3.random_mag())
  ry_x = v3.transform(v3.rotation(y, v3.radians(90)), x)
  assert v3.is_similar_vector(v3.norm(ry_x), -v3.norm(z))
  assert v3.is_similar_mag(v3.mag(ry_x), v3.mag(x))
  ry_z = v3.transform(v3.rotation(y, v3.radians(90)), z)
  assert v3.is_similar_vector(v3.norm(ry_z), v3.norm(x))
  cross_x_y = v3.cross(x, y)
  assert v3.is_similar_vector(v3.norm(cross_x_y), v3.norm(z))
  assert v3.is_similar_mag(0, v3.dot(cross_x_y, x))
  assert v3.is_similar_mag(0, v3.dot(cross_x_y, y))
  cross_y_x = v3.cross(y, x)
  assert v3.is_similar_vector(v3.norm(cross_y_x), -v3.norm(z))
예제 #5
0
def test_matrix_combination():
    n = 4
    x = v3.random_vector()
    y1 = v3.vector(x)
    matrix = v3.identity()
    for i in range(4):
        r_matrix = v3.random_matrix()
        y1 = v3.transform(r_matrix, y1)
        matrix = v3.combine(r_matrix, matrix)
    y2 = v3.transform(matrix, x)
    assert v3.is_similar_vector(y1, y2)
예제 #6
0
def test_matrix_combination():
  n = 4
  x = v3.random_vector()
  y1 = v3.vector(x)
  matrix = v3.identity()
  for i in range(4):
    r_matrix = v3.random_matrix()
    y1 = v3.transform(r_matrix, y1)
    matrix = v3.combine(r_matrix, matrix)
  y2 = v3.transform(matrix, x)
  assert v3.is_similar_vector(y1, y2)
예제 #7
0
def test_translation():
    x = v3.vector(v3.random_mag(), 0, 0)
    y = v3.vector(0, v3.random_mag(), 0)
    x_and_y = v3.transform(v3.translation(y), x)
    assert v3.is_similar_vector(x_and_y, x + y)
예제 #8
0
def test_translation():
  x = v3.vector(v3.random_mag(), 0, 0)
  y = v3.vector(0, v3.random_mag(), 0)
  x_and_y = v3.transform(v3.translation(y), x)
  assert v3.is_similar_vector(x_and_y, x+y)