From: rusin@washington.math.niu.edu (Dave Rusin) Newsgroups: sci.math Subject: Re: equal or similar triangles Date: 15 Nov 1995 21:31:24 GMT In article <47talf$g13@apopi.u-strasbg.fr>, SHAHBAZKIA Hamid wrote: >I am looking for a formal methode which tells how many non equal or non >similar triangles there are in a n*n grid. [Poster wants to enumerate equivalence classes of triples in a portion of the standard lattice --that is, T \subset (Z^2 \intersect [0,n]^2 )^3 -- under the usual equivalence relations of congruence or similarity.] You have asked this question before. I think the lack of responses indicates that others have noticed what I notice: there is some hard number theory at work here. I wish I could be more helpful, but I think getting accurate formulas will be equivalent to making precise statements about prime distributions and so on, which I don't think are known. The best I can do without spending a lot of time on it is to say that there are O(n^4) equivalence classes of triangles, whether you use similarity, congruence, or just translation-equivalence. Let me just give two illustrations of the difficulties you will encounter. ******************************** Surely a total count of triangles (no equivalence relation used) should be easy, right? A triangle is an unordered triple of distinct points, so there are ( (n+1)^2 choose 3 ) of them. Unfortunately, this is already incorrect -- presumably you intend to disqualify degenerate triangles, so we need to subtract the number of triples of collinear points. How many are there? You simply specify the two endpoints of the line segment -- ( (n+1)^2 choose 2 ) choices -- and then count the number of intermediate points. If the endpoints are (x1,y1) and (x2,y2), the intermediate points are (tx1+(1-t)x2, ty1+(1-t)y2) with t between 0 and 1; the only stipulation is that these coordinates be integral. This is accomplished by taking t=p/q where 0, SHAHBAZKIA Hamid wrote: >I am looking for a formal methode which tells how many non equal or non >similar triangles there are in a n*n grid. [Poster wants to enumerate equivalence classes of triples in a portion of the standard lattice --that is, T \subset (Z^2 \intersect [0,n]^2 )^3 -- under the usual equivalence relations of congruence or similarity.] You have asked this question before. I think the lack of responses indicates that others have noticed what I notice: there is some hard number theory at work here. Certainly there are about ((n+1)^2 choose 3 ) triangles in this portion of the lattice, roughly n^6/6. But there seems to be no reasonable way to count the number of triangles in each equivalence class, nor to find a "canonical" representative of each equivalence class. As far as I can tell, at least one of those would be necessary if you wanted to count the equivalence classes. Let me clarify by trying to count the number of equivalence classes of triangles with a few other notions of equivalence. We can write T1 ~ T2 if there is a motion G with G(T1)=T2, where G comes from (a) G={1} (no equivalences except identity) (b) G=Z^2 (translations) (c) G=(Z^2).D4 (translations and rigid permutations of the whole square) (d) G=O(2,R) (translations and all rotations and reflections) (e) G=GL(2,R) (same, plus dilations) (Here 'and' is taken to mean the additional motions are used as generators, so of course composites of various motions are allowed.) You evidently intended to count the orbits under groups (d) or (e). Surely (a) would be easy, right? A triangle is an unordered triple of distinct points, so there are ( (n+1)^2 choose 3 ) of them. Unfortunately, this is already incorrect -- presumably you intend to disqualify degenerate triangles, so we need to subtract the number of triples of collinear points. How many are there? You simply specify the two endpoints of the line segment -- ( (n+1)^2 choose 2 ) choices -- and then count the number of intermediate points. If the endpoints are (x1,y1) and (x2,y2), the intermediate points are (tx1+(1-t)x2, ty1+(1-t)y2) with t between 0 and 1; the only stipulation is that these coordinates be integral. This is accomplished by taking t=p/q where 00, and a third point (z,w) different from these and from the origin. This appears to give n^2( (n+1)^2-3 ) triangles, although if z or w is zero, we will create a triangle which will be counted twice. ============================================================================== [This next was also evidently neither posted nor mailed. [Timestamp: 15 Nov 1995 08:53 CST] ============================================================================== Now let us consider the equivalneece classes under the group Z^2.C_4 of translations and 90-degree rotations. There are several quantities asociated with a triangle which are preserved under this group. One is what I might call the _collection of inverse slopes_ of the three sides: to a side of slope m we associate the number m if |m|<=1 and 1/m if |m|>1; vertical and horizontal lines are assigned the number 0. Thus a triangle determines a set of three numbers {m1, m2, m3} each in the interval [-1,1]; these numbers do not change upon translation and 90-degree rotation, that is, they are functions of equivalence classes. Note that a non-degenerate triangle cannot have the collection be {0,0,0}. It can have form {0,0,m} -- this happens iff there are two sides parallel to the axes. In this case a unique rotation and translation will move their intersection to the origin, so that the triangle is {(0,0), (a,0), (0,b)} with a>0, b>0. Thus I count n^2 equivalence classes of form {0,0,m}. If a triangle has form {0, m1, m2} then there is a unique rotation which gives it a horizontal side "south" of the triangle. If the angle to the left of this base is acute, there is a unique translation taking the triangle to {(0,0), (a,0), (x,y)} where a, x, y > 0: n^3 triangles. If instead the angle at the left is obtuse, rotate 90 degrees clockwise and follow by the rotation taking the triangle to {(0,0), (0,a), (x,y)} where a>0 and this time we must have x>0 and y>a. Summing over the choices of a gives n^2(n-1)/2 more triangles. If the triangle has form {m1, m2, m3} in which the m_i are not all of the same sign, then there is a unique rotation making two of the m_i positive and the triangle to the "northeast" of the intersection the corresponding lines. Then a unique translation takes the triangle to {(0,0), (x,y), (z,w)} where the negativity of the third slope means (x-z)/(y-w)<0. To count these triangles, fix any (x,y) not on the left or bottom edges to be the top-most point, and count the choices for (z,w) to the southeast of it: there are (n-x)(y-1) such choices. This gives n^2(n-1)^2/4 triangles. Finally, if the triangle has form {m1, m2, m3} in which the m_i _are_ all of the same sign, then there are _two_ rotations making all the m_i positive and the triangle to the "northeast" of the intersection the corresponding lines. In this case we choose the one with the longest side to the north. Then a unique translation takes the triangle to {(0,0), (x,y), (z,w)} in which, if (x,y) is the right-most point, we have x>z, y>w, and x/y > z/w. For any pair (x,y) not on the left or bottom the choices for (z,w) are all those strictly inside the triangle {(0,0), (x,y), (0,x)}. These are of course half the points inside a rectangle, apart from the points on the perimeter and the additional -1+gcd(x,y) points on the diagonal. Thus the total number of such triangles is Sum( (1/2)((x-1)(y-1)+1-gcd(x,y), 0