# Calculate bounds of the inner rectangle of the polygon based on it's constant bounds along with border

Yesterday I asked this question seems not clear. So, I am writing new question with mathematical terms only.

Here is some points about shapes I used:

• Square: Rectangle that all angles are 90° & all sides are equal length. So, consider Square also a Rectangle.
• Triangle: I used an equilateral triangle is a triangle in which all three sides have the same length.
• Polygon: A finite number of straight line segments connected to form a closed.

So, Here after I use the term Polygon to describe triangle & rectangle shapes when it's required to mention consider this shape as polygone. Becuase, I used triangle (regular polygon) to simplfy the work to find out the formula.

Variables used in this problem:

• b = Border width

Bounds of Outer Rectangle (r) that enclosing the polygon(p):

• x = Origin x
• y = Origin y
• w = Width
• h = Height

So, If r = (x,y,w,h) then, Bounds of Inner Rectangle that encloses the inner polygon(p1) (r1) = (x1,y1,w1,h1)

Here, inner polygon = Polygon by subtracting the border width.

What is my final goal:

I should able to calculate inner rectangle boundary of any polygon like below image, I have angles, outer rectangle bounds & border width. The problem is to find out the inner rectangle bounds across to the outer rectangle based on the polygon at that enclosed by inner rectangle.

Problem 1:

Consider a Polygon(p) as a shape of rectangle(r) which has width(w) is 100 & height(h) is 100. The border width of the polygon is 10. The what is the inner boundary of the rectangle that encloses the inner polygon?

Note: I solved it by mind calculation(I didn't took angles in the calculation). But we can't apply this same formula for triangle. So, this is not solution for my problem.

Problem 2:

Consider the polygon (don't consider regulard) with three edges and three vertices & all angles are equal in measure.

If the rectangle(r) boundary is zero & size(w,h) is (100,87) that encloses the polygon(p) along with polygon border width as 10, then

What is the bounds of the inner rectangle(r2) that encloses the inner polygon(p2) ?

Hope I clearly explained the problem. If anything I am missed then please let me know. Thanks in advance.

Let us denote width and height of the inner rectangle as $$w_\mathrm{in}$$ and $$h_\mathrm{in}$$ respectively. Then, we have, $$w_\mathrm{in} = w-2\sqrt{3}b. \qquad\mathrm{and}\qquad h_\mathrm{in} = h\space–\space3b.$$

Using these results, we can easily derive the coordinates of the four corners of the sought rectangle $$P$$, $$Q$$, $$R$$, and $$S$$ as given in the diagram.

Frankly, I am not sure whether these are the results you were looking for. If you have doubts you can always comment on this answer no holds barred.

• Thank you so much!, Yes this is the answer exactly I am looking for solving triangle problem. I will check & let you know If an doubts. Thanks!
– Vin
Dec 17, 2020 at 17:52
• These are the result when applying formula P, Win, Hin and got result Frame:(0.0, 0.0, 100.0, 87.0) Win: 89.04554884989668 Hin: 57.0 Inner Rect Origin: (5.477225575051661, 10.0) and This is the result I got ploted [imgur.com/CRaBpPI]. Here you can see full variable border width: [imgur.com/2LvBVhQ], This is the calculation screenshot: [imgur.com/sr1dZhp], Am I missed anything wrong?
– Vin
Dec 18, 2020 at 4:34
• According to my calculations, all your values, except those of $P$ and $w_{in}$, are correct. The correct values of $w_{in}$ is 65.3589838486 and that of $P$ is $\left(17.320508075689,10\right)$.
– YNK
Dec 18, 2020 at 8:55
• I was first unable to view any of your diagrams, because their link-embedding was faulty. Since this is a comment, you cannot edit it to correct the fault. But, you can delete your comment and post a new comment with right embedding of those three links. However, I manage to view your calculation screenshot. The formula you used to calculate $W_{in}$ is wrong. The correct statement is $\mathrm{\mathbf{\color{red}{let\space win\space =\space rect.width\space -\space 2*sqrt(3)*borderWidth}}}$
– YNK
Dec 18, 2020 at 8:58

Inner triangle is the image of outer triangle under a homothetic transformation centred at the centre of the triangle.

• The centre of the triangle is located on the altitude, at $$1/3$$ of its length starting from the base.

• The ratio $$r$$ of the homothety can be computed as the ratio of the distances from the centre to the midpoint of the bases: $$r={{1\over3}{\sqrt3\over2}100-10\over {1\over3}{\sqrt3\over2}100}= 1-{\sqrt3\over 5}.$$

Inner rectangle is then the image of outer rectangle under the same homothety.

• Thank you very much! I will try your formula & will update
– Vin
Dec 17, 2020 at 17:32