Pattern matching circle, square or triangle

1.3k Views Asked by At

I have a set of x, y co-ordinates that are actually taken from hand drawings of a circle, square or a triangle. Using the set of points, I need to mathematically find if the points approximately fit a square, circle or a triangle. What is the ideal way to implement this case?

2

There are 2 best solutions below

0
On

Calculate all the slopes between pairs of points, and order them. If there are two numbers that show up repeatedly in your list, you've got a square; three, a triangle; none; a circle.

This assumes that the given points are many in number and sampled randomly from the drawing.

0
On

You also could use Hough transform. There are large number of this implementation of different programming languages. For more clearness, I post link with web example here.