'2017/09/12'에 해당되는 글 1건

  1. 2017.09.12 point-box distance 를 구하는 깔끔한 방법
posted by cimple 2017. 9. 12. 12:05
def compute_point_to_box_dist(minXYZ, maxXYZ, point):
    dx = max(minXYZ[0] - point[0], 0, point[0] - maxXYZ[0])
    dy = max(minXYZ[1] - point[1], 0, point[1] - maxXYZ[1])
    dz = max(minXYZ[2] - point[2], 0, point[2] - maxXYZ[2])
    return (dx*dx + dy*dy *dz*dz)**0.5


위 함수를 이용하면 axis-align 된 bondong box 와 point 사이의 distance 를 간단하게 구할 수 있다.

참고 : https://stackoverflow.com/questions/5254838/calculating-distance-between-a-point-and-a-rectangular-box-nearest-point