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~track track proc~fida_mc->proc~track proc~store_photons store_photons proc~store_photons->proc~get_fields proc~track_cylindrical track_cylindrical proc~track_cylindrical->proc~get_fields proc~store_npa store_npa proc~store_npa->proc~get_fields proc~mc_fastion_pass_grid mc_fastion_pass_grid proc~mc_fastion_pass_grid->proc~get_fields proc~track->proc~get_fields proc~fida_weights_los fida_weights_los proc~fida_weights_los->proc~get_fields proc~fida_weights_los->proc~track interface~operator(-) operator(-) interface~operator(-)->proc~lflf_subtract proc~pnpa_mc pnpa_mc proc~pnpa_mc->proc~get_fields proc~pnpa_mc->proc~store_npa proc~ndmc ndmc proc~ndmc->proc~get_fields proc~ndmc->proc~track proc~make_diagnostic_grids make_diagnostic_grids proc~make_diagnostic_grids->proc~get_fields proc~make_diagnostic_grids->proc~track_cylindrical proc~make_diagnostic_grids->proc~track proc~neutron_mc neutron_mc proc~neutron_mc->proc~get_fields interface~operator(+) operator(+) interface~operator(+)->proc~lflf_add proc~npa_mc npa_mc proc~npa_mc->proc~get_fields proc~npa_mc->proc~store_npa proc~store_fw_photons store_fw_photons proc~store_fw_photons->proc~get_fields proc~pfida_mc pfida_mc proc~pfida_mc->proc~get_fields proc~pfida_mc->proc~track_cylindrical proc~npa_weights npa_weights proc~npa_weights->proc~get_fields proc~mc_fastion mc_fastion proc~mc_fastion->proc~get_fields proc~neutron_f neutron_f proc~neutron_f->proc~get_fields proc~fida_weights_mc fida_weights_mc proc~fida_weights_mc->proc~get_fields proc~fida_weights_mc->proc~track proc~pnpa_f pnpa_f proc~pnpa_f->proc~store_npa proc~pnpa_f->proc~mc_fastion_pass_grid proc~dcx_spec dcx_spec proc~dcx_spec->proc~store_photons proc~dcx dcx proc~dcx->proc~track proc~halo_spec halo_spec proc~halo_spec->proc~store_photons proc~fida_f fida_f proc~fida_f->proc~track proc~fida_f->proc~mc_fastion proc~cold_spec cold_spec proc~cold_spec->proc~store_photons proc~nbi_spec nbi_spec proc~nbi_spec->proc~store_photons proc~npa_f npa_f proc~npa_f->proc~store_npa proc~npa_f->proc~mc_fastion proc~halo halo proc~halo->proc~track program~fidasim fidasim program~fidasim->proc~fida_mc program~fidasim->proc~fida_weights_los program~fidasim->proc~pnpa_mc program~fidasim->proc~ndmc program~fidasim->proc~make_diagnostic_grids program~fidasim->proc~neutron_mc program~fidasim->proc~npa_mc program~fidasim->proc~pfida_mc program~fidasim->proc~npa_weights program~fidasim->proc~neutron_f program~fidasim->proc~fida_weights_mc program~fidasim->proc~pnpa_f program~fidasim->proc~dcx_spec program~fidasim->proc~dcx program~fidasim->proc~halo_spec program~fidasim->proc~fida_f program~fidasim->proc~cold_spec program~fidasim->proc~nbi_spec program~fidasim->proc~npa_f program~fidasim->proc~halo proc~pfida_f pfida_f program~fidasim->proc~pfida_f proc~store_bes_photons store_bes_photons proc~store_bes_photons->proc~store_photons proc~pfida_f->proc~track_cylindrical proc~pfida_f->proc~mc_fastion_pass_grid proc~store_fida_photons store_fida_photons proc~store_fida_photons->proc~store_photons

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