calc_perp_vectors Subroutine

public subroutine calc_perp_vectors(b, a, c)

Calculates normalized vectors that are perpendicular to b such that a x c = b_norm

Arguments

Type IntentOptional AttributesName
real(kind=Float64), intent(in), dimension(3):: b
real(kind=Float64), intent(out), dimension(3):: a
real(kind=Float64), intent(out), dimension(3):: c

Called by

proc~~calc_perp_vectors~~CalledByGraph proc~calc_perp_vectors calc_perp_vectors proc~get_fields get_fields proc~get_fields->proc~calc_perp_vectors proc~lflf_subtract lflf_subtract proc~lflf_subtract->proc~calc_perp_vectors proc~lflf_add lflf_add proc~lflf_add->proc~calc_perp_vectors proc~fida_mc fida_mc proc~fida_mc->proc~get_fields proc~store_fw_photons store_fw_photons proc~store_fw_photons->proc~get_fields proc~store_npa store_npa proc~store_npa->proc~get_fields proc~fida_weights_los fida_weights_los proc~fida_weights_los->proc~get_fields interface~operator(-) operator(-) interface~operator(-)->proc~lflf_subtract interface~operator(+) operator(+) interface~operator(+)->proc~lflf_add proc~neutron_mc neutron_mc proc~neutron_mc->proc~get_fields proc~read_npa read_npa proc~read_npa->proc~get_fields proc~npa_mc npa_mc proc~npa_mc->proc~get_fields proc~npa_mc->proc~store_npa proc~store_bes_photons store_bes_photons proc~store_bes_photons->proc~get_fields proc~neutron_f neutron_f proc~neutron_f->proc~get_fields proc~npa_weights npa_weights proc~npa_weights->proc~get_fields proc~mc_fastion mc_fastion proc~mc_fastion->proc~get_fields proc~store_fida_photons store_fida_photons proc~store_fida_photons->proc~get_fields proc~fida_weights_mc fida_weights_mc proc~fida_weights_mc->proc~get_fields proc~fida_f fida_f proc~fida_f->proc~mc_fastion proc~npa_f npa_f proc~npa_f->proc~store_npa proc~npa_f->proc~mc_fastion program~fidasim fidasim program~fidasim->proc~fida_mc program~fidasim->proc~fida_weights_los program~fidasim->proc~neutron_mc program~fidasim->proc~read_npa program~fidasim->proc~npa_mc program~fidasim->proc~neutron_f program~fidasim->proc~npa_weights program~fidasim->proc~fida_weights_mc program~fidasim->proc~fida_f program~fidasim->proc~npa_f

Contents

Source Code


Source Code

subroutine calc_perp_vectors(b, a, c)
  !+ Calculates normalized vectors that are perpendicular to b
  !+ such that `a` x `c` = `b_norm`
  real(Float64), dimension(3), intent(in)  :: b
  real(Float64), dimension(3), intent(out) :: a
  real(Float64), dimension(3), intent(out) :: c

  real(Float64), dimension(3) :: bnorm

  bnorm=b/norm2(b)

  if (abs(bnorm(3)).eq.1) then
      a=[1.d0,0.d0,0.d0]
      c=[0.d0,1.d0,0.d0]
  else
      if (bnorm(3).eq.0.) then
          a=[0.d0,0.d0,1.d0]
          c=[bnorm(2),-bnorm(1), 0.d0]/sqrt(bnorm(1)**2+bnorm(2)**2)
      else
          a=[bnorm(2),-bnorm(1),0.d0]/sqrt(bnorm(1)**2+bnorm(2)**2)
          c=-[ a(2) , -a(1) , (a(1)*bnorm(2)-a(2)*bnorm(1))/bnorm(3) ]
          c=c/norm2(c)
          if(bnorm(3).lt.0.0) then
              c=-c
          endif
      endif
  endif

end subroutine calc_perp_vectors