📄 geo2d.f90
字号:
!------------------------------------------------------------------------------!! MODULE : GEO2D Auteur : J. Gressier! Date : Fevrier 2004! Fonction Modif : (cf historique)! Bibliotheque de procedures et fonctions pour le calcul geometrique 2D!! Defauts/Limitations/Divers :!!------------------------------------------------------------------------------!module GEO2Duse TYPHMAKE! -- DECLARATIONS -----------------------------------------------------------type v2d real(krp) :: x, yendtype! -- INTERFACES -------------------------------------------------------------interface v2d_of module procedure v2d_fromtabendinterfaceinterface abs module procedure v2d_normeendinterfaceinterface tab module procedure tab_v2dendinterfaceinterface xcomp module procedure v2d_xcompendinterfaceinterface ycomp module procedure v2d_ycompendinterfaceinterface operator(+) module procedure v2d_additionendinterfaceinterface operator(-) module procedure v2d_substraction, v2d_oppendinterfaceinterface operator(*) module procedure v2d_multiplysp, v2d_multiplydpendinterfaceinterface operator(/) module procedure v2d_divisionsp, v2d_divisiondpendinterfaceinterface operator(.scal.) module procedure v2d_scalar_productendinterfaceinterface operator(.vect.) module procedure v2d_vectorial_productendinterfaceinterface rot module procedure v2d_rot, v2d_rot_aendinterface! -- Fonctions et Operateurs ------------------------------------------------! -- IMPLEMENTATION ---------------------------------------------------------contains!------------------------------------------------------------------------------!! Fonction : composante x!------------------------------------------------------------------------------!real(krp) function v2d_xcomp(v)implicit nonetype(v2d), intent(in) :: v v2d_xcomp = v%xendfunction v2d_xcomp!------------------------------------------------------------------------------!! Fonction : composante y!------------------------------------------------------------------------------!real(krp) function v2d_ycomp(v)implicit nonetype(v2d), intent(in) :: v v2d_ycomp = v%yendfunction v2d_ycomp!------------------------------------------------------------------------------!! Fonction : transtypage real(1:2) -> v2d!------------------------------------------------------------------------------!type(v2d) function v2d_fromtab(tab)implicit nonereal(krp), dimension(2) :: tab v2d_fromtab = v2d(tab(1), tab(2))endfunction v2d_fromtab!------------------------------------------------------------------------------!! Fonction : transtypage v2d -> real(1:2)!------------------------------------------------------------------------------!function tab_v2d(v)implicit nonetype(v2d), intent(in) :: vreal(krp), dimension(2) :: tab_v2d tab_v2d(1:2) = (/ v%x, v%y /)endfunction tab_v2d!------------------------------------------------------------------------------!! Fonction : calcul de somme de vecteur!------------------------------------------------------------------------------!type(v2d) function v2d_addition(v1, v2)implicit nonetype(v2d), intent(in) :: v1, v2 v2d_addition%x = v1%x + v2%x v2d_addition%y = v1%y + v2%y endfunction v2d_addition!------------------------------------------------------------------------------!! Fonction : calcul difference de vecteur!------------------------------------------------------------------------------!type(v2d) function v2d_substraction(v1, v2)implicit nonetype(v2d), intent(in) :: v1, v2 v2d_substraction%x = v1%x - v2%x v2d_substraction%y = v1%y - v2%y endfunction v2d_substraction!------------------------------------------------------------------------------!! Fonction : calcul de l'oppose d'un vecteur!------------------------------------------------------------------------------!type(v2d) function v2d_opp(v)implicit nonetype(v2d), intent(in) :: v v2d_opp%x = - v%x v2d_opp%y = - v%y endfunction v2d_opp!------------------------------------------------------------------------------!! Fonction : calcul de multiplication de vecteur par reel!------------------------------------------------------------------------------!type(v2d) function v2d_multiplysp(x, v)implicit nonereal(4), intent(in) :: xtype(v2d), intent(in) :: v v2d_multiplysp%x = x * v%x v2d_multiplysp%y = x * v%y endfunction v2d_multiplysp!------------------------------------------------------------------------------!! Fonction : calcul de multiplication de vecteur par reel!------------------------------------------------------------------------------!type(v2d) function v2d_multiplydp(x, v)implicit nonereal(8), intent(in) :: xtype(v2d), intent(in) :: v v2d_multiplydp%x = x * v%x v2d_multiplydp%y = x * v%y endfunction v2d_multiplydp!------------------------------------------------------------------------------!! Fonction : calcul de division de vecteur par reel!------------------------------------------------------------------------------!type(v2d) function v2d_divisionsp(v,x)implicit nonereal(4), intent(in) :: xtype(v2d), intent(in) :: v v2d_divisionsp%x = v%x / x v2d_divisionsp%y = v%y / xendfunction v2d_divisionsp!------------------------------------------------------------------------------!! Fonction : calcul de division de vecteur par reel!------------------------------------------------------------------------------!type(v2d) function v2d_divisiondp(v,x)implicit nonereal(8), intent(in) :: xtype(v2d), intent(in) :: v v2d_divisiondp%x = v%x / x v2d_divisiondp%y = v%y / xendfunction v2d_divisiondp!------------------------------------------------------------------------------!! Fonction : norme de vecteur!------------------------------------------------------------------------------!real(krp) function v2d_norme(v)implicit nonetype(v2d), intent(in) :: v v2d_norme = sqrt(v%x*v%x + v%y*v%y)endfunction v2d_norme!------------------------------------------------------------------------------!! Fonction : calcul de produit scalaire!------------------------------------------------------------------------------!real(krp) function v2d_scalar_product(v1, v2)implicit nonetype(v2d), intent(in) :: v1, v2 v2d_scalar_product = v1%x*v2%x + v1%y*v2%yendfunction v2d_scalar_product!------------------------------------------------------------------------------!! Fonction : produit vectoriel -> scalaire!------------------------------------------------------------------------------!real(krp) function v2d_vectorial_product(v1, v2)implicit nonetype(v2d), intent(in) :: v1, v2 v2d_vectorial_product = v1%x*v2%y - v1%y*v2%xendfunction v2d_vectorial_product!------------------------------------------------------------------------------!! Fonction : rotation d'un vecteur!------------------------------------------------------------------------------!type(v2d) function v2d_rot(v)implicit nonetype(v2d), intent(in) :: v v2d_rot%x = - v%y v2d_rot%y = v%x endfunction v2d_rot!------------------------------------------------------------------------------!! Fonction : rotation d'un vecteur!------------------------------------------------------------------------------!type(v2d) function v2d_rot_a(v, a)implicit nonetype(v2d), intent(in) :: v ! vecteur a tournerreal(krp), intent(in) :: a ! angle de rotation en radiansreal(krp) :: ca, sa ca = cos(a) sa = sin(a) v2d_rot_a%x = v%x*ca - v%y*sa v2d_rot_a%y = v%x*sa + v%y*caendfunction v2d_rot_aendmodule GEO2D!------------------------------------------------------------------------------!! Historique des modifications!! fev 2004 : creation du module (a partir de GEO3D)! mars 2004 : rotation angulaire 2D (v2d_rot_a)!------------------------------------------------------------------------------!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -