Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Let say I have a polygon. Now I need to scale the polygon at x meters from edges? What will be the scale factor. See this image,

enter image description here

Here I have all co-ordinates of polygon and I need scaling factor of inner polygon which is x meter far from outer one.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Warning: too chatty answer. Sorry about that.


TL;DR If all the corner points are given, then everything you need is in the first chapter of any computational geometry book.


For $1 \le i \le 6,$ let the corner points be $p_i = (x_i, y_i).$ Let the sides of the polygon be $$s_1 = (p_1, p_2), s_2 = (p_2, p_3), \ldots, s_5 = (p_5, p_6), s_6 = (p_6, p_1)$$ Of course, the length of each side $s = (p_i, p_j)$ is given by $\| p_i - p_j \|.$

Since we are given all the $p_i$'s, we can form linear equations for the $6$ lines passing through each side. Each line takes the forms $$ l_i : y = m_i x + b_i $$ where $m_i$ is the slope, and $b_i$ is the intercept. Of course, solving each pair of lines would give one of our points back. For example, solving $l_1$ and $l_6$ would yield $p_1.$

Now, given that the new polygon is $d$ meters away (sorry I used $d$ instead of $x$ to avoid notation conflict), our goal should be

  1. Find the $6$ new line equations $l'_i: y = m'_i x + b'_i$

  2. Solve each pair of $l'_1, l'_2$ etc to find all corner points $p'_i.$

  3. From $p'_i,$ compute the new side lengths, and hence the scaling factor for each side.

Step 2, 3 are obvious. So I'll focus on step 1. To do so, let's look on the new system of line equations $$ l'_i : y = m'_i x + b'_i $$ corresponding to the lines passing through the sides of the scaled away polygon. To find $m'_i$ and $b'_i,$ we first notice that the slope remains the same, but the intercept changes. In other words, $$ m'_i = m_i $$ Now we're left with finding $b'_i,$ and the problem is solved.

To do so, take each pair of line equations and do the following:

I'll only pick, for example, $l_1: y = m x + b_1$ and $l'_1: y = mx + b'_1$ (we already agreed that $m'_1 = m'_2 = m.$) Remember, we know $l_1,$ and we know a point $p_1$ on $l_1.$ We have to figure out $b'_1.$ The perpendicular distance from $l_1$ to $l'_1$ is $d.$ i.e., the distance from $p_1$ to $l'_1$ is $d.$

Out of laziness, I will leave the rest as an exercise. Given $p_1,$ and $l_1,$ figure out the unit vector in the direction of $l_1.$ Then flip it (sign change) to get the unit vector in the normal (perpindicual) direction on $l_1.$ Translate $p_1$ in the direction of the normal $d$ meters away to get $p'_1.$ We got our first point! Solve $l'_1$ using $p'_1$ to find $b'_1.$ Repeat for all pairs of $l_i, l'_i.$ And continue the steps 1, 2, 3 above.

share|improve this answer
    
I think scaling factor should be only 1 or 2 and the value is always between 0 and 1(in my case). –  user960567 Mar 30 '12 at 5:17
    
@user960567 In general there is no single scaling factor. There will be different scaling factors for each side. (bold for emphasis; not shouting :]) –  user2468 Mar 30 '12 at 5:19
    
ok............. –  user960567 Mar 30 '12 at 6:21
    
Can you please explain more about, "figure out the unit vector in the direction of l1. Then flip it (sign change) to get the unit vector in the normal (perpindicual) direction on l1. Translate p1 in the direction of the normal d meters away to get p′1. We got our first point! Solve l′1 using p′1 to find b′1. Repeat for all pairs of li,l′i. And continue the steps 1, 2, 3 above." –  user960567 Mar 30 '12 at 11:43
    
Sure. The unit vector direction of $l_1$ is defined by the vector $v_1 = \dfrac{p2 - p1}{\| p2 - p1 \|} = (x, y)$ (Just to make sure; do you know what a vector is? vector length? unit vector?). –  user2468 Mar 30 '12 at 18:24

If I understand your question, it's not as simple as just finding a single scaling factor.

Let's look at something easier. Suppose I have a $6\times48$ rectangle, with a rectangle at 1/2 meter from it. That bigger rectangle will be $7\times49$, which is not just a scaling of the $6\times48$. Scaling preserves relative dimensions, but the $6\times48$ is a 1-to-8 rectangle, while the $7\times49$ is 1-to-7.

share|improve this answer
    
Some else answered about rectangle at, math.stackexchange.com/questions/125863/… –  user960567 Mar 30 '12 at 4:50
    
Yes, but did you understand that answer? It said you need two scaling factors, one for the height, and a different one for the length. Anyway, you might have saved people some work if you had linked to that earlier question when you posted this newer one. –  Gerry Myerson Mar 30 '12 at 5:08
    
Sorry for that. But if there are two factors then how to calculate in polygon. because there is no width or height. Can you please explain –  user960567 Mar 30 '12 at 5:13
    
Ok............... –  user960567 Mar 30 '12 at 6:05
1  
To do for a polygon what was done for a rectangle in the other question, you would need a different scale factor for each edge. You would have to do for each edge what the other answer does for the length and for the height. –  Gerry Myerson Mar 30 '12 at 6:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.