I know this question may be based on programming but its core is geometry hence I am posting it here.
Okay what I am trying to do is to write a small program to find out all the possible triangles that have the same incircle radius.
One important condition is that all the units will be in integers. That is to say the ratio between the area and semi-perimeter must be a fully divisible with each other. The area calculated by Heron's formula must be a perfect square root. Also the perimeter must be fully divisible by 2. No rounding off, values with floating points are discarded entirely.
Following the above conditions the two scalene triangles share the same incircle ie. of radius 2.
5 12 13
6 8 10
Do they have any similarities ? What is the maximum area of the triangle that can contain an incircle of radius $r$ ?
What I am doing right now is actually checking all triangles starting with sides $2r$ to $2r*100$. Its basically a brute-force. But is there a better way of determining where I should stop ?
EDIT:
Just found this algo in CodeChef for this problem. Can someone explain to me how it works ? Or whats the logic behind it is ?
for x = 1 to 2*r-1 do:
for y=x to (3*(r*r))/x do:
p = (r*r)*(x+y)
q = x*y-(r*r)
if q <= 0
perform next iteration of inner loop
else
z = p/q
if (z < y or p mod q ! = 0)
perform next iteration of inner loop
else
points for the triangle are
x+y
x+z
z+y
end inner loop
end outer loop
Here $r$ is the radius of the incircle. And mod means the remainder when I divide by the divisor(Its a programming operator). For example 4 mod 2 = 0, 4 mod 3 = 1
Please note I come from a computer science background so I am not that much familiar with the mathematical language, so if the above algo seems difficult to understand in the fashion I have given it then please let me know what I can do to better present it.
