This routine creates box from canoND definition i.en origin and three vectors. If only_surface is defined then box is converted further to plane and then to triangles. \verbatim vecB_vecC /\ - | | - | | - | | - | |- | |------------>| origin vecA \endverbatim
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_box_type), | intent(out) | :: | me | |||
real(kind=rk), | intent(in) | :: | origin(3) | |||
real(kind=rk), | intent(in) | :: | vecA(3) | |||
real(kind=rk), | intent(in) | :: | vecB(3) | |||
real(kind=rk), | intent(in) | :: | vecC(3) | |||
logical, | intent(in) | :: | only_surface |
subroutine tem_createBox(me, origin, vecA, vecB, vecC, only_surface) !--------------------------------------------------------------------------! type(tem_box_type), intent(out) :: me !< plane to return real(kind=rk), intent(in) :: origin(3) !< plane origin real(kind=rk), intent(in) :: vecA(3) !< 1st vector real(kind=rk), intent(in) :: vecB(3) !< 2nd vector real(kind=rk), intent(in) :: vecC(3) !< 3nd vector logical, intent(in) :: only_surface !--------------------------------------------------------------------------! real(kind=rk) :: extent real(kind=rk) :: secondOrigin(3) ! -------------------------------------------------------------------------! me%only_surface = only_surface if (only_surface) then ! convert box to planes ! planes 1,2,3 call tem_createPlane(me = me%plane(1), origin = origin, & & vecA = vecA, vecB = vecB ) call tem_createPlane(me = me%plane(2), origin = origin, & & vecA = vecA, vecB = vecC ) call tem_createPlane(me = me%plane(3), origin = origin, & & vecA = vecB, vecB = vecC ) ! planes 4,5,6 secondOrigin = origin + vecA + vecB + vecC call tem_createPlane(me = me%plane(4), origin = secondOrigin, & & vecA = -vecA, vecB = -vecB ) call tem_createPlane(me = me%plane(5), origin = secondOrigin, & & vecA = -vecA, vecB = -vecC ) call tem_createPlane(me = me%plane(6), origin = secondOrigin, & & vecA = -vecB, vecB = -vecC ) else ! convert me to box !vector is normalized first and then converted to half vector !length of the vector extent = sqrt(dot_product(vecA(:),vecA(:))) !normal of the vector(unitNormal) me%normal(:,1) = vecA(:)/extent !halfwidth of the vector me%halfwidth(1) = extent*0.5_rk !halfvector me%halfvec(:,1) = 0.5_rk*vecA(:) !length of the vector extent = sqrt(dot_product(vecB(:),vecB(:))) !normal of the vector(unitNormal) me%normal(:,2) = vecB(:)/extent !halfwidth of the vector me%halfwidth(2) = extent*0.5_rk !halfvector me%halfvec(:,2) = 0.5_rk*vecB(:) !length of the vector extent = sqrt(dot_product(vecC(:),vecC(:))) !normal of the vector(unitNormal) me%normal(:,3) = vecC(:)/extent !halfwidth of the vector me%halfwidth(3) = extent*0.5_rk !halfvector me%halfvec(:,3) = 0.5_rk*vecC(:) me%center = origin & & + me%halfvec(:,1) & & + me%halfvec(:,2) & & + me%halfvec(:,3) end if end subroutine tem_createBox