ATLAS Offline Software
Loading...
Searching...
No Matches
LineIntersection2D.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6// LineIntersection2D.h, (c) ATLAS Detector software
8
9#ifndef TRKEXUTILS_LINEINTERSECTION2D_H
10#define TRKEXUTILS_LINEINTERSECTION2D_H
11
12#include <cmath>
13#include <utility>
14
15#ifndef NUMERICALSTABLE
16#define NUMERICALSTABLE 10e-7
17#endif
18
19namespace Trk {
20
21/* @struct LineIntersction2D
22
23 Helper method having 2 lines given with two sets of points each
24
25 (x1,y1)(x2,y2) - line a
26 (X1,Y1)(X2,Y2) - line b
27
28 @author Andreas.Salzburger@cern.ch
29 */
30
32{
33
34 bool valid;
35 double interX;
36 double interY;
37 double k, K, d, D;
38
40 double y1,
41 double x2,
42 double y2,
43 double X1,
44 double Y1,
45 double X2,
46 double Y2)
47 {
48 // diffs, k's and d's
49 double deltax = x2 - x1;
50 double deltay = y2 - y1;
51 double deltaX = X2 - X1;
52 double deltaY = Y2 - Y1;
53 k = deltay / deltax;
54 K = deltaY / deltaX;
55 d = y2 - k * x2;
56 D = Y2 - K * X2;
57 // check if valid
58 valid = ((k - K) * (k - K) > NUMERICALSTABLE);
59 if (valid) {
60 interX = (D - d) / (k - K);
61 interY = interX * k + d;
62 } else {
63 interX = -99999.;
64 interY = -99999.;
65 }
66 }
67};
68
69} // end of namespace
70
71#endif
72
#define NUMERICALSTABLE
Ensure that the ATLAS eigen extensions are properly loaded.
LineIntersection2D(double x1, double y1, double x2, double y2, double X1, double Y1, double X2, double Y2)