Find if point lays on line segment

前端 未结 12 1319
抹茶落季
抹茶落季 2020-11-30 04:01

I have line segment defined by two points A(x1,y1,z1) and B(x2,y2,z2) and point p(x,y,z). How can I check if the point lays on the line segment?

12条回答
  •  悲&欢浪女
    2020-11-30 04:51

    The cross product (B - A) × (p - A) should be much much shorter than B - A. Ideally, the cross product is zero, but that's unlikely on finite-precision floating-point hardware.

提交回复
热议问题