Calculates basis from 3 points on a plane with +z being the plane normal
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=Float64), | intent(in), | dimension(3) | :: | center | Plane origin |
|
real(kind=Float64), | intent(in), | dimension(3) | :: | redge | Right edge of plane |
|
real(kind=Float64), | intent(in), | dimension(3) | :: | tedge | Top edge of plane |
|
real(kind=Float64), | intent(out), | dimension(3,3) | :: | basis | Basis for transforming from plane to cartesian coordinates |
|
real(kind=Float64), | intent(out), | optional | dimension(3,3) | :: | inv_basis | Inverse basis for the reverse transformation cartesian to plane |
subroutine plane_basis(center, redge, tedge, basis, inv_basis)
!+ Calculates basis from 3 points on a plane with +z being the plane normal
real(Float64), dimension(3), intent(in) :: center
!+ Plane origin
real(Float64), dimension(3), intent(in) :: redge
!+ Right edge of plane
real(Float64), dimension(3), intent(in) :: tedge
!+ Top edge of plane
real(Float64), dimension(3,3), intent(out) :: basis
!+ Basis for transforming from plane to cartesian coordinates
real(Float64), dimension(3,3), intent(out), optional :: inv_basis
!+ Inverse basis for the reverse transformation cartesian to plane
real(Float64), dimension(3) :: u1,u2,u3
u1 = (redge - center)
u1 = u1/norm2(u1)
u2 = (tedge - center)
u2 = u2/norm2(u2)
u3 = cross_product(u1,u2)
u3 = u3/norm2(u3)
basis(:,1) = u1
basis(:,2) = u2
basis(:,3) = u3
if(present(inv_basis)) inv_basis = transpose(basis)
end subroutine plane_basis