16#ifndef MATHUTILS_INCLUDE_MATHUTILS_DETAIL_TRIGONOMETRIC_H_
17#define MATHUTILS_INCLUDE_MATHUTILS_DETAIL_TRIGONOMETRIC_H_
24#ifndef GPUCA_GPUCODE_DEVICE
43 res += o2::constants::math::TwoPI;
60 res += o2::constants::math::TwoPI;
62 while (
res > o2::constants::math::TwoPI) {
63 res -= o2::constants::math::TwoPI;
79 if (
res > o2::constants::math::PI) {
80 res -= o2::constants::math::TwoPI;
81 }
else if (
res < -o2::constants::math::PI) {
82 res += o2::constants::math::TwoPI;
98 while (
res < -o2::constants::math::PI) {
99 res += o2::constants::math::TwoPI;
101 while (
res > o2::constants::math::PI) {
102 res -= o2::constants::math::TwoPI;
114template <
typename T,
typename S,
typename U>
117 return o2::gpu::GPUCommonMath::SinCos(ang,
s,
c);
123 return o2::gpu::GPUCommonMath::SinCos(ang,
s,
c);
128 return o2::gpu::GPUCommonMath::SinCosd(ang,
s,
c);
132#ifndef GPUCA_GPUCODE_DEVICE
139 sincos<T>(ang, sin, cos);
140 return std::make_tuple(sin, cos);
164 sincos<T>(
alpha, sin, cos);
166 xy[0] =
x * cos - xy[1] * sin;
167 xy[1] =
x * sin + xy[1] * cos;
186template <
typename T =
float>
187GPUhdi() constexpr
T sectorDAlpha()
189 return o2::constants::math::SectorSpanRad * 0.5;
196 int sect =
phi * o2::constants::math::Rad2Deg / o2::constants::math::SectorSpanDeg;
198 sect += o2::constants::math::NSectors - 1;
200 return sect % o2::constants::math::NSectors;
207 T ang = o2::constants::math::SectorSpanRad * (0.5f + sect);
216 return sector2Angle<T>(angle2Sector<T>(
phi));
223 const T dphi =
phi - phiMin;
224 return ((dphi > 0 && dphi < constants::math::PI) || dphi < -constants::math::PI) ? true :
false;
231 const T dphi =
phi - phiMax;
232 return ((dphi < 0 && dphi > -constants::math::PI) || dphi > constants::math::PI) ? true :
false;
240 if (!okForPhiMin(phi0,
phi1)) {
246 phi = 0.5 * (
phi1 - (constants::math::TwoPI - phi0));
259 if (!okForPhiMin(phi0,
phi1)) {
266 del += constants::math::TwoPI;
278 constexpr T Pi = 3.1415926535897932384626433832795;
284 constexpr T A = 0.0776509570923569;
285 constexpr T B = -0.287434475393028;
286 constexpr T C = ((Pi / 4) -
A -
B);
288 return ((
A * a2 +
B) * a2 + C) *
a;
293 constexpr T Pi025 = 1 * Pi / 4;
294 constexpr T Pi075 = 3 * Pi / 4;
295 const T x1 = xx + yy;
296 const T y1 = yy - xx;
306 return phi0 +
atan(tan);
316 return o2::gpu::GPUCommonMath::ASin(
x);
322 return o2::gpu::GPUCommonMath::ACos(
x);
328 return o2::gpu::GPUCommonMath::ATan(
x);
334 return o2::gpu::GPUCommonMath::ATan2(
y,
x);
340 return o2::gpu::GPUCommonMath::Sin(
x);
346 return o2::gpu::GPUCommonMath::Cos(
x);
352 return o2::gpu::GPUCommonMath::Tan(
x);
358 return o2::gpu::GPUCommonMath::TwoPi();
364 return o2::constants::math::TwoPI;
370 return o2::gpu::GPUCommonMath::Pi();
376 return o2::constants::math::PI;
379#ifndef GPUCA_GPUCODE_DEVICE
393 return std::atan2(
y,
x);
GLfloat GLfloat GLfloat alpha
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLboolean GLboolean GLboolean GLboolean a
void bringTo02PiGen(T &phi)
return((dphi > 0 &&dphi< constants::math::PI)||dphi< -constants::math::PI) ? true GPUhdi() const expr bool okForPhiMax(T phiMax
return((dphi< 0 &&dphi > -constants::math::PI)||dphi > constants::math::PI) ? true T phi1
void bringToPMPiGen(T &phi)
std::tuple< T, T > rotateZ(T xL, T yL, T snAlp, T csAlp)
return copysign< T >(atan2P(o2::gpu::GPUCommonMath::Abs(y), x), y)
float angle2Alpha(float phi)
int angle2Sector(float phi)
std::tuple< float, float > rotateZInv(float xG, float yG, float snAlp, float csAlp)
float sector2Angle(int sect)
void bringToPMPi(float &phi)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...