6

I need to calculate the aspect ratio of a triangle. I have the 3 points, and therefore I have the lengths and midpoints. I was attempting to use this tutorial (although its not much of one in my opinion), but it is very vague and doesn't give much information. Could someone elaborate, specifically on the rectangle creation part, or even share a bit of c++ code to solve this problem?

To James's solution:

double s = (a + b + c) / 2.0;
double AR = (a * b * c) / (8.0 * (s - a) * (s - b) * (s - c));

@James:

Cubit reports the following:

Function Name  Average      Std Dev      Minimum     Maximum
-------------  ---------    ---------    ---------   ---------
Aspect Ratio   1.000e+00    7.371e-04    1.000e+00   1.010e+00
--------------------------------------------------------------

Your formula reports the following:

Function Name  Average    Minimum    Maximum
-------------  ---------  --------   -------
Aspect Ratio   1.00006    1.000000   1.00972
--------------------------------------------
Drise
  • 4,310
  • 5
  • 41
  • 66
  • 1
    Define "aspect ratio of triangle". Is that its narrowest possible dimension/diameter to the longest one? – Kaz Apr 23 '12 at 23:36
  • Aha, length of the longest side, to the height (if we lay the triangle on that side, so to speak). – Kaz Apr 23 '12 at 23:37
  • What I would do is project one of the shorter sides (as a vector) onto the longer side. The delta between that projected vector and the original one is a vector whose length is the height of the triangle. – Kaz Apr 23 '12 at 23:39
  • @Kaz This is in relation to a meshed surface, just to clarify. – Drise Apr 23 '12 at 23:45
  • The usefulness of the finding the largest aspect ratio is to determine the quality of the mesh for use in computational electromagnetic solvers. The closer the ratio is to 1, the better and more accurate a mesh is to the geometric volume it represents. – Drise Apr 23 '12 at 23:49

2 Answers2

10

These are the definitions of aspect ratio for triangles I know:

Aspect ratio of a triangle is the ratio of the longest edge to shortest edge (so equilateral triangle has aspect ratio 1).

Aspect ratio of a triangle is the ratio of the circumradius to twice its inradius, so AR = abc/(8(s-a)(s-b)(s-c)) where a,b,c are the lengths of sides of the triangle and s = (a+b+c)/2. So, if a=b=c, then the aspect ratio is 1.

These are much easier to calculate than what you've given.

James Custer
  • 857
  • 6
  • 12
  • Thank you, and if I recall correctly, it was briefly mentioned to me that that example I provided was incorrect, but it was said in passing, and was the only thing that was returned by Google that was useful / made some sense. – Drise Apr 24 '12 at 00:34
  • I'm getting minimum ratios of ~ .02 and maximums of 49. My average is 1.1, so the average is about right (most of the triangles are equilateral). But shouldn't at least the minimum be near 1, and the maximum not so high? If I just take the ratio of the shortest sides and longest sides, I get ~1.0001 and ~4.5 respectively. – Drise Apr 24 '12 at 00:45
  • @Drise Are you sure you implemented the formula correctly? The aspect ratio should be >= 1. The maximums can be fairly high depending on the triangles. – James Custer Apr 24 '12 at 01:33
  • Check my implementation above. – Drise Apr 24 '12 at 01:50
  • I've added the exact reportings from Cubit, a modeling and meshing program, and what your formula produces. – Drise Apr 24 '12 at 02:06
  • @Drise You have a typo in your formula. You have `(s-b)(s-b)` when it should be `(s-b)(s-c)`. – James Custer Apr 24 '12 at 02:07
  • I'm quite embarrassed. Thank you for noticing... :/ – Drise Apr 24 '12 at 02:09
  • I've fixed the comparison statistics I posted for verification. Thank you very much. – Drise Apr 24 '12 at 02:11
  • No problem. Just FYI, typically aspect ratios of > 1.5 are considered "bad." – James Custer Apr 24 '12 at 02:12
0

The ratio of the circumradius to twice the inradius is the correct definition. There is a slightly simpler formula: AR = abc/((b+c-a)(c+a-b)(a+b-c))