ML-Purdue / Document-Reconstruction

Purdue University SIGART document reconstruction project.
1 stars 0 forks source link

Get nearest point in a convex hull from a given point #4

Closed chrismwendt closed 10 years ago

chrismwendt commented 10 years ago

If the point is in the convex hull, the nearest point is itself. Otherwise, the nearest point is the nearest point on any face.

nearest_in_convex_hull(point, hull):
    if point_is_in_convex_hull(point, hull):
        return 0
    else:
        return min(nearest_on_face(point, face) for face in hull.faces, lambda  p: return distance(point, p))
nearest_on_face(point, face):
    return min(face.vertices +
        [nearest_on_edge(point, edge) for edge in face.edges] +
        nearest_on_plane(point, Plane(face.vertices))

nearest_on_edge and nearest_on_plane to be implemented...

chrismwendt commented 10 years ago

Completed in commit 70cb80b0dead6c8e97671cddeca0259bda642cf8.