# Polygon's share of its rectangle inconsistent?

Jim Hurley jhurley0305 at sbcglobal.net
Sun Jun 9 10:28:37 EDT 2013

```>
>
> Message: 1
> Date: Sat, 8 Jun 2013 11:06:05 -0600
> From: Dar Scott <dsc at swcp.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Subject: Re: Polygon's share of its rectangle inconsistent?
> Message-ID: <EB5D4974-E672-4AFD-9B5F-C353E4AA5B1B at swcp.com>
> Content-Type: text/plain; charset=windows-1252
>
> (Snip)
>
> I'm not sure what "singly connected" means.  Does this mean a graphic can work like several graphics?
>
> Dar
>

Hi Dar,

The code I offered for obtaining  the area within a closed, singly connected polygon relied on the sum of the areas underneath a connected series of line segments equates to the area within those segments. The area under a single line segment defined by it's end points x1,y1 and x2,y2 is given by  (x2 - x1) * (y1 + y2)/2

The area under the "top" of the polygon (where x2 - x1) is positive) minus the area under the  "bottom" (where x1 - x2 is negative) is equal to the area within.

This presumes one moves clockwise around the polygon. Going counter-clockwise the area calculated is negative. For a symmetric, doubly connected figure, such  as a figure 8, there is a clockwise segment and an equal and opposite counter-clockwise segment, resulting in zero net area.

A figure is singly connected if it is possible to move to every point within, without crossing a line. The figure "0" is singly connected; the figure "8" is doubly connected.

Jim

```