0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
mo_poly::center_of_mass Interface Reference

Center of mass of polygon. More...

Public Member Functions

real(sp) function, dimension(2) center_of_mass_sp (coord)
 Center of mass of polygon.
 
real(dp) function, dimension(2) center_of_mass_dp (coord)
 Center of mass of polygon.
 

Detailed Description

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

polygon(:,1) = (/ 1.0_dp,2.0_dp,2.0_dp,1.0_dp /)
polygon(:,2) = (/ 1.0_dp,1.0_dp,2.0_dp,2.0_dp /)
com = center_of_mass( polygon )
! --> com = (/1.5_dp, 1.5_dp/)

See also example in test directory

Literature

  1. http://de.wikipedia.org/wiki/Geometrischer_Schwerpunkt
Returns
Center of mass of polygon.
Parameters
[in]coordcoordinates of polygon in question

Definition at line 39 of file mo_poly.f90.

Member Function/Subroutine Documentation

◆ center_of_mass_dp()

real(dp) function, dimension(2) mo_poly::center_of_mass::center_of_mass_dp ( real(dp), dimension(:,:), intent(in)  coord)

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

polygon(:,1) = (/ 1.0_dp,2.0_dp,2.0_dp,1.0_dp /)
polygon(:,2) = (/ 1.0_dp,1.0_dp,2.0_dp,2.0_dp /)
com = center_of_mass( polygon )
! --> com = (/1.5_dp, 1.5_dp/)

See also example in test directory

Literature

  1. http://de.wikipedia.org/wiki/Geometrischer_Schwerpunkt
Returns
Center of mass of polygon.
Parameters
[in]coordcoordinates of polygon in question

Definition at line 543 of file mo_poly.f90.

References mo_poly::areapoly_dp().

Here is the call graph for this function:

◆ center_of_mass_sp()

real(sp) function, dimension(2) mo_poly::center_of_mass::center_of_mass_sp ( real(sp), dimension(:,:), intent(in)  coord)

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

polygon(:,1) = (/ 1.0_dp,2.0_dp,2.0_dp,1.0_dp /)
polygon(:,2) = (/ 1.0_dp,1.0_dp,2.0_dp,2.0_dp /)
com = center_of_mass( polygon )
! --> com = (/1.5_dp, 1.5_dp/)

See also example in test directory

Literature

  1. http://de.wikipedia.org/wiki/Geometrischer_Schwerpunkt
Returns
Center of mass of polygon.
Parameters
[in]coordcoordinates of polygon in question

Definition at line 168 of file mo_poly.f90.

References mo_poly::areapoly_sp().

Here is the call graph for this function:

The documentation for this interface was generated from the following file: