ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Frustum.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Frustum.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-2019 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 http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
13 
14 #include <ostream>
15 
16 namespace Acts {
17 
27 template <typename value_t, size_t DIM, size_t SIDES>
28 class Frustum {
29  using translation_t = Eigen::Translation<value_t, DIM>;
30 
31  static constexpr size_t n_normals = SIDES + 1;
32 
33  public:
39  using vertex_array_type = Eigen::Array<value_t, DIM, 1>;
41  using transform_type = Eigen::Transform<value_t, DIM, Eigen::Affine>;
42 
44  static constexpr size_t dim = DIM;
46  static constexpr size_t sides = SIDES;
47 
54  template <size_t D = DIM, std::enable_if_t<D == 2, int> = 0>
55  Frustum(const VertexType& origin, const VertexType& dir,
56  value_type opening_angle);
57 
64  template <size_t D = DIM, std::enable_if_t<D == 3, int> = 0>
65  Frustum(const VertexType& origin, const VertexType& dir,
66  value_type opening_angle);
67 
73  template <size_t D = DIM, std::enable_if_t<D == 3, int> = 0>
74  void draw(IVisualization& helper, value_type far_distance = 10) const;
75 
84  template <size_t D = DIM, std::enable_if_t<D == 2, int> = 0>
85  std::ostream& svg(std::ostream& os, value_type w, value_type h,
86  value_type far_distance = 1, value_type unit = 20.) const;
87 
90  const VertexType& origin() const { return m_origin; }
91 
94  const VertexType& dir() const { return m_normals[0]; }
95 
100  const std::array<VertexType, SIDES + 1>& normals() const { return m_normals; }
101 
106 
107  private:
108  // private constructor with pre-calculated normals
109  Frustum(const VertexType& origin, std::array<VertexType, SIDES + 1> normals)
110  : m_origin(origin), m_normals(std::move(normals)) {}
111 
113  // need one more for direction we're facing
114  std::array<VertexType, SIDES + 1> m_normals;
115 };
116 
117 } // namespace Acts
118