def distance(ptsA, ptsB):
"""Function computing the Euclidian distance between two points.
Can be 2D or 3D coordinates.
Args:
ptsA: (list/numpy.array) - 2D/3D coordinates of point A;
ptsB: (list/numpy.array) - 2D/3D coordinates of point B;
Returns:
The Euclidian distance between points A & B.
"""
if len(ptsA) != len(ptsB):
warnings.warn("It seems that the points are not in the same space!")
return None
if len(ptsA) == 2:
return math.sqrt( (ptsA[0]-ptsB[0])**2+(ptsA[1]-ptsB[1])**2 )
if len(ptsA) == 3:
return math.sqrt( (ptsA[0]-ptsB[0])**2+(ptsA[1]-ptsB[1])**2+(ptsA[2]-ptsB[2])**2 )
spatial_image_analysis.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录