Пример #1
0
def intersection_segment_segment(ab, cd, tol=1e-6):
    """Compute the intersection of two lines segments.

    Parameters
    ----------
    ab : tuple
        XYZ coordinates of two points defining a line segment.
    cd : tuple
        XYZ coordinates of two points defining another line segment.
    tol : float, optional
        A tolerance for membership verification.
        Default is ``1e-6``.

    Returns
    -------
    None
        If there is no intersection point.
    list
        XYZ coordinates of intersection point if one exists.

    """
    x = intersection_line_line(ab, cd, tol=tol)

    if not x:
        return None

    if is_point_on_segment(x, ab, tol=tol) and is_point_on_segment(
            x, cd, tol=tol):
        return x
Пример #2
0
def intersection_segment_segment(ab, cd, tol=0.0):
    """Compute the intersection of two lines segments.

    Parameters
    ----------
    ab : tuple
        XYZ coordinates of two points defining a line segment.
    cd : tuple
        XYZ coordinates of two points defining another line segment.

    Returns
    -------
    None
        If there is no intersection point.
    list
        XYZ coordinates of intersection point if one exists.
    """
    intx_pt = intersection_line_line(ab, cd)

    if not intx_pt:
        return None

    if not is_point_on_segment(intx_pt, ab, tol):
        return None

    if not is_point_on_segment(intx_pt, cd, tol):
        return None

    return intx_pt
Пример #3
0
def intersection_segment_segment(ab, cd, tol=0.0):
    """"""
    intx_pt = intersection_line_line(ab, cd)

    if not intx_pt:
        return None

    if not is_point_on_segment(intx_pt, ab, tol):
        return None

    if not is_point_on_segment(intx_pt, cd, tol):
        return None

    return intx_pt
Пример #4
0
def intersection_line_segment(line, segment, tol=1e-6):
    """"""
    x = intersection_line_line(line, segment, tol=tol)

    if not x:
        return None

    if is_point_on_segment(x, segment, tol=tol):
        return x
Пример #5
0
def check_colisions(b_struct, pts, radius, bar_nb=None, bar_checking=None):
    """[summary]

    Parameters
    ----------
    b_struct : [type]
        [description]
    pts : [type]
        [description]
    radius : [type]
        [description]
    bar_nb : [type], optional
        [description], by default None
    bar_checking : [type], optional
        [description], by default None

    Returns
    -------
    bool
        True if no collision found, False otherwise
    """

    tol = 50  # | TOL
    # print "bar_checking", bar_checking
    for b in b_struct.vertex:
        if not bar_nb:
            bar_nb = 100000000000000
        if bar_checking != None and b < 3: continue
        if b < bar_nb and b != bar_checking:
            pts_b = b_struct.vertex[b]["axis_endpoints"]
            dpp = dropped_perpendicular_points(pts[0], pts[1], pts_b[0],
                                               pts_b[1])
            try:
                dist = distance_point_point(dpp[0], dpp[1])
            except:
                return False
            # why 50?
            if 2*radius - dist > TOL and \
               is_point_on_segment(dpp[0], pts, tol=tol) and \
               is_point_on_segment(dpp[1], pts_b, tol=tol):
                print("COLLISION", len(b_struct.vertex))
                return False
    return True
Пример #6
0
    def on_segment(self, segment):
        """Determine if the point lies on the given segment.

        Parameters
        ----------
        segment : segment
            The segment.

        Returns
        -------
        bool
            True, if the point lies on the segment.
            False, otherwise.

        """
        return is_point_on_segment(self, segment)