# Pattern matching circle, square or triangle

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?

-
Are you looking for a computational solution? This generally belongs to the field of machine learning/pattern recognition in computer science, and is often performed as OCR (Optical Character Recognition). The most common approach is to train your algorithm on many samples of each of the handwritten characters, find a common mathematical pattern and use that for prediction. – Bitwise Oct 7 '12 at 3:46

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.

-

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.

-