Ejemplo n.º 1
0
 def h_fn(built_nodes, node_id, built_triangles):
     # return (bias, chosen triangle node ids)
     # lower bias will be dequed first
     # iterate through all existing triangles and return the minimal cost one
     dist_to_tri = []
     for tri in list(built_triangles):
         tri_node_pts = [points[tri_id] for tri_id in list(tri)]
         tet_pts = tri_node_pts + [points[node_id]]
         score = 0.0
         if heuristic == 'point2triangle_distance':
             score = distance_point_triangle(points[node_id], tri_node_pts)
         elif heuristic == 'tet_surface_area':
             score = tet_surface_area(tet_pts)
         elif heuristic == 'tet_volume':
             vol = tet_volume(tet_pts)
             score = vol if vol else penalty_cost
         else:
             raise NotImplementedError(
                 'point2triangle search heuristic ({}) not implemented, the only available ones are: {}'
                 .format(heuristic, PT2TRI_SEARCH_HEURISTIC))
         planar_cost = penalty_cost if is_coplanar(
             tri_node_pts + [points[node_id]]) else 1.0
         score *= planar_cost
         dist_to_tri.append(score)
     sorted_built_triangles = sorted(zip(dist_to_tri, built_triangles),
                                     key=lambda pair: pair[0])
     return sorted_built_triangles[0]
Ejemplo n.º 2
0
def tet_from_points(tet_end_points):
    assert len(tet_end_points) == 4, 'input points must be four!'
    ids = frozenset([0,1,2,3])
    faces = []
    if is_coplanar(tet_end_points):
        return None, None
    for face in combinations(ids, 3):
        left_id, = ids - set(face)
        if is_point_infront_plane(tet_end_points[left_id], Plane.from_three_points(*[tet_end_points[i] for i in face])):
            face = [face[0], face[2], face[1]]
        faces.append(list(face) + [left_id])
    return tet_end_points, faces
Ejemplo n.º 3
0
    def is_planar(self):
        """Determine if the polygon is planar.

        Returns
        -------
        bool
            True if all points of the polygon lie in one plane.
            False otherwise.

        Examples
        --------
        >>> polygon = Polygon([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.1]])
        >>> polygon.is_planar()
        False
        """
        return is_coplanar(self.points)
Ejemplo n.º 4
0
 def is_coplanar(self):
     return is_coplanar(self.points)