Class Geometry
In: geometry.f90

幾何学に関するルーチン

Methods

Included Modules

math_const

Public Instance methods

Subroutine :
xp :real, intent(in)
: 円の中心 x 座標
yp :real, intent(in)
: 円の中心 y 座標
rad :real, intent(in)
: 円の半径
num :integer, intent(in)
: 配列要素数
xd(num) :real, intent(inout)
: 円の x 座標データ
yd(num) :real, intent(inout)
: 円の y 座標データ

デカルト点 xp, yp から半径 rad の円を描き, その値を 極座標の同位角方向に num 個の配列要素に格納する. xd, yd がその円のデカルト座標での値.

[Source]

subroutine product_circle( xp, yp, rad, num, xd, yd )
! デカルト点 xp, yp から半径 rad の円を描き, その値を
! 極座標の同位角方向に num 個の配列要素に格納する.
! xd, yd がその円のデカルト座標での値.
  use math_const
  implicit none
  real, intent(in) :: xp  ! 円の中心 x 座標
  real, intent(in) :: yp  ! 円の中心 y 座標
  real, intent(in) :: rad  ! 円の半径
  integer, intent(in) :: num  ! 配列要素数
  real, intent(inout) :: xd(num)  ! 円の x 座標データ
  real, intent(inout) :: yd(num)  ! 円の y 座標データ
  integer :: i

  do i=1,num
     xd(i)=xp+rad*cos(real(i-1)*2.0*pi/real(num-1))
     yd(i)=yp+rad*sin(real(i-1)*2.0*pi/real(num-1))
  end do

end subroutine
Subroutine :
r :real, intent(in)
: 中心からの距離
t :real, intent(in)
: x 軸からの角度 [rad]
x :real, intent(inout)
: x 座標
y :real, intent(inout)
: y 座標

平面極座標から平面デカルト座標への変換

この場合は座標の原点が r で自動的に指定されているので, 原点を指定する引数は必要ない. 逆に返される x, y の値は, r=0 を原点とした デカルト座標系として返されることに注意する.

[Source]

subroutine rt_2_xy( r, t, x, y )
! 平面極座標から平面デカルト座標への変換
!
! この場合は座標の原点が r で自動的に指定されているので,
! 原点を指定する引数は必要ない.
! 逆に返される x, y の値は, r=0 を原点とした
! デカルト座標系として返されることに注意する.
  implicit none
  real, intent(in) :: r  ! 中心からの距離
  real, intent(in) :: t  ! x 軸からの角度 [rad]
  real, intent(inout) :: x  ! x 座標
  real, intent(inout) :: y  ! y 座標

  x=r*cos(t)
  y=r*sin(t)

end subroutine