예제 #1
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))
  cross_y_x = v3.cross(y, x)
  assert v3.is_similar_vector(v3.norm(cross_y_x), -v3.norm(z))
예제 #2
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))
    cross_y_x = v3.cross(y, x)
    assert v3.is_similar_vector(v3.norm(cross_y_x), -v3.norm(z))
예제 #3
0
def test_vector_algebra():
  a = v3.random_vector()
  assert v3.is_similar_vector(a, +a)
  b = v3.random_vector()
  a_add_b = a+b
  assert v3.is_similar_vector(a_add_b - b, a)
  a_sub_b = a-b
  assert v3.is_similar_vector(a_sub_b + b, a)
  s = v3.random_mag()
  v = v3.random_vector()
  assert v3.is_similar_mag(v3.mag(v3.scale(v, s)), s*v3.mag(v))
  s = v3.random_mag()
  v = v3.random_vector()
  assert v3.is_similar_vector(v3.scale(v, -s), -v3.scale(v, s))
예제 #4
0
def test_vector_algebra():
    a = v3.random_vector()
    assert v3.is_similar_vector(a, +a)
    b = v3.random_vector()
    a_add_b = a + b
    assert v3.is_similar_vector(a_add_b - b, a)
    a_sub_b = a - b
    assert v3.is_similar_vector(a_sub_b + b, a)
    s = v3.random_mag()
    v = v3.random_vector()
    assert v3.is_similar_mag(v3.mag(v3.scale(v, s)), s * v3.mag(v))
    s = v3.random_mag()
    v = v3.random_vector()
    assert v3.is_similar_vector(v3.scale(v, -s), -v3.scale(v, s))
예제 #5
0
 def get_orientate(self, tangent, up, scale):
     """
 Transform stretches the length to the length of tangent and
 the radius to scale.
 """
     return v3.combine(get_xy_face_transform(tangent, up, scale),
                       v3.scaling_matrix(1.0, 1.0,
                                         v3.mag(tangent) / scale))
예제 #6
0
def test_rotation():
  x = v3.random_vector()
  y = v3.transform(v3.random_rotation(), x)
  assert v3.is_similar_mag(v3.mag(x), v3.mag(y))
예제 #7
0
def test_rotation():
    x = v3.random_vector()
    y = v3.transform(v3.random_rotation(), x)
    assert v3.is_similar_mag(v3.mag(x), v3.mag(y))