2

According to the Shoelace formula :

If the points are labeled sequentially in the counterclockwise direction, then the area is positive, if they are labeled in the clockwise direction, the area will be negative.

Can anyone please explain why the area is negative, with the change in the order of the points? How does this work? I want to know the logic behind this.

3 Answers3

2

The shoelace formula is a sum of signed triangle areas.

The area of a triangle is (half) a $3 \times 3$ determinant.

Exchanging two rows or columns of a matrix changes the sign of its determinant.

lhf
  • 221,500
2

The area $A(T)$ of a triangle $T$, as of any planar shape, is positive. But the shoelace formula produces the value $-A(T)$ instead if the vertices of the triangle are numbered clockwise. If you just want to know the area you can throw the sign produced by the shoelace formula away, but there are instance in computational geometry where this sign is important.

The shoelace formula is an implementation of Green's area formula $${\rm area}(\Omega)={1\over2}\int_{\partial\Omega}(x\>dy-y\>dx)$$ to the case of a simple polygon. Green's formula is valid as given if the interior of the domain $\Omega$ is lying to the left of the boundary cycle $\partial\Omega$ (a "sum" of piecewise smooth curves). The formula is useful if $\Omega$ is not defined by inequalities, but by a parametric representation of its boundary $\partial\Omega$. If $\Omega$ has holes then the rims of the holes have to be oriented clockwise, whereas the outer boundary has to be oriented counterclockwise. You can realize that the signs here play an important role.

  • There is too much mathematics for laymen. Can you please reduce the mathematics and just clarify why the sign changes when the naming order changes? – helloansuman Jul 23 '17 at 20:05
0

Consider a convex quadrilateral $ABCD$ (the vertices labeled in counterclockwise order, so that $AC$ and $BD$ are its diagonals). If you draw it out, you'll see that $${\rm Area}(ABCD)={\rm Area}(ABC)+{\rm Area}(ACD)$$

Now imagine moving the point $D$ around a bit. This changes the areas of the triangle $ACD$ and the quadrilateral $ABCD$, but as long as the quadrilateral stays convex, the equation above works out.

Now move the point $D$ to inside the triangle $ABC$. The quadrilateral is no longer convex. Now, the triangle $ABC$ contains the triangle $ACD$, and the area of the quadrilateral $ABCD$ is the area of $ABC$ minus that of $ACD$. The above equation fails.

To fix this, we use the notion of signed area — a notion of area that can sometimes be negative. Note that, in the above case where the equation fails, the vertices of $ABC$ and $ABCD$ are labeled in counterclockwise order, but the vertices of $ACD$ are labeled in clockwise order. If we decide that the signed area of a clockwise-labeled triangle should be negative, then the above equation works again.

  • 1
    This answer would be greatly benefited by an illustration or animation, but neither of those options are available to me at the moment. So I encourage you to draw it out instead. – Akiva Weinberger Jul 20 '17 at 15:01
  • Yes, please. It will be great if an illustration is attached. Please be specific on clarifying, why the change in ordering changes the sign. – helloansuman Jul 23 '17 at 20:07