groups

name language licence
Feng's wierd way of making time plots C++ Other
Adding Bundles Other Other
C Starter C Other
Check to see if a file exists C++ Other
Check the version of php Shell Other
PostgreSQL version number Shell Other
Distance from a point to a line C++ Other
Checkout code from SVN Shell Other

< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 >



language: C++
licence: Other

Distance from a point to a line

options: view full snippetsend to code collector
Float_t distance_from_muon(Float_t n_x, Float_t n_y, Float_t n_z,
                           Float_t muon_x, Float_t muon_y, Float_t muon_z,
                           Float_t muon_u, Float_t muon_v, Float_t muon_w) {

  // Calculate the distance of a point (n_x, n_y, n_z) from a line specified
  // by a point (muon_u, muon_v, muon_w) and direction cosines (muon_u, muon_v, muon_w).

  TVector3 ref_point(n_x, n_y, n_z);
  TVector3 line_point(muon_x, muon_y, muon_z);
  TVector3 line_direction_cosines(muon_u, muon_v, muon_w);

  TVector3 v = ref_point - line_point;

  Double_t d = (line_direction_cosines.Cross(v)).Mag()
             / line_direction_cosines.Mag();
	
(Continues...)