I have some scattered 3D points (2d solution is sufficient). I want find different straight lines passing through (at least three points makes line) which are laying nearby (say for example 10 units). A single point could be part of different lines.
I have some scattered 3D points (2d solution is sufficient). I want find different
Share
To determine whether 3 points (a,b,c) are in a line, use cross-products (2D or 3D):
If
CrossProd(Vab, Vac)is zero, then the points(a, b, c)are colinear. Actually the cross product is proportional to the area of the triangle(a, b ,c), so you can set a small non-zero tolerance if needed.Re. tolerance.
The distance from
bto the lineVacis given by:You can probably compare this with an absolute tolerance given your problem description. Alternatively you might use:
Then
thetais the angle between the two vectors and can be compared with a fixed tolerance.