IGMBaseLib 1.0
|
00001 00012 module igmcore_coordinate_conversion 00013 00014 ! モジュール引用 ; Use statements 00015 ! 00016 00017 ! 種類型パラメタ 00018 ! Kind type parameter 00019 ! 00020 use dc_types, only: DP ! 倍精度実数型. Double precision. 00021 00022 ! 数学 00023 ! Mathematic. 00024 ! 00025 use igmcore_math, only: PI ! 円周率. PI. 00026 00027 ! 宣言文 ; Declaration statements 00028 ! 00029 implicit none 00030 private 00031 00032 ! 公開手続き 00033 ! Public procedure 00034 ! 00035 public :: orth_to_geo_pos, geo_to_orth_pos, geo_to_orth_vec, orth_to_geo_vec 00036 00037 00038 contains 00039 00040 ! 00053 function orth_to_geo_pos( & 00054 & orth_p & ! (in) 00055 & ) result(geo_p) 00056 00057 ! 宣言文 ; Declaration statements 00058 ! 00059 00060 real(DP), intent(in) :: orth_p(3) 00061 real(DP) geo_p(3) 00062 00063 ! 実行文 ; Executable statements 00064 ! 00065 00066 geo_p(3) = sqrt( orth_p(1)**2 + orth_p(2)**2 + orth_p(3)**2 ) 00067 geo_p(2) = asin( orth_p(3) / geo_p(3) ) 00068 geo_p(1) = atan( orth_p(2) / orth_p(1) ) 00069 00070 ! 位置ベクトルの終点が xy 平面上において第三象限にあるときは西経 90 度から 180度, 00071 ! 第二象限にあるときは東経 90 度から 180 度となるように調節する. 00072 00073 if ( geo_p(1) < 0 .and. orth_p(1) < 0 ) then 00074 geo_p(1) = geo_p(1) + PI 00075 else if ( geo_p(1) > 0 .and. orth_p(1) < 0 ) then 00076 geo_p(1) = geo_p(1) - PI 00077 end if 00078 00079 end function orth_to_geo_pos 00080 00081 ! 00094 function geo_to_orth_pos( & 00095 & geo_p & ! (in) 00096 & ) result(orth_p) 00097 00098 ! 宣言文 ; Declaration statements 00099 ! 00100 00101 real(DP), intent(in) :: geo_p(3) ! 地理座標系における位置ベクトル(\f$\phi\f$(経度), \f$\theta\f$(緯度), \f$r\f$(中心からの距離)) 00102 real(DP) orth_p(3) ! 直交座標系における位置ベクトル\f$(x,y,z)\f$. 00103 00104 ! 実行文 ; Executable statements 00105 ! 00106 00107 orth_p(1) = geo_p(3) * cos(geo_p(2)) * cos(geo_p(1)) 00108 orth_p(2) = geo_p(3) * cos(geo_p(2)) * sin(geo_p(1)) 00109 orth_p(3) = geo_p(3) * sin(geo_p(2)) 00110 00111 end function geo_to_orth_pos 00112 00113 ! 00128 function orth_to_geo_vec( & 00129 & orth_v, geo_p & ! (in) 00130 & ) result(geo_v) 00131 00132 ! 宣言文 ; Declaration statements 00133 ! 00134 real(DP), intent(in) :: orth_v(3) ! 直交座標系におけるベクトル\f$(A_x,A_y,A_z)\f$. 00135 real(DP), intent(in) :: geo_p(3) ! 地理座標系における位置ベクトル(\f$\phi\f$(経度), \f$\theta\f$(緯度), \f$r\f$(中心からの距離)) 00136 real(DP) geo_v(3) ! 地理座標系におけるベクトル\f$(A_{\phi}, A_{\theta}, A_r)\f$. 00137 00138 ! 実行文 ; Executable statements 00139 ! 00140 00141 geo_v(3) = orth_v(1) * cos(geo_p(2)) * cos(geo_p(1)) & 00142 & + orth_v(2) * cos(geo_p(2)) * sin(geo_p(1)) & 00143 & + orth_v(3) * sin(geo_p(2)) 00144 00145 geo_v(2) = - orth_v(1) * sin(geo_p(2)) * cos(geo_p(1)) & 00146 & - orth_v(2) * sin(geo_p(2)) * sin(geo_p(1)) & 00147 & + orth_v(3) * cos(geo_p(2)) 00148 00149 geo_v(1) = - orth_v(1) * sin(geo_p(1)) & 00150 & + orth_v(2) * cos(geo_p(1)) 00151 00152 end function orth_to_geo_vec 00153 00154 ! 00168 function geo_to_orth_vec( & 00169 & geo_v, geo_p & ! (in) 00170 & ) result(orth_v) 00171 00172 ! 宣言文 ; Declaration statements 00173 ! 00174 real(DP), intent(in) :: geo_v(3) ! 地理座標系におけるベクトル\f$(A_{\phi}, A_{\theta}, A_r)\f$. 00175 real(DP), intent(in) :: geo_p(3) ! 地理座標系における位置ベクトル($\phi$(経度), $\theta$(緯度), $r$(中心からの距離)) 00176 real(DP) orth_v(3) ! 直交座標系におけるベクトル\f$(A_x,A_y,A_z)\f$. 00177 00178 ! 実行文 ; Executable statements 00179 ! 00180 00181 orth_v(1) = geo_v(3) * cos(geo_p(1)) * cos(geo_p(2)) & 00182 & - geo_v(2) * cos(geo_p(1)) * sin(geo_p(2)) & 00183 & - geo_v(1) * sin(geo_p(1)) 00184 00185 orth_v(2) = geo_v(3) * sin(geo_p(1)) * cos(geo_p(2)) & 00186 & - geo_v(2) * sin(geo_p(1)) * sin(geo_p(2)) & 00187 & + geo_v(1) * cos(geo_p(1)) 00188 00189 orth_v(3) = geo_v(3) * dsin(geo_p(2)) + geo_v(2) * dcos(geo_p(2)) 00190 00191 end function geo_to_orth_vec 00192 00193 end module igmcore_coordinate_conversion