# Math Help - Measuring the boundary of an irregular polygon

1. ## Measuring the boundary of an irregular polygon

Hi

I have been set a programming task where I need to determine the length of the boundary of an irregular polygon between 3 and 6 sides, I am not asking for the programming part (as I know how to program) but just the maths behind how to calculate the length of the boundary of an irregular polygon, I will then be able to do myself, the conversion into programming language.

Thank you very much in advance if you can help me out with the maths involved in calculating the length of the boundary of an irregular polygon between 3 and 6 sides.

2. Originally Posted by rushhour
Hi
to determine the length of the boundary of an irregular polygon between 3 and 6 sides ... just the maths behind how to calculate the length of the boundary of an irregular polygon ... the maths involved in calculating the length of the boundary of an irregular polygon between 3 and 6 sides.
How are the sides of the polygon defined?
Are you given (x,y,z) coordinates for the endpoints or
are they described using polar coordinates,
or some other method?

3. well the question consists of co-ordinates at points p1 and p2. These are:

p1 has co-ordinates (X1, Y1)
p2 has co-ordinates (X2, Y2)

The length of the line joining p1 and p2 is given by the equation of:

{ (X2 - X1)^2 + (Y2 - Y1)^2 } 1/2

From this I wish to determine the length of the boundary of an irregular polygon between 3 and 6 sides. The program should calculate and display the total length of the boundary.

I hope I have given you more information for you to help me.

Thanks if you can help.

4. Originally Posted by rushhour
p1 has co-ordinates (X1, Y1)
p2 has co-ordinates (X2, Y2)

The length of the line joining p1 and p2 is given by the equation of:

{ (X2 - X1)^2 + (Y2 - Y1)^2 } 1/2

points in order:
$P_1 \hdots P_n$

For the Length or perimeter of the polygon,
use your distance formula for each side.
Then sum the individual distances.

For the area for n points:
A12 = (X1*Y2 - X2*Y1)/2
A23 = (X2*Y3 - X3*Y2)/2
...
Akn = (Xk*Yn - Xn*Yk)/2
An1 = (Xn*Y1 - X1*Yn)/2

k being n-1

the sum of the partials:
$A_{12} + A_{23} + A_{34} \hdots A_{kn} + A_{n1}$
will give the area of the polygon.

5. Well based on the equation I gave you a couple of posts ago, can you tell me if this is the correct way to measure the boundary of an irregular 6 sided polygon?

(12,30)
(28,16)
(10,26)
(16,28)
(8,13)
(4,7)

28 - 12 = 16
16 - 30 = -14
10 - 28 = -18
26 - 16 = 10
16 - 10 = 6
28 - 26 = 2
8 - 16 = -8
13 - 28 = -15
4 - 8 = -4
7 - 13 = -6
12 - 4 = 8
30 - 7 = 23

16^2 = 256
-14^2 = 196
-18^2 = 324
10^2 = 100
6^2 = 36
2^2 = 4
-8^2 = 64
-15^2 = 225
-4^2 = 16
-6^2 = 36
8^2 = 64
23^2 = 529

256 +
196 +
324+
100+
36+
4+
64+
225+
16+
36+
529+
= 1850

Sqrt(1850)
= 43.01162634

If you can tell me if this is correct, then I know I am well on my way to solving my programming problem.

6. Originally Posted by rushhour
Well based on the equation I gave you a couple of posts ago, can you tell me if this is the correct way to measure the boundary of an irregular 6 sided polygon?
(12,30)
(28,16)
(10,26)
(16,28)
(8,13)
(4,7)
You have the fundamental parts correct.
It's the assembly that's not quite acceptable.

This is you data rearranged with some labels:

p1(12,30) x=12, y=30, so x1= 12 and y1= 30
p2(28,16)
p3(10,26)
p4(16,28)
p5(8,13)
p6(4,7)

---
x2-x1: 28 - 12 = 16
y2-y1: 16 - 30 = -14
16^2 = 256
-14^2 = 196
Sqrt( 256 + 196 ) = distance from p1 [Point 1] to p2 [Point 2]
---
x3 - x2 : 10 - 28 = -18
y3 - y2 : 26 - 16 = 10
-18^2 = 324
10^2 = 100
Sqrt( 324 + 100) = distance from p2 to p3
---
x4 - x3 : 16 - 10 = 6
y4 - y3 : 28 - 26 = 2
6^2 = 36
2^2 = 4
Sqrt( 36 + 4) = distance between p3 and p4
---
x5 - x4 : 8 - 16 = -8
y5 - y4 : 13 - 28 = -15
-8^2 = 64
-15^2 = 225
Sqrt( 64 + 225) is the distance between which two points?
---
x6 - x5 : 4 - 8 = -4
y6 - y5 : 7 - 13 = -6
-4^2 = 16
-6^2 = 36
Sqrt( 16 + 36) is the length of the next side of the polygon. p5 & p6
---
x1 - x6 : 12 - 4 = 8
y1 - y6 : 30 - 7 = 23
8^2 = 64
23^2 = 529
Sqrt ( 64 + 529) is the length from point 6 back to point 1. p6 & p1
---
The SUM of those individual distances will give the entire length of the perimeter of the polygon.

=================================
Your initial post was almost perfect:
well the question consists of co-ordinates at points p1 and p2. These are:

p1 has co-ordinates (X1, Y1)
p2 has co-ordinates (X2, Y2)

The length of the line joining p1 and p2 is given by the equation of:

{ (X2 - X1)^2 + (Y2 - Y1)^2 } 1/2
I thought that you actually meant:
{ (X2 - X1)^2 + (Y2 - Y1)^2 } ^ 1/2

which is

Sqrt( (x2-x1)^2 + (y2-y1)^2 )

Hope that helps.

7. So I need to add together all the square roots? And this will give me the length of the boundary?

Thanks, if you can help.

8. Originally Posted by rushhour
So I need to add together all the square roots? And this will give me the length of the boundary?

Thanks, if you can help.
YES. That is correct, IF
your square roots are the individual lengths of the sides of the polygon.
Code:

x1 = 12 : y1 = 30
x2 = 28 : y2 = 16
distance_1to2 =  Sqrt( (x2-x1)^2 + (y2-y1)^2 )
The SUM of those individual distances will give the entire length of the boundary.