Exemple #1
0
    def delaunay_is_point_close(self, pt, points, distance):
        if pt in points:
            idx = points.index(pt)
            try:
                faces = delaunay_from_points(points)
            except Exception:
                return None

            if len(faces) > 0:
                triplets = [face for face in faces if idx in face]

                if len(triplets) > 0:
                    for triplet in triplets:
                        try:
                            circle = cg.circle_from_points(
                                points[triplet[0]], points[triplet[1]],
                                points[triplet[2]])
                            if circle:
                                if circle[1] * 2 < distance:
                                    print('Distance Delaunay is {}'.format(
                                        circle[1]))
                                    return True
                        except Exception:
                            return None
        return None
Exemple #2
0
def trimesh_face_circle(mesh, fkey):
    """Get data on circumcentre of triangular face.

    Parameters
    ----------
    fkey : Key
        The face key.

    Returns
    -------
    list
        The centre coordinates, the radius value and the normal vector of the circle.
    None
        If the face is not a triangle.

    """
    vertices = mesh.face_vertices(fkey)
    # return None if not a triangle (possible improvement with best-fit circle)
    if len(vertices) != 3:
        return None
    u, v, w = vertices
    a = mesh.vertex_coordinates(u)
    b = mesh.vertex_coordinates(v)
    c = mesh.vertex_coordinates(w)
    return circle_from_points(a, b, c)
Exemple #3
0
def trimesh_face_circle(mesh, fkey):
    """Get data on circumcentre of triangular face.

    Parameters
    ----------
    fkey : Key
        The face key.

    Returns
    -------
    list, None
        The centre coordinates, the radius value and the normal vector of the circle.
        None if the face is not a triangle

    """

    face_vertices = mesh.face_vertices(fkey)

    # return None if not a triangle (possible improvement with best-fit circle)
    if len(face_vertices) != 3:
        return None

    a, b, c = face_vertices

    return circle_from_points(mesh.vertex_coordinates(a),
                              mesh.vertex_coordinates(b),
                              mesh.vertex_coordinates(c))
Exemple #4
0
def face_circle(mesh, fkey):

    face_vertices = mesh.face_vertices(fkey)
    if len(face_vertices) != 3:
        return None

    a, b, c = face_vertices
    a = mesh.vertex_coordinates(a)
    b = mesh.vertex_coordinates(b)
    c = mesh.vertex_coordinates(c)

    centre, radius, normal = circle_from_points(a, b, c)

    return centre, radius, normal