12#include "detray/definitions/algebra.hpp"
13#include "detray/definitions/containers.hpp"
14#include "detray/definitions/detail/qualifiers.hpp"
15#include "detray/definitions/indexing.hpp"
16#include "detray/definitions/math.hpp"
17#include "detray/definitions/units.hpp"
18#include "detray/geometry/coordinates/cartesian3D.hpp"
19#include "detray/geometry/coordinates/polar2D.hpp"
20#include "detray/geometry/detail/shape_utils.hpp"
37 static constexpr std::string_view
name =
"ring2D";
47 template <concepts::scalar scalar_t>
51 template <concepts::algebra algebra_t>
55 template <
typename bool_t>
59 static constexpr std::size_t
dim{2u};
70 template <concepts::scalar scalar_t, concepts::po
int po
int_t>
73 return math::min(math::fabs(loc_p[0] - bounds[e_inner_r]),
74 math::fabs(bounds[e_outer_r] - loc_p[0]));
86 template <concepts::algebra algebra_t>
114 template <concepts::scalar scalar_t, concepts::po
int po
int_t>
117 const scalar_t tol = std::numeric_limits<scalar_t>::epsilon(),
118 const scalar_t = 0.f)
const {
119 return ((loc_p[0] + tol) >= bounds[e_inner_r] &&
120 loc_p[0] <= (bounds[e_outer_r] + tol));
129 template <concepts::scalar scalar_t>
130 DETRAY_HOST_DEVICE
constexpr scalar_t
measure(
140 template <concepts::scalar scalar_t>
141 DETRAY_HOST_DEVICE
constexpr scalar_t
area(
143 return (bounds[e_outer_r] * bounds[e_outer_r] -
144 bounds[e_inner_r] * bounds[e_inner_r]) *
154 template <concepts::scalar scalar_t>
160 new_bounds[e_inner_r] = math::min(bounds[e_inner_r], o_bounds[e_inner_r]);
161 new_bounds[e_outer_r] = math::max(bounds[e_outer_r], o_bounds[e_outer_r]);
175 template <concepts::algebra algebra_t>
182 return {-r_bound, -r_bound, -env, r_bound, r_bound, env};
186 template <concepts::algebra algebra_t>
189 return {0.f, 0.f, 0.f};
198 template <concepts::algebra algebra_t>
202 throw std::runtime_error(
"Vertex generation for rings is not implemented");
212 template <concepts::scalar scalar_t>
215 constexpr auto tol{10.f * std::numeric_limits<scalar_t>::epsilon()};
217 if (math::signbit(bounds[e_inner_r]) || bounds[e_outer_r] < tol) {
218 os <<
"DETRAY ERROR (HOST): Radius must be in the range [0, "
223 if (bounds[e_inner_r] >= bounds[e_outer_r] ||
224 math::fabs(bounds[e_inner_r] - bounds[e_outer_r]) < tol) {
225 os <<
"DETRAY ERROR (HOST): Inner radius must be smaller outer "
Geometrical shape of a closed ring.
Definition ring2D.hpp:34
constexpr bool check_consistency(const bounds_type< scalar_t > &bounds, std::ostream &os) const
Check consistency of boundary values.
Definition ring2D.hpp:213
static constexpr std::string_view name
The name for this shape.
Definition ring2D.hpp:37
scalar_t min_dist_to_boundary(const bounds_type< scalar_t > &bounds, const point_t &loc_p) const
Find the minimum distance to any boundary.
Definition ring2D.hpp:71
static constexpr std::size_t dim
Dimension of the local coordinate system.
Definition ring2D.hpp:59
constexpr auto check_boundaries(const bounds_type< scalar_t > &bounds, const point_t &loc_p, const scalar_t tol=std::numeric_limits< scalar_t >::epsilon(), const scalar_t=0.f) const
Definition ring2D.hpp:115
dvector< dpoint3D< algebra_t > > vertices(const bounds_type< dscalar< algebra_t > > &, dindex) const
Generate vertices in local cartesian frame.
Definition ring2D.hpp:199
constexpr scalar_t measure(const bounds_type< scalar_t > &bounds) const
Measure of the shape: Area.
Definition ring2D.hpp:130
boundaries
Indices describing the entries in the shape boundary array.
Definition ring2D.hpp:40
darray< dscalar< algebra_t >, 6 > local_min_bounds(const bounds_type< dscalar< algebra_t > > &bounds, const dscalar< algebra_t > env=std::numeric_limits< dscalar< algebra_t > >::epsilon()) const
Lower and upper point for minimal axis aligned bounding box.
Definition ring2D.hpp:176
constexpr scalar_t area(const bounds_type< scalar_t > &bounds) const
The area of a the shape.
Definition ring2D.hpp:141
darray< scalar_t, boundaries::e_size > bounds_type
Container definition for the shape boundary values.
Definition ring2D.hpp:48
bool_t result_type
Result type of a boundary check.
Definition ring2D.hpp:56
constexpr result_type< dbool< algebra_t > > check_boundaries(const bounds_type< dscalar< algebra_t > > &bounds, const dtransform3D< algebra_t > &trf, const dpoint3D< algebra_t > &glob_p, const dscalar< algebra_t > tol=std::numeric_limits< dscalar< algebra_t > >::epsilon(), const dscalar< algebra_t >=0.f) const
Check boundary values for a local point.
Definition ring2D.hpp:87
dpoint3D< algebra_t > centroid(const bounds_type< dscalar< algebra_t > > &) const
Definition ring2D.hpp:187
polar2D< algebra_t > local_frame_type
Local coordinate frame for boundary checks.
Definition ring2D.hpp:52
constexpr bounds_type< scalar_t > merge(const bounds_type< scalar_t > &bounds, const bounds_type< scalar_t > &o_bounds) const
Merge two ring/disc shapes.
Definition ring2D.hpp:155
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
vecmem::vector< value_t > dvector
Vector container backed by vecmem.
Definition containers.hpp:34
unsigned int dindex
Default index type.
Definition indexing.hpp:18
std::array< value_t, kDIM > darray
Fixed-size array container.
Definition containers.hpp:30
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
static loc_point global_to_local(const transform3_type &trf, const point3_type &p, const vector3_type &)
This method transforms a point from a global cartesian 3D frame to a local 3D cartesian point Convert...
Definition cartesian3D.hpp:57
static constexpr scalar_t pi
π
Definition units.hpp:136
Projection into a polar coordinate frame.
Definition polar2D.hpp:20