CMS 3D CMS Logo

Line3D.h
Go to the documentation of this file.
1 // Hep-LIKE geometrical 3D LINE class
2 //
3 //
4 // Author: BKH
5 //
6 
7 #ifndef HepLine3D_hh
8 #define HepLine3D_hh
9 
10 #include "CLHEP/Geometry/Point3D.h"
11 #include "CLHEP/Geometry/Normal3D.h"
12 #include "CLHEP/Geometry/Plane3D.h"
13 #include <iostream>
14 
15 class HepLine3D {
16 protected:
17  HepGeom::Point3D<double> pp;
18  HepGeom::Vector3D<double> uu;
19  double eps;
20 
21 public:
22  HepLine3D(const HepGeom::Point3D<double>& p, const HepGeom::Vector3D<double>& v, double sml = 1.e-10)
23  : pp(p), uu(v * (v.mag() > 1.e-10 ? 1. / v.mag() : 1)), eps(fabs(sml)) {}
24 
25  HepLine3D(const HepGeom::Point3D<double>& p1, const HepGeom::Point3D<double>& p2, double sml = 1.e-10)
26  : pp(p1), uu((p2 - p1) * ((p2 - p1).mag() > 1.e-10 ? 1. / (p2 - p1).mag() : 1)), eps(fabs(sml)) {}
27 
28  // Copy constructor
30 
31  // Destructor
33 
34  // Assignment
36  pp = line.pp;
37  uu = line.uu;
38  eps = line.eps;
39  return *this;
40  }
41 
42  // Test for equality
43  bool operator==(const HepLine3D& l) const { return pp == l.pp && uu == l.uu; }
44 
45  // Test for inequality
46  bool operator!=(const HepLine3D& l) const { return pp != l.pp || uu != l.uu; }
47 
48  const HepGeom::Point3D<double>& pt() const { return pp; }
49 
50  const HepGeom::Vector3D<double>& uv() const { return uu; }
51 
52  HepGeom::Point3D<double> point(const HepGeom::Plane3D<double>& pl, bool& parallel) const {
53  const double num(-pl.d() - pl.a() * pp.x() - pl.b() * pp.y() - pl.c() * pp.z());
54  const double den(pl.a() * uu.x() + pl.b() * uu.y() + pl.c() * uu.z());
55 
56  parallel = (eps > fabs(num)) || (eps > fabs(den));
57 
58  return (parallel ? pp : HepGeom::Point3D<double>(pp + uu * (num / den)));
59  }
60 
61  HepGeom::Point3D<double> point(const HepGeom::Point3D<double>& q) const {
62  return (pp + ((q.x() - pp.x()) * uu.x() + (q.y() - pp.y()) * uu.y() + (q.z() - pp.z()) * uu.z()) * uu);
63  }
64 
65  double dist2(const HepGeom::Point3D<double>& q) const { return (q - point(q)).mag2(); }
66  double dist(const HepGeom::Point3D<double>& q) const { return (q - point(q)).mag(); }
67 };
68 
69 #endif
HepLine3D::dist
double dist(const HepGeom::Point3D< double > &q) const
Definition: Line3D.h:66
HepLine3D::operator==
bool operator==(const HepLine3D &l) const
Definition: Line3D.h:43
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
data-class-funcs.q
q
Definition: data-class-funcs.py:169
HepLine3D::operator!=
bool operator!=(const HepLine3D &l) const
Definition: Line3D.h:46
findQualityFiles.v
v
Definition: findQualityFiles.py:179
HepLine3D::uv
const HepGeom::Vector3D< double > & uv() const
Definition: Line3D.h:50
HepLine3D::pp
HepGeom::Point3D< double > pp
Definition: Line3D.h:17
p2
double p2[4]
Definition: TauolaWrapper.h:90
HepLine3D::eps
double eps
Definition: Line3D.h:19
HepLine3D::operator=
HepLine3D & operator=(const HepLine3D &line)
Definition: Line3D.h:35
HepLine3D::HepLine3D
HepLine3D(const HepGeom::Point3D< double > &p1, const HepGeom::Point3D< double > &p2, double sml=1.e-10)
Definition: Line3D.h:25
HepLine3D::point
HepGeom::Point3D< double > point(const HepGeom::Point3D< double > &q) const
Definition: Line3D.h:61
HepLine3D::uu
HepGeom::Vector3D< double > uu
Definition: Line3D.h:18
p1
double p1[4]
Definition: TauolaWrapper.h:89
HepLine3D
Definition: Line3D.h:15
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
HepLine3D::~HepLine3D
~HepLine3D()
Definition: Line3D.h:32
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
HepLine3D::dist2
double dist2(const HepGeom::Point3D< double > &q) const
Definition: Line3D.h:65
HepLine3D::point
HepGeom::Point3D< double > point(const HepGeom::Plane3D< double > &pl, bool &parallel) const
Definition: Line3D.h:52
HepLine3D::HepLine3D
HepLine3D(const HepGeom::Point3D< double > &p, const HepGeom::Vector3D< double > &v, double sml=1.e-10)
Definition: Line3D.h:22
HepLine3D::pt
const HepGeom::Point3D< double > & pt() const
Definition: Line3D.h:48
HepLine3D::HepLine3D
HepLine3D(const HepLine3D &line)
Definition: Line3D.h:29
mps_splice.line
line
Definition: mps_splice.py:76
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37