Belle II Software development
Angle.h
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#pragma once
9
10#include <cmath>
11
12namespace Belle2 {
17 namespace TrackFindingCDC {
18
19
24 struct AngleUtil {
25
27 static double average(const double angle1, double angle2)
28 {
29 return normalised(angle1 + normalised(angle2 - angle1) / 2);
30 }
31
33 static double normalised(const double angle)
34 {
35 if (angle > M_PI) return angle - 2 * M_PI;
36 if (angle < -M_PI) return angle + 2 * M_PI;
37 return angle;
38 }
39
41 static void normalise(double& angle)
42 {
43 if (angle > M_PI) angle -= 2 * M_PI;
44 if (angle < -M_PI) angle += 2 * M_PI;
45 }
46
48 static double fullNormalised(const double angle)
49 {
50 return std::remainder(angle, 2 * M_PI);
51 }
52
54 static double reversed(const double angle)
55 {
56 return angle > 0 ? angle - M_PI : angle + M_PI;
57 }
58
59 };
60
61 }
63}
Abstract base class for different kinds of events.
Utility functions to be used with angular quantities.
Definition: Angle.h:24
static void normalise(double &angle)
Normalise an angle inplace to lie in the range from [-pi, pi].
Definition: Angle.h:41
static double average(const double angle1, double angle2)
Combines two angular values to the one that lies half way between them on the short arc.
Definition: Angle.h:27
static double reversed(const double angle)
Get the angle that point in the opposite direction.
Definition: Angle.h:54
static double normalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].
Definition: Angle.h:33
static double fullNormalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].
Definition: Angle.h:48