class Polygon

This class defines a polygon as being made up of its sides given by an array of Lines and its dual point. Maybe one could use the class Lines for the sides of the polygon.

We have several methods to show polygons. One simply shows the polygon independently of its shape. But I prefer to be able to draw only selected polygons. The method “showRegular(n)” draws only the polygon if it has a given number n of corners. If n equals 4 it draws only if it is a square. The method “showRhomb” draws the polygon if it is a rhomb and has a chosen angle. Note that we actually have to call the related methods of the class Polygons.

The method “center” calculates the mean coordinate of the corner points. This is only the center of the polygon if it is a regular polygon. We can use it to approximate the position of the points of the dual tiling.

There are two important methods for the dualization method:

“createDualPoint” creates the dual point of the polygon and connects it to the dual lines of the sides of the polygon. For each side its dual line has the dual point of the polygon as one of its endpoints. If a side has not yet a dual line then its dual line is created too. Thus we get the topology of the dual tiling.

“setDualPoints” calculates the exact positions of the dual tiling. It imposes that dual lines are perpendicular to their grid lines and that they all have the same length. It needs that the position of the dual point to the polygon is known. Then it looks if the positions of the other endpoints of the dual lines are known. If not, it sets the positions and calls itself recursively if this other endpoint is dual to a grid polygon.

This entry was posted in programming and tagged , , . Bookmark the permalink.