Belle II Software  release-05-01-25
LineSegment2D.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Kirill Chilikin *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 /* Own header. */
12 #include <klm/eklm/geometry/LineSegment2D.h>
13 
14 using namespace Belle2;
15 
17  const HepGeom::Point3D<double>& point2) :
18  Line2D(point1.x(), point1.y(),
19  point2.x() - point1.x(), point2.y() - point1.y())
20 {
21 }
22 
24 {
25 }
26 
29  HepGeom::Point3D<double>* intersection) const
30 {
31  int n;
32  double t[2];
33  bool condition;
34  n = Line2D::findIntersection(line, intersection, t);
35  if (n == 0)
36  return 0;
37  condition = tWithinRange(t[0]);
38  return selectIntersections(intersection, &condition, 1);
39 }
40 
41 
43 findIntersection(const LineSegment2D& lineSegment,
44  HepGeom::Point3D<double>* intersection) const
45 {
46  int n;
47  double t[2];
48  bool condition;
49  n = Line2D::findIntersection(lineSegment, intersection, t);
50  if (n == 0)
51  return 0;
52  condition = tWithinRange(t[0]) && lineSegment.tWithinRange(t[1]);
53  return selectIntersections(intersection, &condition, 1);
54 }
55 
57 findIntersection(const Circle2D& circle,
58  HepGeom::Point3D<double> intersections[2]) const
59 {
60  int i, n;
61  double t[2], angles[2];
62  bool condition[2];
63  n = Line2D::findIntersection(circle, intersections, t, angles);
64  for (i = 0; i < n; i++)
65  condition[i] = tWithinRange(t[i]);
66  return selectIntersections(intersections, condition, n);
67 }
68 
71  HepGeom::Point3D<double> intersections[2]) const
72 {
73  int i, n;
74  double t[2], angles[2];
75  bool condition[2];
76  n = Line2D::findIntersection(arc, intersections, t, angles);
77  for (i = 0; i < n; i++)
78  condition[i] = tWithinRange(t[i]) && arc.angleWithinRange(angles[i]);
79  return selectIntersections(intersections, condition, n);
80 }
81 
83 {
84  return (t >= 0 && t <= 1);
85 }
86 
Belle2::EKLM::LineSegment2D::tWithinRange
bool tWithinRange(double t) const
Check if t is within the line segment (0 <= t <= 1).
Definition: LineSegment2D.cc:82
Belle2::EKLM::Arc2D
2D arc.
Definition: Arc2D.h:35
Belle2::EKLM::Line2D
2D line.
Definition: Line2D.h:40
Belle2::EKLM::Circle2D
2D circle.
Definition: Circle2D.h:35
Belle2::EKLM::LineSegment2D::findIntersection
int findIntersection(const Line2D &line, HepGeom::Point3D< double > *intersection) const
Find intersection with a line.
Definition: LineSegment2D.cc:28
Belle2::EKLM::LineSegment2D
2D line segment.
Definition: LineSegment2D.h:38
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::EKLM::Arc2D::angleWithinRange
bool angleWithinRange(double angle) const
Check if angle is within the arc.
Definition: Arc2D.cc:28
Belle2::EKLM::Line2D::findIntersection
int findIntersection(const Line2D &line, HepGeom::Point3D< double > *intersection) const
Find intersection with a line.
Definition: Line2D.cc:30
HepGeom::Point3D< double >
Belle2::EKLM::LineSegment2D::~LineSegment2D
~LineSegment2D()
Destructor.
Definition: LineSegment2D.cc:23
Belle2::EKLM::LineSegment2D::LineSegment2D
LineSegment2D(const HepGeom::Point3D< double > &point1, const HepGeom::Point3D< double > &point2)
Constructor.
Definition: LineSegment2D.cc:16