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?
Asked
Active
Viewed 1,429 times
2
-
it's a math question, so http://math.stackexchange.com/ might be a better place – xvatar Jul 20 '12 at 23:58
1 Answers
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.)

Gareth McCaughan
- 19,888
- 1
- 41
- 62