This module contains the definition of a polygon and some related subroutines More...
| Data Types | |
| type | mod_cg2_polygon::t_polygon | 
| Definition of a bi-dimensional polygon.  More... | |
| Functions/Subroutines | |
| 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. | |
This module contains the definition of a polygon and some related subroutines
| pure subroutine mod_cg2_polygon::cg2_copy_polygon | ( | type(t_polygon), intent(in) | original, | 
| type(t_polygon), intent(out) | copy ) | 
Make a copy of a polygon.
| [in] | original | Original polygon | 
| [out] | copy | Copy of the original polygon | 
| elemental subroutine mod_cg2_polygon::cg2_finalize_polygon | ( | type(t_polygon), intent(inout) | polygon | ) | 
Finalize the polygon structure.
| [in,out] | polygon | The polygon to finalize | 
| pure subroutine mod_cg2_polygon::cg2_initialize_polygon | ( | type(t_polygon), intent(inout) | polygon, | 
| integer, intent(in) | n ) | 
Initialize the polygon structure.
| [in,out] | polygon | The polygon to initialize | 
| [in] | n | The number of vertices of the 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 a given polygon to another polygon.
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.
| [in,out] | polygon1 | Polygon to be transfered in polygon2 | 
| [in,out] | polygon2 | Polygon receiving data from polygon1 | 
| 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 ) | 
Compute the centroid of a polygon.
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
| [in] | polygon | Any polygon | 
| [out] | centroid | Centroid of the polygon | 
| [out] | volume | Volume of the polygon | 
| double precision elemental function mod_cg2_polygon::cg2_polygon_volume | ( | type(t_polygon), intent(in) | polygon | ) | 
Compute the area of a 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
| [in] | polygon | Any polygon | 
| integer pure function mod_cg2_polygon::cg2_polygon_winding_number | ( | type(t_polygon), intent(in) | polygon, | 
| double precision, dimension(2), intent(in) | point ) | 
Compute the winding number of a point in a polygon.
A point is outside a polygon if the winding number is equal to 0.
| [in] | polygon | Any polygon | 
| [in] | point | Any point of the plane | 
| 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 ) | 
Compute the winding number of a point in a polygon including its boundary.
A point is outside a polygon if the winding number is equal to 0.
| [in] | polygon | Any polygon | 
| [in] | point | Any point of the plane | 
| subroutine mod_cg2_polygon::cg2_polygon_write_vtk_file | ( | type(t_polygon), intent(in) | polygon, | 
| character(len=*), intent(in) | filename ) | 
Print a polygon into a VTK file for debug purpose.
| [in] | polygon | Any polygon | 
| [in] | filename | File name of the VTK file | 
| 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 ) | 
Split a quadrilateral in two triangles.
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}
  !! | [in] | quad | Quadrilateral | 
| [out] | triangle1,triangle2 | quadsplit in two triangles |