POLYGON returns properties of an area enclosed by a polygon in two dimensions relative to lines, axes and points:
- properties of an area enclosed by a polygon in two dimensions or;
- properties of a line section within a polygon in two dimensions or;
- Information on whether a point is located inside or outside a polygon in two dimensions.
Syntax
- POLYGON(Pno%, Ndim%[=2], "ColLab$_1", "ColLab$_2", X0, Y0, XN, YN, Mode%)
- POLYGON(0, Npoints%, X_11, Y_12, X_21, Y_22,.., X_n1, Y_n2, X0, Y0, XN, YN, Mode%)
- POLYGON(@ObjFn(..), Ndim%[=2], @ObjColPar_1, @ObjColPar_2, X0, Y0, XN, YN, Mode%)
- POLYGON(Telitab$, Ndim%[=2], "ColLab$_1", "ColLab$_2", X0, Y0, XN, YN, Mode%)
Arguments
- Pno% is the number that refers to the TeLiTab sets in the Data slot. Pno% should be an integer value or a parameter which is assigned an integer value and is the number of theTeLiTab set in the expressions data slot.
- Ndim% is the number of dimensions, which is 2 for the POLYGON function.
- Npoints% is the number of points (X,Y) that are given in direct definition.
- @ObjFn() refers to the Object from which data will be used.
- TeLiTab$ refers to the string parameter that contains the TeLiTab data to be used.
- "ColLab$_1" and @ObjColPar_1 refer to the column containing the first values.
- "ColLab$_2" and @ObjColPar_2 refer to the column containing the second values.
- X_11, Y_12, X_21, Y_22,.., X_n1, Y_n2 are the X and Y coordinates of the points of the polygon that are given in the direct definition.
- X0, Y0 are the X and Y coordinates of point (X0, Y0).
- XN, YN are the X and Y coordinates of point (XN, YN).
- Mode% is the option of the function. There are 25 mode. See Remarks for all options.
POLYGON can be used in the following ways:
1. Properties of an area enclosed by a polygon in two dimensions
For Mode% = 1 to 15 the function POLYGON returns a property of the polygon.
In these cases the points (X0, Y0) and (XN, YN) are not used. These points are no part of the polygon point set and X0, Y0, XN, YN should all be 0, to make sure that they will not influence the result.
- For Mode%=1, the function returns the area of the polygon.
- For Mode%=2, idem with the polygon mirrored in the X-axis.
- For Mode%=3, idem with the polygon mirrored in the Y-axis.
- For Mode%=4, the function returns the COGX (X coordinate of the Centre Of Gravity) of the polygon.
- For Mode%=5, idem with the polygon mirrored in the X-axis.
- For Mode%=6, idem with the polygon mirrored in the Y-axis.
- For Mode%=7, the function returns the COGY (Y coordinate of the Centre Of Gravity) of the polygon.
- For Mode%=8, idem with the polygon mirrored in the X-axis.
- For Mode%=9, idem with the polygon mirrored in the Y-axis.
- For Mode%=10, the function returns the 2nd order moment of the area around the X-axis through the COG.
- For Mode%=11, idem with the polygon mirrored in the X-axis.
- For Mode%=12, idem with the polygon mirrored in the Y-axis.
- For Mode%=13, the function returns the 2nd order moment of the area around the Y-axis through the COG.
- For Mode%=14, idem with the polygon mirrored in the X-axis.
- For Mode%=15, idem with the polygon mirrored in the Y-axis.
2. Properties of a line section within a polygon in two dimensions
For Mode% = 16 to 24 the function POLYGON returns properties of a line section within a polygon in two dimensions.
In these cases the point (X0, Y0) is the starting point and (XN, YN) is the end point of the line. This line is not a part of the polygon and the property is calculated only for the section(s) inside the polygon.
- For Mode%=16, the function returns the length of the line section(s) within the polygon.
- For Mode%=17, idem with the polygon mirrored in the X-axis.
- For Mode%=18, idem with the polygon mirrored in the Y-axis.
- For Mode%=19, the function returns the 1st order moment of the line section(s) within the polygon around (X0, Y0).
- For Mode%=20, idem with the polygon mirrored in the X-axis.
- For Mode%=21, idem with the polygon mirrored in the Y-axis.
- For Mode%=22, the function returns the 2nd order moment of the line section(s) within the polygon around (X0, Y0).
- For Mode%=23, idem with the polygon mirrored in the X-axis.
- For Mode%=24, idem with the polygon mirrored in the Y-axis.
3. Determine whether a point is located inside or outside a polygon in two dimensions
For Mode% = 25 to 27 the function POLYGON returns "1" when point (X0, Y0) is inside the polygon and "0" when it is outside the polygon .
In these cases the point (XN, YN) is not used. XN, YN should both be 0, to make sure that they will not influence the result.
- For Mode%=25, the function returns "1" when point (X0, Y0) is inside the polygon and "0" when it is outside the polygon.
- For Mode%=26, idem with the polygon mirrored in the X-axis.
- For Mode%=27, idem with the polygon mirrored in the Y-axis.
Examples
Example 1: Syntax 1 (telitab in dataslot), Properties of the area
The relation
POLYGON(1, 2, "XC", "YC", 0, 0, 0, 0, Mode)
contains the following Telitab set in the Data slot:
The polygon is a square with corner points (0,0), (1,0), (1,1) and (0,1), this gives for example the following properties:
- For Mode = 1, the area of the polygon is returned: 1.00
- For Mode = 2, the area of the polygon mirrored in the X-axis is returned: 2.00
- For Mode = 4, the COGX (X coordinate of the Centre Of Gravity) of the polygon is returned: 0.50
- For Mode = 10, the 2nd order moment of the area around the X-axis through the COG is returned: 0.08
- For Mode = 15, the 2nd order moment of the area around the Y-axis through the COG is returned for the polygon mirrored in the Y-axis: 0.67
Example 2: Syntax 1 (telitab in dataslot), Properties of a line section
The function:
POLYGON(1, 2, "XC", "YC", X0, Y0, XN, YN, Mode)
with the TeLiTab of the previous example in the dataset gives the possibility to calculate properties of a line section within the polygon. Lets take a look at a line between the points (0,0) and (2,2):
Only the section between the points (0,0) and (1,1) is within the polygon, this gives for example the following properties:
- For Mode = 16, the lenght of the line section is returned: 1.41
- For Mode = 19, the 1st order moment of the line section around (X0, Y0) is returned: 0.24
The function:
POLYGON(1, 2, "XC", "YC", X0, Y0, 0, 0, Mode)
with the TeLiTab of the first example in the dataset gives the possibility to determine whether a point is located inside or outside a polygon. Lets take a look at the point (-0.5 , 0.5):
This results in the following properties:
- For Mode = 25, the result is 0 because the point (X0, Y0) is not inside the polygon.
- For Mode = 27, the result is 1 because the point (X0, Y0) is inside the polygon mirrored in the Y-axis.
Example 4: Syntax 2 (direct definition)
In direct definition, the points of the polygon are stated in the relation itself:
POLYGON(0, Npoints%, X_11, Y_12, X_21, Y_22,.., X_n1, Y_n2, X0, Y0, XN, YN, Mode%)
The minimum number of (X,Y) data points Npoints% in the list is 3 in which case the polygon is a triangle.
The syntax
POLYGON(0, 4, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, Mode)
is the same polygon as in the previous examples and e.g. for Mode = 1, the area of the polygon is returned: 1.00
Quick links: Functions overview | Attribute overview | Constants overview | Dimensions overview