Skip to main content
1-Visitor
June 13, 2012
Solved

Crude Squareness Parameter for optimisation

  • June 13, 2012
  • 30 replies
  • 9836 views

Hi, I have a square versus triangle problem that I would appreciate help with. Please see attached.

Thanks for any help.

Jason

Best answer by StuartBruff

Jason Bryant wrote:

Hi Richard, the CC seems like a good method but Im guessing its quite involved. For the maximum seperation, I dont follow how this would tell you if its more squar elike or triangle like.

It may be that, for a simple approximation, you are actually looking for two (binary) measures, which you can then combine with an 'and' conjunction. The extended version of my original worksheet calculates the standard deviation of the angles of each corner (eliminates too shalllow an angle) and the stdev of the side lengths (to avoid too trapezoid a shape). Pick some threshold values to choose 'squareish'.

Stuart

30 replies

23-Emerald V
June 13, 2012

There's probably some nice method out there just for this problem, but I'm too lazy to look.

So I'd be tempted to look at the differences between the angles between successive points. A more triangular pattern should have a pair of more open angles.

Stuart

19-Tanzanite
June 13, 2012

Do you really need the "squareness"? If each of your points really represents cluster of points, and you need to be able to distinguish between them, all you would need is maximum separation.

If squareness is important, calculate the correlation coefficient for all possible combinations of three points. A high CC indicates the three points are close to a straight line, in which case your shape is close to a triangle.

Jbryant611-VisitorAuthor
1-Visitor
June 13, 2012

Hi Richard, the CC seems like a good method but Im guessing its quite involved. For the maximum seperation, I dont follow how this would tell you if its more squar elike or triangle like.

Thanks

Jason

19-Tanzanite
June 13, 2012

Hi Richard, the CC seems like a good method but Im guessing its quite involved.

Not really.

For the maximum seperation, I dont follow how this would tell you if its more squar elike or triangle like.

It wouldn't, but it's not clear to me why you need to determine that. If you are trying to distinguish the four fluorescent species then all you need is maximum separation between the points. Well, not quite, because each point is not really a point. If you were to measure multiple samples each point would actually be cluster of points, and what you need is to minimize the overlap between the clusters. If the clusters are small that just means getting the points far enough apart that there is effectively no overlap. If the clusters are large enough that complete separation is not possible then to get the best separation you would need to consider not only the distance between the clusters, but also the size of the clusters.

But maybe I misunderstand the nature of the problem (quite likely, given the brief description!)

17-Peridot
June 13, 2012

Hello Jason,

without providing some code I suggest that you check for parallelity within the shape. E.g. connect the two highest points by a straight line (the two lowest likewise) and check whether the angle between the two lines is less than a given threshold.

A triangle should have less parallels than a rectangle 😉

Raiko

Jbryant611-VisitorAuthor
1-Visitor
June 13, 2012

Hi guys, thanks for your help, I like all 3 ideas provided

1: STANDARD DEVIATION OF THE ANGLES

2: CORRELATION COEFFICIENT FOR 3 POINTS

3: PARALLEL LINES

After a quick play, it seems the standard deviation is quite sensitive. So (sorry Richard and Raiko) - I will have to give the "correct answer" to Stuart. I will flag as helpful answers to you both, although all 3 of you have given me the correct answer. Thanks again - extremely useful

Jason

12-Amethyst
June 28, 2012

Better later than never?

Here are a few other intuitive (to me) measures that may also be helpful. The points in order RBGP (red, blue, green.purple) form a simple polygon (no crossed lines). Assuming this, or an appropriate reordering:

1. Area of the quadrilateral. There's a 2:1 difference between the trangle and the square.

2. Maximum size of the four interior angles; close to 90deg => square, close to 180deg => traingle.

3. Ratio of the lengths of the two diagonals ( I think not as robust as 1 and 2). Same ~2:1 for triangle and square, assuming range of possible positions limited to approx. variations is as shown.

Lou

Jbryant611-VisitorAuthor
1-Visitor
June 28, 2012

Some great idea Lou - late ideas always welcome!

Thanks

Jason