Calculates basis from a line with +x in the direction of line
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=Float64), | intent(in), | dimension(3) | :: | r0 | Starting point of line [cm] |
|
real(kind=Float64), | intent(in), | dimension(3) | :: | v0 | Direction of line |
|
real(kind=Float64), | intent(out), | dimension(3,3) | :: | basis | Basis for transforming from line coordinates to cartesian |
|
real(kind=Float64), | intent(out), | optional | dimension(3,3) | :: | inv_basis | Inverse basis for the reverse transformation cartesian to line |
subroutine line_basis(r0, v0, basis, inv_basis)
!+ Calculates basis from a line with +x in the direction of line
real(Float64), dimension(3), intent(in) :: r0
!+ Starting point of line [cm]
real(Float64), dimension(3), intent(in) :: v0
!+ Direction of line
real(Float64), dimension(3,3), intent(out) :: basis
!+ Basis for transforming from line coordinates to cartesian
real(Float64), dimension(3,3), intent(out), optional :: inv_basis
!+ Inverse basis for the reverse transformation cartesian to line
real(Float64), dimension(3) :: rf
real(Float64) :: alpha, beta, dis
rf = r0 + v0
dis = sqrt(sum((rf - r0)**2))
beta = asin((r0(3) - rf(3))/dis)
alpha = atan2(rf(2)-r0(2),rf(1)-r0(1))
call tb_zyx(alpha,beta,0.d0,basis)
if(present(inv_basis)) inv_basis = transpose(basis)
end subroutine line_basis