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/cylindrical2D.hpp"
20#include "detray/geometry/detail/shape_utils.hpp"
36 static constexpr std::string_view
name =
"cylinder2D";
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[1] - bounds[e_lower_z]),
74 math::fabs(bounds[e_upper_z] - loc_p[1]));
86 template <concepts::algebra algebra_t>
117 template <concepts::scalar scalar_t, concepts::po
int po
int_t>
120 const scalar_t tol = std::numeric_limits<scalar_t>::epsilon(),
121 const scalar_t edge_tol = 0.f)
const {
122 auto inside_mask{((bounds[e_lower_z] - tol) <= loc_p[1] &&
123 loc_p[1] <= (bounds[e_upper_z] + tol))};
125 decltype(inside_mask) inside_edge{
false};
126 if (detail::any_of(edge_tol > 0.f)) {
127 const scalar_t full_tol{tol + edge_tol};
128 inside_edge = ((bounds[e_lower_z] - full_tol) <= loc_p[1] &&
129 loc_p[1] <= (bounds[e_upper_z] + full_tol));
132 return result_type<
decltype(inside_mask)>{inside_mask, inside_edge};
141 template <concepts::scalar scalar_t>
142 DETRAY_HOST_DEVICE
constexpr scalar_t
measure(
152 template <concepts::scalar scalar_t>
153 DETRAY_HOST_DEVICE
constexpr scalar_t
area(
156 (bounds[e_upper_z] - bounds[e_lower_z]);
165 template <concepts::scalar scalar_t>
171 new_bounds[e_r] = math::max(bounds[e_r], o_bounds[e_r]);
172 new_bounds[e_lower_z] = math::min(bounds[e_lower_z], o_bounds[e_lower_z]);
173 new_bounds[e_upper_z] = math::max(bounds[e_upper_z], o_bounds[e_upper_z]);
187 template <concepts::algebra algebra_t>
195 return {-xy_bound, -xy_bound, bounds[e_lower_z] - env,
196 xy_bound, xy_bound, bounds[e_upper_z] + env};
201 template <concepts::algebra algebra_t>
206 0.5f * (bounds[e_lower_z] + bounds[e_upper_z])};
215 template <concepts::algebra algebra_t>
219 throw std::runtime_error(
220 "Vertex generation for cylinders is not implemented");
230 template <concepts::scalar scalar_t>
233 constexpr auto tol{10.f * std::numeric_limits<scalar_t>::epsilon()};
235 if (bounds[e_r] < tol) {
236 os <<
"DETRAY ERROR (HOST): Radius must be in the range (0, "
241 if (bounds[e_lower_z] >= bounds[e_upper_z] ||
242 math::fabs(bounds[e_lower_z] - bounds[e_upper_z]) < tol) {
243 os <<
"DETRAY ERROR (HOST): Neg. half length must be smaller than "
Geometrical shape of a 2D cylinder.
Definition cylinder2D.hpp:33
cylindrical2D< algebra_t > local_frame_type
Local coordinate frame for boundary checks.
Definition cylinder2D.hpp:52
constexpr bool check_consistency(const bounds_type< scalar_t > &bounds, std::ostream &os) const
Check consistency of boundary values.
Definition cylinder2D.hpp:231
boundaries
Indices describing the entries in the shape boundary array.
Definition cylinder2D.hpp:39
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 edge_tol=0.f) const
Definition cylinder2D.hpp:118
dvector< dpoint3D< algebra_t > > vertices(const bounds_type< dscalar< algebra_t > > &, dindex) const
Generate vertices in local cartesian frame.
Definition cylinder2D.hpp:216
constexpr scalar_t area(const bounds_type< scalar_t > &bounds) const
The area of a the shape.
Definition cylinder2D.hpp:153
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 > edge_tol=0.f) const
Check boundary values for a local point.
Definition cylinder2D.hpp:87
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 cylinder2D.hpp:188
static constexpr std::string_view name
The name for this shape.
Definition cylinder2D.hpp:36
constexpr bounds_type< scalar_t > merge(const bounds_type< scalar_t > &bounds, const bounds_type< scalar_t > &o_bounds) const
Merge two 2D cylinder shapes.
Definition cylinder2D.hpp:166
darray< scalar_t, boundaries::e_size > bounds_type
Container definition for the shape boundary values.
Definition cylinder2D.hpp:48
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 cylinder2D.hpp:71
dpoint3D< algebra_t > centroid(const bounds_type< dscalar< algebra_t > > &bounds) const
Definition cylinder2D.hpp:202
static constexpr std::size_t dim
Dimension of the local coordinate system.
Definition cylinder2D.hpp:59
constexpr scalar_t measure(const bounds_type< scalar_t > &bounds) const
Measure of the shape: Area.
Definition cylinder2D.hpp:142
detail::boundary_check_result< bool_t > result_type
Result type of a boundary check.
Definition cylinder2D.hpp:56
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 2D cylindrical coordinate frame.
Definition cylindrical2D.hpp:20