{"id":1121,"date":"2019-11-10T03:11:27","date_gmt":"2019-11-10T03:11:27","guid":{"rendered":"https:\/\/muthu.co\/?p=1121"},"modified":"2021-05-24T02:39:48","modified_gmt":"2021-05-24T02:39:48","slug":"find-clusters-of-collinear-points-from-a-given-set-of-data-points","status":"publish","type":"post","link":"http:\/\/write.muthu.co\/find-clusters-of-collinear-points-from-a-given-set-of-data-points\/","title":{"rendered":"Find clusters of collinear points from a given set of data points"},"content":{"rendered":"\n

A set of 3 or more points are said to be collinear if they all lie on a straight line as shown in the image below.<\/p>\n\n\n\n

\"collinear<\/a><\/figure><\/div>\n\n\n\n

One common way of checking if three points are collinear is by finding the area of the triangle formed by the points. The area will be zero if the points are collinear.<\/p>\n\n\n\n

Area(A,B,C) = 0<\/p>\n\n\n\n

Another way is to see if the angle formed by the three points is 180 degrees which is what I used in my number plate segmentation algorithm described in this article<\/a>. Using the angle to find the collinearity also gives us the advantage of using intervals like:<\/p>\n\n\n\n

[175,185] = { angle \u2208 \u211d  | 175 <= angle <=185}<\/p>\n\n\n\n

The interval can help us find almost collinear points as shown in the image below.<\/p>\n\n\n\n

\"characters<\/a><\/figure><\/div>\n\n\n\n

But what about finding more than 3 points which are collinear. In this post, I will describe a good way of identifying all the clusters of collinear points in a cartesian plane using the line equation.<\/p>\n\n\n\n

Algorithm<\/h2>\n\n\n\n