File Frustum.hpp

namespace Acts

Note

This file is foreseen for the Geometry module to replace Extent

template<typename value_t, size_t DIM, size_t SIDES>
class Frustum
#include <Acts/Utilities/Frustum.hpp>

Class representing a frustum shape.

The frustum is defined using an origin, a direction and an opening angle. These parameters are then used to calculate a number of side planes, each having a position and a normal vector. The “near plane” is assumed to coincide with the origin point, and the normal with the “direction” of the frustum. No far plane is defined.

Template Parameters
  • value_t – The floating point value to use

  • DIM – The number of dimensions of ambient space

  • SIDES – The number of sides (= side planes) the frustum has (exactly 2 in 2D, minimum 3 in 3D)

Public Types

using transform_type = Eigen::Transform<value_t, DIM, Eigen::Affine>

Associated transform type.

using value_type = value_t

Re expose the value type.

using vertex_array_type = Eigen::Array<value_t, DIM, 1>

Vertex array type corresponding to the vertex type.

using VertexType = Eigen::Matrix<value_t, DIM, 1>

Vertex type based on the value type and dimension.

Public Functions

template<size_t D = DIM, std::enable_if_t<D == 2, int> = 0>
Frustum(const VertexType &origin, const VertexType &dir, value_type opening_angle)

Constructor for the 2D case.

Note

The opening_angle is defined as the angle between opposing side planes. The opening angle needs to be < pi.

Parameters
  • origin – The origin of the frustum

  • dir – The direction of the frustum

  • opening_angle – The opening angle

template<size_t D = DIM, std::enable_if_t<D == 3, int> = 0>
Frustum(const VertexType &origin, const VertexType &dir, value_type opening_angle)

Constructor for the 3D case.

Note

The opening_angle is defined as the angle between opposing side planes. The opening angle needs to be < pi.

Parameters
  • origin – The origin of the frustum

  • dir – The direction of the frustum

  • opening_angle – The opening angle

inline const VertexType &dir() const

Getter for the direction of the frustum.

Returns

The direction of the frustum

template<size_t D = DIM, std::enable_if_t<D == 3, int> = 0>
void draw(IVisualization3D &helper, value_type far_distance = 10) const

Draw a representation of this frustum using a visualization helper.

Note

This is only available for the 3D case.

Parameters
  • helper – The visualization helper

  • far_distance – The distance to the virtual “far plane” at which point the side planes terminate visually.

inline const std::array<VertexType, SIDES + 1> &normals() const

Getter for the normal vectors of the planes defining this frustum.

Note

The size of the array that is returned is fixed to number of sides + 1

Returns

Array containing the normal vectors for all planes.

inline const VertexType &origin() const

Getter for the oriogin of the frustum.

Returns

The origin of the frustum

template<size_t D = DIM, std::enable_if_t<D == 2, int> = 0>
std::ostream &svg(std::ostream &os, value_type w, value_type h, value_type far_distance = 1, value_type unit = 20.) const

Draw a representation of this frustum as an SVG string to an outstream.

Note

This is only available for the 2D case.

Parameters
  • os – The out stream to write to

  • w – The width of the output SVG

  • h – The height of the output SVG

  • far_distance – The distance to the virtual “far line” at which point the side lines terminate visually.

  • unit – Multiplicative factor to apply to internal distances

Frustum<value_t, DIM, SIDES> transformed(const transform_type &trf) const

Transforms this frustum using a given transform and returns a new instance.

Parameters

trf – The transform to apply

Returns

A copy of this frustum with the transform trf applied.

Public Static Attributes

static constexpr size_t dim = DIM

Re expose the number of dimensions.

static constexpr size_t sides = SIDES

Re expose the number of sides.

Private Types

using translation_t = Eigen::Translation<value_t, DIM>

Private Functions

inline Frustum(const VertexType &origin, std::array<VertexType, SIDES + 1> normals)

Private Members

std::array<VertexType, SIDES + 1> m_normals
VertexType m_origin

Private Static Attributes

static constexpr size_t n_normals = SIDES + 1