2

I just wonder how can I determine if a given 3D point lies on a line given by 2 points, and ALSO it lies between those 2 points?

1

1 Answer 1

6

Points a,b,c are collinear (all lie on a single line) if b-a,c-a are parallel, which is true iff the cross product (b-a) x (c-a) is zero. (That is, all three of its components are zero. You should probably actually permit them to be nonzero but very very small; exactly what that should mean will depend on your application.)

Given that points a,b,c are collinear, b lies between a and c iff the scalar product (b-a).(c-b) is positive. (Non-negative, if it's OK for b to be coincident with a or c.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.