This module contains the definition of a polygon and some related subroutines
More...
|
pure subroutine | mod_cg2_polygon::cg2_initialize_polygon (polygon, n) |
| Initialize the polygon structure.
|
|
elemental subroutine | mod_cg2_polygon::cg2_finalize_polygon (polygon) |
| Finalize the polygon structure.
|
|
double precision elemental function | mod_cg2_polygon::cg2_polygon_volume (polygon) |
| Compute the area of a polygon.
|
|
pure subroutine | mod_cg2_polygon::cg2_polygon_centroid (polygon, centroid, volume) |
| Compute the centroid of a polygon.
|
|
integer pure function | mod_cg2_polygon::cg2_polygon_winding_number (polygon, point) |
| Compute the winding number of a point in a polygon.
|
|
integer pure function | mod_cg2_polygon::cg2_polygon_winding_number_with_boundary (polygon, point) |
| Compute the winding number of a point in a polygon including its boundary.
|
|
pure subroutine | mod_cg2_polygon::cg2_split_quad_in_triangles (quad, triangle1, triangle2) |
| Split a quadrilateral in two triangles.
|
|
pure subroutine | mod_cg2_polygon::cg2_copy_polygon (original, copy) |
| Make a copy of a polygon.
|
|
elemental subroutine | mod_cg2_polygon::cg2_move_alloc_polygon (polygon1, polygon2) |
| Move the allocation of a given polygon to another polygon.
|
|
subroutine | mod_cg2_polygon::cg2_polygon_write_vtk_file (polygon, filename) |
| Print a polygon into a VTK file for debug purpose.
|
|
- Attention
- Modify these functions at your own risk. Many algorithms depend on the specific behaviour of these functions. They are designed to not generate false negative results. Note that false positive results may occur due to the finite representation of real numbers. Take that into consideration when writing new algorithms.
◆ cg2_copy_polygon()
pure subroutine mod_cg2_polygon::cg2_copy_polygon |
( |
type(t_polygon), intent(in) | original, |
|
|
type(t_polygon), intent(out) | copy ) |
- Parameters
-
[in] | original | Original polygon |
[out] | copy | Copy of the original polygon |
◆ cg2_finalize_polygon()
elemental subroutine mod_cg2_polygon::cg2_finalize_polygon |
( |
type(t_polygon), intent(inout) | polygon | ) |
|
- Parameters
-
[in,out] | polygon | The polygon to finalize |
◆ cg2_initialize_polygon()
pure subroutine mod_cg2_polygon::cg2_initialize_polygon |
( |
type(t_polygon), intent(inout) | polygon, |
|
|
integer, intent(in) | n ) |
- Parameters
-
[in,out] | polygon | The polygon to initialize |
[in] | n | The number of vertices of the polygon |
◆ cg2_move_alloc_polygon()
elemental subroutine mod_cg2_polygon::cg2_move_alloc_polygon |
( |
type(t_polygon), intent(inout) | polygon1, |
|
|
type(t_polygon), intent(inout) | polygon2 ) |
Move the allocation of the vertices array of polygon1
into the vertices array of polygon2
. After calling this routine the vertices array of polygon1
is unallocated.
- Parameters
-
[in,out] | polygon1 | Polygon to be transfered in polygon2 |
[in,out] | polygon2 | Polygon receiving data from polygon1 |
◆ cg2_polygon_centroid()
pure subroutine mod_cg2_polygon::cg2_polygon_centroid |
( |
type(t_polygon), intent(in) | polygon, |
|
|
double precision, dimension(2), intent(out) | centroid, |
|
|
double precision, intent(out), optional | volume ) |
May also output the volume of a polygon
The centroid \(x_c(\omega)\) of a polygon \(\omega\) is given by
\[
x_c(\omega) = x_0 + \dfrac{1}{6|\omega|}\sum_{i=1}^{n}[(x_i - x_0)\times(x_{i+1}-x_0)]((x_i - x_0) + (x_{i+1} - x_0))
\]
Where \( x_0 \) is any point of the real plane
- Parameters
-
[in] | polygon | Any polygon |
[out] | centroid | Centroid of the polygon |
[out] | volume | Volume of the polygon |
◆ cg2_polygon_volume()
double precision elemental function mod_cg2_polygon::cg2_polygon_volume |
( |
type(t_polygon), intent(in) | polygon | ) |
|
The volume of a polygon \(\omega = \{x_1,\cdots,x_n\}\) is given by
\[
|\omega| = \sum_{i=1}^{n} ((x_i - x_0)\times(x_{i+1}-x_0))
\]
Where \( x_0 \) is any point of the real plane
- Parameters
-
◆ cg2_polygon_winding_number()
integer pure function mod_cg2_polygon::cg2_polygon_winding_number |
( |
type(t_polygon), intent(in) | polygon, |
|
|
double precision, dimension(2), intent(in) | point ) |
A point is outside a polygon if the winding number is equal to 0.
- Parameters
-
[in] | polygon | Any polygon |
[in] | point | Any point of the plane |
◆ cg2_polygon_winding_number_with_boundary()
integer pure function mod_cg2_polygon::cg2_polygon_winding_number_with_boundary |
( |
type(t_polygon), intent(in) | polygon, |
|
|
double precision, dimension(2), intent(in) | point ) |
A point is outside a polygon if the winding number is equal to 0.
- Parameters
-
[in] | polygon | Any polygon |
[in] | point | Any point of the plane |
◆ cg2_polygon_write_vtk_file()
subroutine mod_cg2_polygon::cg2_polygon_write_vtk_file |
( |
type(t_polygon), intent(in) | polygon, |
|
|
character(len=*), intent(in) | filename ) |
- Parameters
-
[in] | polygon | Any polygon |
[in] | filename | File name of the VTK file |
◆ cg2_split_quad_in_triangles()
pure subroutine mod_cg2_polygon::cg2_split_quad_in_triangles |
( |
type(t_polygon), intent(in) | quad, |
|
|
type(t_polygon), intent(out) | triangle1, |
|
|
type(t_polygon), intent(out) | triangle2 ) |
Check the concavity. Two cases:
!! |
!! Case 1: | Case 2:
!! |
!! 1 4 | 4 3
!! +----------+ | +----------+
!! `. / | `. /
!! `. / | `. /
!! `. \3 | `. \2
!! `. \ | `. \
!! `.\ | `.\
!! `\ | `\
!! 2 | 1
!! |
!! Generate: | Generate:
!! - {1, 3, 4} | - {4, 2, 3}
!! - {1, 2, 3} | - {4, 1, 2}
!!
- Parameters
-
[in] | quad | Quadrilateral |
[out] | triangle1,triangle2 | quad split in two triangles |