ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtVectorUtil.h
Go to the documentation of this file.
1 #ifndef ATVECTORUTIL_H
2 #define ATVECTORUTIL_H
3 
4 #include <Math/AxisAngle.h>
5 #include <Math/Point3D.h>
6 #include <Math/Point3Dfwd.h> // for XYZPoint
7 #include <Math/Rotation3D.h>
8 #include <Math/Vector3D.h>
9 #include <Math/Vector3Dfwd.h> // for XYZVector
10 #include <Math/VectorUtil.h>
11 
12 #include <cassert>
13 namespace AtTools {
14 
19 template <class Vector>
20 ROOT::Math::AxisAngle GetRotationToZ(const Vector &vec)
21 {
22  using namespace ROOT::Math;
23  XYZVector z(0, 0, 1);
24  return AxisAngle(vec.Unit().Cross(z), VectorUtil::Angle(vec, z));
25 }
26 
31 template <class Vector1, class Vector2>
32 ROOT::Math::XYZPoint GetIntersection(const std::vector<Vector1> &point, const std::vector<Vector2> &direction)
33 {
34  assert(point.size() > 1 && direction.size() > 1);
35  auto n = direction[0].Cross(direction[1]);
36  auto n0 = direction[0].Cross(n);
37  auto n1 = direction[1].Cross(n);
38 
39  auto c0 = point[0] + (point[1] - point[0]).Dot(n1) / direction[0].Dot(n1) * direction[0];
40  auto c1 = point[1] + (point[0] - point[1]).Dot(n0) / direction[1].Dot(n0) * direction[1];
41 
42  return ROOT::Math::XYZPoint((c0 + c1) / 2.);
43 }
44 
45 } // namespace AtTools
46 #endif //#ifndef ATVECTORUTIL_H
XYZVector
ROOT::Math::XYZVector XYZVector
Definition: AtFindVertex.h:20
XYZPoint
ROOT::Math::XYZPoint XYZPoint
Definition: AtPatternCircle2D.h:18
AtTools::GetRotationToZ
ROOT::Math::AxisAngle GetRotationToZ(const Vector &vec)
Definition: AtVectorUtil.h:20
AtTools
Definition: AtSimpleSimulation.h:19
AtTools::GetIntersection
ROOT::Math::XYZPoint GetIntersection(const std::vector< Vector1 > &point, const std::vector< Vector2 > &direction)
Definition: AtVectorUtil.h:32