ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
line2D.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s)
12#include "detray/definitions/algebra.hpp"
13#include "detray/definitions/detail/qualifiers.hpp"
14#include "detray/definitions/math.hpp"
15
16namespace detray {
17
19template <concepts::algebra algebra_t>
20struct line2D {
22 using algebra_type = algebra_t;
33
36
44 DETRAY_HOST_DEVICE
46 const point3_type &p,
47 const vector3_type &dir) {
48 const auto local3 = trf.point_to_local(p);
49
50 // Line direction
51 const vector3_type z = trf.z();
52
53 // Line center
54 const point3_type t = trf.translation();
55
56 // Radial vector
57 const vector3_type r = vector::cross(z, dir);
58
59 // Assign the sign depending on the position w.r.t line
60 // Right: -1
61 // Left: 1
62 const scalar_type sign = vector::dot(r, t - p) > 0.f ? -1.f : 1.f;
63
64 return {sign * vector::perp(local3), local3[2], vector::phi(local3)};
65 }
66
74 DETRAY_HOST_DEVICE
75 static inline loc_point global_to_local(const transform3_type &trf,
76 const point3_type &p,
77 const vector3_type &dir) {
78 const point3_type local3 =
80
81 return {local3[0], local3[1]};
82 }
83
89 DETRAY_HOST_DEVICE static inline point3_type local_to_global(
90 const transform3_type &trf, const point3_type &p) {
91 const scalar_type R = math::fabs(p[0]);
92 const point3_type local = {R * math::cos(p[2]), R * math::sin(p[2]), p[1]};
93
94 return trf.point_to_global(local);
95 }
96
103 template <typename mask_t>
104 DETRAY_HOST_DEVICE static inline point3_type local_to_global(
105 const transform3_type &trf, const mask_t & /*mask*/, const loc_point &p,
106 const vector3_type &dir) {
107 // Line direction
108 const vector3_type z = trf.z();
109
110 // Radial vector
111 const vector3_type r = vector::cross(z, dir);
112
113 // Local Z position in global cartesian coordinate
114 const point3_type locZ_in_global = trf.point_to_global(point3_type{
115 static_cast<scalar_type>(0), static_cast<scalar_type>(0), p[1]});
116
117 return locZ_in_global + p[0] * vector::normalize(r);
118 }
119
123 template <typename mask_t>
124 DETRAY_HOST_DEVICE static inline vector3_type normal(
125 const transform3_type &trf, const point2_type & /*loc*/ = {},
126 const mask_t & /*mask*/ = {}) {
127 return trf.z();
128 }
129
133 DETRAY_HOST_DEVICE static inline vector3_type normal(
134 const transform3_type &trf, const point3_type & /*loc*/ = {}) {
135 return trf.z();
136 }
137};
138
139} // namespace detray
Detray include(s).
Definition array_operators.hpp:18
get_scalar_t< A, T > dscalar
Scalar type for algebra A and value type T.
Definition algebra.hpp:64
get_vector3D_t< A, T > dvector3D
Three-dimensional vector type for algebra A and value type T.
Definition algebra.hpp:80
get_transform3D_t< A, T > dtransform3D
Three-dimensional transform type for algebra A and value type T.
Definition algebra.hpp:84
get_point3D_t< A, T > dpoint3D
Three-dimensional point type for algebra A and value type T.
Definition algebra.hpp:72
get_point2D_t< A, T > dpoint2D
Two-dimensional point type for algebra A and value type T.
Definition algebra.hpp:68
Projection into a line coordinate frame.
Definition line2D.hpp:20
dpoint3D< algebra_t > point3_type
Three-dimensional point type.
Definition line2D.hpp:28
dscalar< algebra_t > scalar_type
Scalar type associated with the algebra backend.
Definition line2D.hpp:24
static vector3_type normal(const transform3_type &trf, const point3_type &={})
Definition line2D.hpp:133
point2_type loc_point
Local point type in line coordinates.
Definition line2D.hpp:35
static point3_type local_to_global(const transform3_type &trf, const point3_type &p)
This method transforms from a local 3D line point to a point in the global cartesian 3D frame.
Definition line2D.hpp:89
dtransform3D< algebra_t > transform3_type
Three-dimensional transform type.
Definition line2D.hpp:32
static point3_type global_to_local_3D(const transform3_type &trf, const point3_type &p, const vector3_type &dir)
This method transforms a point from a global cartesian 3D frame to a local 3D line point Convert a po...
Definition line2D.hpp:45
dpoint2D< algebra_t > point2_type
Two-dimensional point type.
Definition line2D.hpp:26
static vector3_type normal(const transform3_type &trf, const point2_type &={}, const mask_t &={})
Definition line2D.hpp:124
static loc_point global_to_local(const transform3_type &trf, const point3_type &p, const vector3_type &dir)
This method transforms a point from a global cartesian 3D frame to a local 3D line point Convert a po...
Definition line2D.hpp:75
algebra_t algebra_type
Algebra backend used by this coordinate frame.
Definition line2D.hpp:22
dvector3D< algebra_t > vector3_type
Three-dimensional vector type.
Definition line2D.hpp:30
static point3_type local_to_global(const transform3_type &trf, const mask_t &, const loc_point &p, const vector3_type &dir)
This method transforms from a local 2D line point to a point in the global cartesian 3D frame.
Definition line2D.hpp:104