1 | .. _api-zoo-geometry-polygon: |
---|
2 | |
---|
3 | ZOO.Geometry.Polygon |
---|
4 | ==================== |
---|
5 | |
---|
6 | Polygon is a collection of :ref:`ZOO.Geometry.LinearRing <api-zoo-geometry-linearring>`. |
---|
7 | |
---|
8 | Inherits from |
---|
9 | |
---|
10 | - :ref:`ZOO.Geometry.Collection <api-zoo-geometry-collection>` |
---|
11 | |
---|
12 | Functions |
---|
13 | --------- |
---|
14 | |
---|
15 | .. list-table:: |
---|
16 | :widths: 15 50 |
---|
17 | :header-rows: 1 |
---|
18 | |
---|
19 | * - NAME |
---|
20 | - DESCRIPTION |
---|
21 | * - :ref:`ZOO.Geometry.Polygon <ZOO.Geometry.Polygon>` |
---|
22 | - Constructor for a Polygon geometry. |
---|
23 | * - :ref:`getArea <getArea>` |
---|
24 | - Calculated by subtracting the areas of the internal holes from the area of the outer hole. |
---|
25 | * - :ref:`containsPoint <containsPoint>` |
---|
26 | - Test if a point is inside a polygon. |
---|
27 | * - :ref:`createRegularPolygon <createRegularPolygon>` |
---|
28 | - Create a regular polygon around a radius. |
---|
29 | |
---|
30 | .. _ZOO.Geometry.Polygon: |
---|
31 | |
---|
32 | ZOO.Geometry.Polygon |
---|
33 | Constructor for a Polygon geometry. The first ring (*this.component[0]*) is the outer |
---|
34 | bounds of the polygon and all subsequent rings (*this.component[1-n]*) are internal holes. |
---|
35 | |
---|
36 | *Parameters* |
---|
37 | |
---|
38 | ``components`` {Array(:ref:`ZOO.Geometry.LinearRing <api-zoo-geometry-linearring>`)} |
---|
39 | |
---|
40 | .. _getArea: |
---|
41 | |
---|
42 | getArea |
---|
43 | :: |
---|
44 | |
---|
45 | getArea: function() |
---|
46 | |
---|
47 | Calculated by subtracting the areas of the internal holes from the area of the outer hole. |
---|
48 | |
---|
49 | *Returns* |
---|
50 | |
---|
51 | ``{float}`` The area of the geometry |
---|
52 | |
---|
53 | .. _containsPoint: |
---|
54 | |
---|
55 | containsPoint |
---|
56 | :: |
---|
57 | |
---|
58 | containsPoint: function(point) |
---|
59 | |
---|
60 | Test if a point is inside a polygon. Points on a polygon edge are considered inside. |
---|
61 | |
---|
62 | *Parameters* |
---|
63 | |
---|
64 | ``point`` :ref:`{ZOO.Geometry.Point} <api-zoo-geometry-point>` |
---|
65 | |
---|
66 | *Returns* |
---|
67 | |
---|
68 | ``{Boolean | Number}`` The point is inside the polygon. Returns 1 if the point is on an edge. Returns boolean otherwise. |
---|
69 | |
---|
70 | .. _createRegularPolygon: |
---|
71 | |
---|
72 | createRegularPolygon |
---|
73 | :: |
---|
74 | |
---|
75 | ZOO.Geometry.Polygon.createRegularPolygon = function( origin, |
---|
76 | radius, |
---|
77 | sides, |
---|
78 | rotation ) |
---|
79 | |
---|
80 | Create a regular polygon around a radius. Useful for creating circles and the like. |
---|
81 | |
---|
82 | *Parameters* |
---|
83 | |
---|
84 | | ``origin`` :ref:`{ZOO.Geometry.Point} <api-zoo-geometry-point>` center of polygon. |
---|
85 | | ``radius {Float}`` distance to vertex, in map units. |
---|
86 | | ``sides {Integer}`` Number of sides. 20 approximates a circle. |
---|
87 | | ``rotation {Float}`` original angle of rotation, in degrees. |
---|