FORCES
FORtran lib for Comp. Env. Sys.
|
Polygon calculations. More...
Data Types | |
interface | areapoly |
Area of polygon. More... | |
interface | center_of_mass |
Center of mass of polygon. More... | |
interface | inpoly |
Determination point of polygon. More... | |
interface | mod_pole |
Modify polygon so it covers pole correctly. More... | |
interface | mod_shift |
Shifts the (longitude) value 180 degrees. More... | |
interface | orientpoly |
Check orientation of polygon. More... | |
Functions/Subroutines | |
real(sp) function | areapoly_sp (coord) |
Area of polygon. | |
real(sp) function, dimension(2) | center_of_mass_sp (coord) |
Center of mass of polygon. | |
subroutine | inpoly_sp (p, coord, erg) |
Determination point of polygon. | |
integer(i4) function | orientpoly_sp (coord) |
Check orientation of polygon. | |
real(sp) function, dimension(:,:), allocatable | mod_pole_sp (coord, meridian_arg) |
Modify polygon so it covers pole correctly. | |
elemental real(sp) function | mod_shift_sp (x_coord, meridian_arg) |
Shifts the (longitude) value 180 degrees. | |
real(dp) function | areapoly_dp (coord) |
Area of polygon. | |
real(dp) function, dimension(2) | center_of_mass_dp (coord) |
Center of mass of polygon. | |
subroutine | inpoly_dp (p, coord, erg) |
Determination point of polygon. | |
integer(i4) function | orientpoly_dp (coord) |
Check orientation of polygon. | |
real(dp) function, dimension(:,:), allocatable | mod_pole_dp (coord, meridian_arg) |
Modify polygon so it covers pole correctly. | |
elemental real(dp) function | mod_shift_dp (x_coord, meridian_arg) |
Shifts the (longitude) value 180 degrees. | |
Polygon calculations.
This module determines wether a 2D point lies inside, outside, or on the vertice/edge of a 2D polygon and is part of the UFZ CHS Fortran library.
COPYING
and COPYING.LESSER
provided with this software. The complete GNU license text can also be found at http://www.gnu.org/licenses/.
|
private |
Area of polygon.
Function for computing the area of a polygon (2D, convex or not). Function for computing the area of a polygon The polygon can be convex or not.
The method is only applicable for 2D polygons and points.
Example
See also example in test directory.
Literature
[in] | coord | coordinates of the polygon in question |
Definition at line 487 of file mo_poly.f90.
Referenced by mo_poly::center_of_mass::center_of_mass_dp().
|
private |
Area of polygon.
Function for computing the area of a polygon (2D, convex or not). Function for computing the area of a polygon The polygon can be convex or not.
The method is only applicable for 2D polygons and points.
Example
See also example in test directory.
Literature
[in] | coord | coordinates of the polygon in question |
Definition at line 112 of file mo_poly.f90.
Referenced by mo_poly::center_of_mass::center_of_mass_sp().
|
private |
Center of mass of polygon.
Function for computing the center of mass of a polygon (2D, convex or not).
\[ A = \sum_{i}(x_{i}y_{i+1}-x_{i+1}y_{i}) \]
\[ x_s = \frac{1}{6A} \sum_i(x_i+x_{i+1})(x_iy_{i+1}-x_{i+1}y_i) \]
\[ y_s = \frac{1}{6A} \sum_i(y_i+y_{i+1})(x_iy_{i+1}-x_{i+1}y_i) \]
Example
See also example in test directory
Literature
[in] | coord | coordinates of polygon in question |
Definition at line 543 of file mo_poly.f90.
|
private |
Center of mass of polygon.
Function for computing the center of mass of a polygon (2D, convex or not).
\[ A = \sum_{i}(x_{i}y_{i+1}-x_{i+1}y_{i}) \]
\[ x_s = \frac{1}{6A} \sum_i(x_i+x_{i+1})(x_iy_{i+1}-x_{i+1}y_i) \]
\[ y_s = \frac{1}{6A} \sum_i(y_i+y_{i+1})(x_iy_{i+1}-x_{i+1}y_i) \]
Example
See also example in test directory
Literature
[in] | coord | coordinates of polygon in question |
Definition at line 168 of file mo_poly.f90.
|
private |
Determination point of polygon.
Determines whether a 2D point is inside, outside or on vertex of a polygon (2D, convex or not).
The original version of the source code (pnpoly) was implemented by W. Randolph Franklin. It was insufficiently assigning vertex/edge points.
Example
See also example in test directory
Literature
[in] | p | point in question |
[in] | coord | coordinates of the polygon |
[out] | erg | result: inside: erg = 1 outside: erg = -1 on vertex/edge: erg = 0 |
Definition at line 607 of file mo_poly.f90.
|
private |
Determination point of polygon.
Determines whether a 2D point is inside, outside or on vertex of a polygon (2D, convex or not).
The original version of the source code (pnpoly) was implemented by W. Randolph Franklin. It was insufficiently assigning vertex/edge points.
Example
See also example in test directory
Literature
[in] | p | point in question |
[in] | coord | coordinates of the polygon |
[out] | erg | result: inside: erg = 1 outside: erg = -1 on vertex/edge: erg = 0 |
Definition at line 232 of file mo_poly.f90.
|
private |
Modify polygon so it covers pole correctly.
Modifies a polygon (2D, convex or not) to include pole when passed to inpoly this function is intended to modify a given polygon, so it can be represented in a Cartesian grid the use case is a polygon (e.g. 120,80, -120,80, 0,80 covering the north pole) that is not represented on Cartesian lat-lon grid as polygon. The script inserts additional coordinates, so the pole is covered (e.g. 180,80, 180,90, -180,90, -180,80) See test cases for examples.
[in] | coord | coordinates of the polygon in question |
[in] | meridian_arg | meridian that represents discontinuity, defaults to 180.0 |
Definition at line 728 of file mo_poly.f90.
|
private |
Modify polygon so it covers pole correctly.
Modifies a polygon (2D, convex or not) to include pole when passed to inpoly this function is intended to modify a given polygon, so it can be represented in a Cartesian grid the use case is a polygon (e.g. 120,80, -120,80, 0,80 covering the north pole) that is not represented on Cartesian lat-lon grid as polygon. The script inserts additional coordinates, so the pole is covered (e.g. 180,80, 180,90, -180,90, -180,80) See test cases for examples.
[in] | coord | coordinates of the polygon in question |
[in] | meridian_arg | meridian that represents discontinuity, defaults to 180.0 |
Definition at line 353 of file mo_poly.f90.
|
private |
Shifts the (longitude) value 180 degrees.
Modify a coordinate value
[in] | x_coord | coordinates of the polygon in question |
[in] | meridian_arg | meridian that represents discontinuity, defaults to 180.0 |
Definition at line 818 of file mo_poly.f90.
|
private |
Shifts the (longitude) value 180 degrees.
Modify a coordinate value
[in] | x_coord | coordinates of the polygon in question |
[in] | meridian_arg | meridian that represents discontinuity, defaults to 180.0 |
Definition at line 443 of file mo_poly.f90.
|
private |
Check orientation of polygon.
Function for checking the orientation of a polygon (2D, convex or not).
[in] | coord | coordinates of the polygon in question |
result: clockwise: orientpoly = 1 counter-clockwise: orientpoly = -1 flat line or similar irregular shape: orientpoly = 0
Definition at line 691 of file mo_poly.f90.
|
private |
Check orientation of polygon.
Function for checking the orientation of a polygon (2D, convex or not).
[in] | coord | coordinates of the polygon in question |
result: clockwise: orientpoly = 1 counter-clockwise: orientpoly = -1 flat line or similar irregular shape: orientpoly = 0
Definition at line 316 of file mo_poly.f90.