找到全等三角形的数量?

时间:2009-10-05 05:23:56

标签: algorithm

Say I have a square from (0,0) to (z,z). 
Given a triangle within this square which has integer coordinates 
for all its vertices.
Find out the number of  triangles within this square which are 
congruent to this triangle and have integer coordinates. 
My algorithm is as follows--


 1) Find out the minimum bounding rectangle(MBR) for the given triangle.
 2) Find out the number of congruent triangles, y within that MBR,
    obtained after reflection, rotation of the given triangle. 
    y can be either 2,4 or 8.
 3) Now find out how many such MBR's can be drawn within the given 
    big square, say x;
    (This is similar to finding number of squares on a chess board)
 4) x*y is the required answer.

我是不是一次计算过一些三角形,或者我错过了这个算法的东西?这是在线评判的问题吗?它给了我错误的答案。 我已经考虑了很多,但我无法弄明白。

3 个答案:

答案 0 :(得分:7)

答案 1 :(得分:2)

在我看来,你可能会以这种方式错过很多全等三角形。对于较小的三角形,不会有很多不同的角度可以放置一个全等三角形,使其所有顶点都是格点。但是,随着三角形的大小增加,有更多机会捕捉到网格,因此最终可能会有超过8个不同的三角形方向。

相反,将示例三角形的一个点指定为原点。尝试将第一个边的半径lattice points of a circle作为第二个顶点的位置。一旦你选择了候选点,计算第三个顶点的位置,如果它也是一个格点,那么计算得到的三角形在不旋转的情况下适合平方的次数。您唯一需要担心的对称性是原始三角形是等腰还是等边,这会导致您将三角形分别计算为2和3。

答案 2 :(得分:1)

您想知道精确只估算的三角形数量吗?

对于“确切”的一个我没有答案,但我确信使用MBR不是一个好主意 - 因为:

  1. 可能存在与MBR
  2. 的边界相交的三角形
  3. 可能存在具有整数坐标的三角形,其缩放不等于整数(即通过旋转。这是一个理论(因为我手中没有示例)但是我们必须在前进之前证明它是错误的)< / LI>

    如果你想知道估算比MBR足够好