Exemplo n.º 1
0
def test_vector_generate2():
    pt1 = (0, 0, 0)
    pt2 = (5, 3, 4)
    result = (5, 3, 4)
    result_normalized = (0.707107, 0.424264, 0.565685)
    to_check = utilities.vector_generate(pt1, pt2)
    to_check_normalized = utilities.vector_generate(pt1, pt2, normalize=True)
    assert to_check == result
    assert to_check_normalized == result_normalized
Exemplo n.º 2
0
def _intersect3d(ray1, ray2, tol):
    # Check for colinear case
    d_cross = utilities.vector_cross(ray1.d, ray2.d)
    if utilities.vector_is_zero(d_cross):
        return -1, -1, RayIntersection.COLINEAR

    # Find common values
    p_diff = utilities.vector_generate(ray1.p, ray2.p)
    d_magn = utilities.vector_magnitude(d_cross)
    d_magn_square = d_magn**2

    # Find t1
    pd1_cross = utilities.vector_cross(p_diff, ray2.d)
    pd1_dot = utilities.vector_dot(pd1_cross, d_cross)
    t1 = pd1_dot / d_magn_square

    # Find t2
    pd2_cross = utilities.vector_cross(p_diff, ray1.d)
    pd2_dot = utilities.vector_dot(pd2_cross, d_cross)
    t2 = pd2_dot / d_magn_square

    # Check for skew case
    ray1_pt = ray1.eval(t1)
    ray2_pt = ray2.eval(t2)

    if utilities.point_distance(ray1_pt, ray2_pt) < tol:
        return t1, t2, RayIntersection.INTERSECT
    else:
        return t1, t2, RayIntersection.SKEW
Exemplo n.º 3
0
def test_vector_generate3():
    with pytest.raises(TypeError):
        utilities.vector_generate(5, 9.7)
Exemplo n.º 4
0
def test_vector_generate1():
    with pytest.raises(ValueError):
        pt1 = ()
        pt2 = (1, 2, 3)
        utilities.vector_generate(pt1, pt2)
Exemplo n.º 5
0
    def d(self):
        """ Vector component of the ray (d)

        :getter: Gets the vector component of the ray
        """
        return utilities.vector_generate(self._pt1, self._pt2, normalize=False)