Distance between point and a line (from two points)

后端 未结 8 2371
梦谈多话
梦谈多话 2020-11-28 07:30

I\'m using Python+Numpy (can maybe also use Scipy) and have three 2D points

(P1, P2, P3); 

I am trying to get the distance from P3 perpend

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 07:40

    3D distance should use np.dot def threeD_corres(points_3_d,pre_points_3_d,points_camera):

      for j in  range (0,len(pre_points_3_d)):
          vec1 = list(map(lambda x:x[0]- x[1],zip(pre_points_3_d[j], points_camera)))
          vec2 = list(map(lambda x:x[0]- x[1],zip(pre_points_3_d[j], points_3_d[j])))
          vec3 =  list(map(lambda x:x[0]- x[1],zip(points_3_d[j], points_camera)))
          distance = np.abs(np.dot(vec1_1,vec2_2))/np.linalg.norm(vec3)
    
          print("#########distance:\n",distance)
      return  distance
    

提交回复
热议问题