Exemple de comment convertir des degrés en radian et inversement en fortran en se basant sur un simple produit en croix:
rad: 0 -> pi
deg: 0 -> 180
qui donne
rad = ( pi * deg ) / 180
deg = ( 180 * rad ) / pi
code fortran 90 correspondant:
program DegToRad
implicit none
integer, parameter :: pr = selected_real_kind(15,3)
real(pr) :: pi = dacos(-1.0d0)
real(pr) :: deg, rad
! Exemple convert Degree to Radian:
deg = 60.0
rad = ( pi * deg ) / 180.0
write(6,*) deg, rad
! Exemple convert Radian to degree:
rad = sqrt(2.0) / 2.0
deg = ( 180.0 * rad ) / pi
write(6,*) rad, deg
end program DegToRad
donne
> gfortran DegToRad.f90 -o DegToRad
> DegToRad
60.000000000000000 1.0471975511965976
0.70710676908493042 40.514233533698189
Recherches associées
Liens | Site |
---|---|
Trigonometric Functions Using Degree | cs.mtu.edu |
Fortran Intrinsic Functions | cs.mtu.edu |
Intrinsic Functions in Fortran 90 | colostate.edu |