Belle II Software development
ParameterLine2D.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackingUtilities/geometry/ParameterLine2D.h>
9
10#include <tracking/trackingUtilities/geometry/VectorUtil.h>
11
12#include <ostream>
13
14using namespace Belle2;
15using namespace TrackingUtilities;
16
17ParameterLine2D ParameterLine2D::touchingCircles(const ROOT::Math::XYVector& fromCenter,
18 const double fromSignedRadius,
19 const ROOT::Math::XYVector& toCenter,
20 const double toSignedRadius)
21{
22 ROOT::Math::XYVector connecting = toCenter - fromCenter;
23
24 // Normalize to the coordinate system vector, but keep the original norm
25 const double norm = connecting.R();
26 if (norm != 0.0) {
27 connecting *= (1. / norm);
28 }
29
30 double kappa = (fromSignedRadius - toSignedRadius) / norm;
31 double cokappa = sqrt(1 - kappa * kappa);
32
33 ROOT::Math::XYVector fromPos = VectorUtil::compose(connecting, kappa * fromSignedRadius, cokappa * fromSignedRadius);
34 fromPos += fromCenter;
35
36 ROOT::Math::XYVector toPos = VectorUtil::compose(connecting, kappa * toSignedRadius, cokappa * toSignedRadius);
37 toPos += toCenter;
38
39 return ParameterLine2D::throughPoints(fromPos, toPos);
40}
41
42std::ostream& TrackingUtilities::operator<<(std::ostream& output, const ParameterLine2D& line)
43{
44 output << "ParameterLine2D(" << line.support() << "," << line.tangential() << ")";
45 return output;
46}
A line with a support point and tangential vector.
ParameterLine2D()
Default constructor for ROOT compatibility.
static ParameterLine2D throughPoints(const ROOT::Math::XYVector &start, const ROOT::Math::XYVector &end)
Static constructor for a line between to points.
static ParameterLine2D touchingCircles(const ROOT::Math::XYVector &fromCenter, double fromSignedRadius, const ROOT::Math::XYVector &toCenter, double toSignedRadius)
Constructs a line touching two circles in one point each.
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
Abstract base class for different kinds of events.