I am making a line/arc detection algorithm. I found this pesky set of points :
[(215, 69), (217, 70), (220, 67), (223, 65), (226, 64), (229, 62), (232, 60), (236, 57), (239, 56), (242, 54), (245, 52), (248, 50), (251, 48), (254, 47), (257, 45), (260, 43), (264, 40), (267, 39), (270, 37), (273, 35), (276, 33), (279, 31), (282, 29), (285, 28), (288, 26), (291, 24)]
I need to determine if these form a line or a curve. I plotted the set , it looks like this: Set of green points on a line
They clearly represent a line.
However, I tried all sorts of tests to determine if they are line or curve.
I tested whether the angles between each of the points are approximately equal. However, because the line a bit zig zagged, there are some outlier points that are not equal
I tested the cross product of any 3 sequential point of the line to check if they are collinear
for k in range(0,len(pts-3),1): cp1=pts[k] cp2=pts[k+1] cp3=pts[k+2] c1,c2,c3= (cp1.x,cp1.y),(cp2.x,cp2.y),(cp3.x,cp3.y) cros= (p2.x - p1.x)*(p3.y - p1.y) - (p3.x - p1.x)*(p2.y - p1.y) print(abs(cros))
Some of them have really significant cross products. Again because the line is a zig zagged line me thinks.
This zig zagged ness is throwing my algorithm off! So how do I determine if a zigged zagged line is a line or a curve?