![]() |
|
|||
File indexing completed on 2025-07-12 07:51:48
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include "Acts/Visualization/IVisualization3D.hpp" 0012 0013 #include <Eigen/Dense> 0014 0015 namespace Acts { 0016 0017 /// Class which models a ray. It is defined by a starting point and a 0018 /// direction. 0019 /// @tparam value_t The floating point type to use 0020 /// @tparam DIM The number of dimensions in which this ray is defined (2 or 3) 0021 template <typename value_t, std::size_t DIM> 0022 class Ray { 0023 public: 0024 /// Re expose the value type 0025 using value_type = value_t; 0026 /// Vertex type based on the value type and dimension 0027 using VertexType = Eigen::Matrix<value_t, DIM, 1>; 0028 /// Vertex array type corresponding to the vertex type 0029 using vertex_array_type = Eigen::Array<value_t, DIM, 1>; 0030 /// Associated transform type 0031 using transform_type = Eigen::Transform<value_t, DIM, Eigen::Affine>; 0032 0033 /// Constructor from an origin point and a direction 0034 /// @param origin The origin of the ray 0035 /// @param dir The direction of the ray 0036 Ray(const VertexType& origin, const VertexType& dir); 0037 0038 /// Getter for the origin 0039 /// @return The origin 0040 const VertexType& origin() const { return m_origin; } 0041 0042 /// Getter for the direction 0043 /// @return The direction 0044 const VertexType& dir() const { return m_dir; } 0045 0046 /// Getter for the element wise inverse of the direction. 0047 /// @return The element wise inverse. 0048 const vertex_array_type& idir() const { return m_idir; } 0049 0050 /// Transforms this ray using a given transform and returns a new instance 0051 /// @param trf The transform to apply 0052 /// @return Copy of this ray with the transform applied 0053 Ray<value_t, DIM> transformed(const transform_type& trf) const; 0054 0055 /// Write information on this instance to an outstream. 0056 /// @param os The out stream 0057 /// @return The out stream given as an argument 0058 std::ostream& toStream(std::ostream& os) const; 0059 0060 /// Helper to draw this ray using a given visualization helper. 0061 /// @param helper The visualization helper 0062 /// @param far_distance The "length" of the drawn line representing the ray 0063 void draw(IVisualization3D& helper, value_type far_distance = 10) const 0064 requires(DIM == 3); 0065 0066 private: 0067 VertexType m_origin; 0068 VertexType m_dir; 0069 vertex_array_type m_idir; 0070 }; 0071 0072 /// Overload of the outstream operator 0073 /// @param os The out stream 0074 /// @param ray The ray to write to @p os 0075 /// @return The outstream given in @p os 0076 template <typename T, std::size_t D> 0077 std::ostream& operator<<(std::ostream& os, const Ray<T, D>& ray) { 0078 ray.dump(os); 0079 return os; 0080 } 0081 0082 using Ray3D = Ray<double, 3>; 0083 0084 } // namespace Acts 0085 0086 #include "Acts/Utilities/Ray.ipp"
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |