空间两点求距离(内含一组仿真数据)

import numpy as np
import math


def calDistanceFrom2Points(P1, P2):
    P = np.array(P1 - P2)
    X = np.array(P[0])
    Y = np.array(P[1])
    Z = np.array(P[2])
    Distance = math.hypot(X, Y, Z)

    return Distance


if __name__ == '__main__':
    P1 = np.array([13.66, 121.55, 0])
    P2 = np.array([101.84, 121.55, 136.68])
    print(calDistanceFrom2Points(P1, P2))

猜你喜欢

转载自blog.csdn.net/m0_61509658/article/details/122490530
今日推荐