예제 #1
0
파일: vector.py 프로젝트: yishizu/compas
    def angles_vectors(left, right):
        """Compute both angles between corresponding pairs of two lists of vectors.

        Parameters
        ----------
        left : list
            A list of vectors.
        right : list
            A list of vectors.

        Returns
        -------
        list
            A list of angle pairs.

        Examples
        --------
        >>> Vector.angles_vectors([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]], [[0.0, 1.0, 0.0], [0.0, 0.0, 2.0]])
        [(1.5707963267948966, 4.71238898038469), (1.5707963267948966, 4.71238898038469)]
        """
        return [angles_vectors(u, v) for u, v in zip(left, right)]
예제 #2
0
    def angles(self, other):
        """Compute both angles between this vector and another vector.

        Parameters
        ----------
        other : :class:`compas.geometry.Vector` or list
            The other vector.

        Returns
        -------
        tuple of float
            The angles between the two vectors, with the smallest angle first.

        Examples
        --------
        >>> u = Vector(1.0, 0.0, 0.0)
        >>> v = Vector(0.0, 1.0, 0.0)
        >>> u.angles(v)[0] == 0.5 * math.pi
        True
        """
        return angles_vectors(self, other)
예제 #3
0
def test_angles_vectors_fails_when_input_is_zero(u, v):
    with pytest.raises(ZeroDivisionError):
        angles_vectors(u, v)
예제 #4
0
def test_angles_vectors(u, v, angles):
    a, b = angles
    assert angles_vectors(u, v) == (pytest.approx(a), pytest.approx(b))
예제 #5
0
def test_angles_vectors(u, v, angles):
    a, b = angles
    assert allclose(angles_vectors(u, v), (a, b))
        # # vertices on the boundaries of the box. Convert the box back to the local
        # # coordinate system.
        # # ==============================================================================

        front = bounding_box_xy(points)
        front = offset_polygon(front, -PADDING)
        front = transform_points(front, X.inverse())

        # # ==============================================================================
        # # Check if boundary normal and local normal have the same direction, if not reverse
        # # list of vertices. Create a 3D box by moving the vertices of the found 2D bounding
        # # box along the z-axis of the boundary coordinate system.
        # # ==============================================================================

        back = []
        angle = angles_vectors(frame.zaxis, frame_0.zaxis, deg=False)

        if angle[0] != 0:
            front.reverse()

        for v in front:
            vertex = add_vectors(v, scale_vector(frame_0.zaxis, THICKNESS))
            back.append(vertex)

# # ==============================================================================
# # Convert the box to a mesh for visualisation.
# # ==============================================================================

        bbox = front + back
        faces = [[0, 3, 2, 1], [4, 5, 6, 7], [3, 0, 4, 7], [2, 3, 7, 6],
                 [1, 2, 6, 5], [0, 1, 5, 4]]