IGMBaseLib 1.0
|
00001 00012 module igmcore_geometry 00013 00014 ! モジュール引用 ; Use statements 00015 ! 00016 00017 ! 種類型パラメタ 00018 ! Kind type parameter 00019 ! 00020 use dc_types, only: DP ! 倍精度実数型. Double precision. 00021 00022 00023 ! 線形代数 00024 ! Linear algebra 00025 ! 00026 use igmcore_linear_algebra, only: & 00027 & vec_length, cross 00028 00029 ! 宣言文 ; Declaration statements 00030 ! 00031 implicit none 00032 private 00033 00034 ! 公開手続き 00035 ! Public procedure 00036 ! 00037 public :: triangle_area, tri_grav_center, polygon_grav_center 00038 00039 contains 00040 00041 ! 00058 function triangle_area( & 00059 & p1, p2, p3 & ! (in) 00060 & ) result(area) 00061 00062 ! 宣言文 ; Declaration statements 00063 ! 00064 real(DP), intent(in) :: p1(3) ! 三角形の頂点 P1 の位置ベクトル 00065 real(DP), intent(in) :: p2(3) ! 三角形の頂点 P2 の位置ベクトル 00066 real(DP), intent(in) :: p3(3) ! 三角形の頂点 P3 の位置ベクトル 00067 real(DP) area ! 三角形の面積 00068 00069 ! 実行文 ; Executable statements 00070 ! 00071 00072 area = 0.5d0 * vec_length(cross(p1-p2, p3-p2)) 00073 00074 end function 00075 00076 ! 00093 function tri_grav_center( & 00094 & p1, p2, p3 & ! (in) 00095 & ) result(p) 00096 00097 ! 宣言文 ; Declaration statements 00098 ! 00099 real(DP), intent(in) :: p1(3) ! 三角形の頂点 P1 の位置ベクトル 00100 real(DP), intent(in) :: p2(3) ! 三角形の頂点 P2 の位置ベクトル 00101 real(DP), intent(in) :: p3(3) ! 三角形の頂点 P3 の位置ベクトル 00102 real(DP) :: p(3) ! 三角形の重心の位置ベクトル 00103 00104 ! 実行文 ; Executable statements 00105 ! 00106 00107 p = ( p1 + p2 + p3 ) /3.0d0 00108 00109 end function tri_grav_center 00110 00111 ! 00126 function polygon_grav_center( & 00127 & pt_size, points & ! (in) 00128 & ) result(grav_p) 00129 00130 ! 宣言文 ; Declaration statements 00131 ! 00132 integer, intent(in) :: pt_size ! 多角形の頂点数 00133 real(DP), intent(in) :: points(pt_size, 3) ! 多角形の各頂点の位置ベクトルを頂点数だけ格納した配列 00134 real(DP) grav_p(3) ! 多角形の重心の位置ベクトル 00135 00136 ! 作業変数 00137 ! Work variables 00138 ! 00139 integer i 00140 00141 ! 実行文 ; Executable statements 00142 ! 00143 00144 grav_p = 0.0d0 00145 do i=1, pt_size 00146 grav_p = grav_p + points(i, :) 00147 end do 00148 00149 grav_p = grav_p / pt_size 00150 00151 end function polygon_grav_center 00152 00153 end module igmcore_geometry