File indexing completed on 2026-05-27 07:24:03
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/tracks/free_track_parameters.hpp"
0014
0015
0016 #include <ostream>
0017
0018 namespace detray::detail {
0019
0020
0021 template <concepts::algebra algebra_t>
0022 class ray {
0023 public:
0024 using algebra_type = algebra_t;
0025 using scalar_type = dscalar<algebra_type>;
0026 using point3_type = dpoint3D<algebra_type>;
0027 using vector3_type = dvector3D<algebra_type>;
0028 using transform3_type = dtransform3D<algebra_type>;
0029
0030 ray() = default;
0031
0032
0033
0034
0035
0036 DETRAY_HOST_DEVICE ray(point3_type &&pos, vector3_type &&dir)
0037 : _pos{std::move(pos)}, _dir{std::move(dir)} {}
0038
0039
0040
0041
0042
0043 DETRAY_HOST_DEVICE ray(const point3_type &pos, const scalar_type ,
0044 const vector3_type &dir, const scalar_type )
0045 : _pos{pos}, _dir{dir} {}
0046
0047
0048
0049
0050 template <typename A>
0051 DETRAY_HOST_DEVICE explicit ray(const free_track_parameters<A> &track)
0052 : ray(track.pos(), track.dir()) {
0053 assert(!track.is_invalid());
0054 }
0055
0056
0057 DETRAY_HOST_DEVICE const point3_type &pos() const { return _pos; }
0058
0059
0060 DETRAY_HOST_DEVICE point3_type pos(const scalar_type s) const {
0061
0062 return _pos + s * _dir;
0063 }
0064
0065
0066 DETRAY_HOST_DEVICE void set_pos(point3_type pos) { _pos = pos; }
0067
0068
0069 DETRAY_HOST_DEVICE const vector3_type &dir() const { return _dir; }
0070
0071
0072 DETRAY_HOST_DEVICE const vector3_type &dir(const scalar_type ) const {
0073 return this->dir();
0074 }
0075
0076
0077 DETRAY_HOST_DEVICE void set_dir(vector3_type dir) { _dir = dir; }
0078
0079
0080 DETRAY_HOST_DEVICE
0081 constexpr scalar_type qop() const { return 0.f; }
0082
0083
0084 DETRAY_HOST
0085 friend std::ostream &operator<<(std::ostream &os, const ray &r) {
0086 os << "ray: ";
0087 os << "ori = " << r._pos;
0088 os << ", dir = " << r._dir << std::endl;
0089
0090 return os;
0091 }
0092
0093 private:
0094
0095 point3_type _pos{0.f, 0.f, 0.f};
0096
0097 vector3_type _dir{0.f, 0.f, 1.f};
0098 };
0099
0100
0101 template <typename A>
0102 DETRAY_HOST_DEVICE ray(const free_track_parameters<A> &) -> ray<A>;
0103
0104 }