File Interpolation.hpp

namespace Acts


This file is foreseen for the Geometry module to replace Extent


template<typename T, size_t N, class Point1, class Point2 = Point1, class Point3 = Point2, typename = std::enable_if_t<detail::can_interpolate<Point1, Point2, Point3, T>::value>>
inline T interpolate(const Point1 &position, const Point2 &lowerCorner, const Point3 &upperCorner, const std::array<T, N> &values)

performs linear interpolation inside a hyper box


  • Given U and V of value type T as well as two double a and b, then the following must be a valid expression a * U + b * V yielding an object which is (implicitly) convertible to T.

  • All Point types must represent d-dimensional positions and support coordinate access using operator[] which should return a double (or a value which is implicitly convertible). Coordinate indices must start at 0.

  • N is the number of hyper box corners which is \(2^d\) where \(d\) is the dimensionality of the hyper box. The dimensionality must be consistent with the provided Point types.

  • Definition of the canonical order for sorting the field values: The hyper box corners are numbered according to the following scheme. Each corner is defined by the set of lower/upper boundary limits in each dimension i. This can be represented by a binary code (from left to right) where a 0 stands for a lower bound along this axis and a 1

    stand for the upper bound along this axis. The left most bit corresponds to the first dimension and the bits to the left correspond to the 2nd, 3rd… dimension. The binary code can be interpreted as integer which gives the number of the corresponding hyper box corner. The field values are ordered according to ascending hyper box corner numbers.

    As an example assume we have a 3D box with

    lowerCorner = (1,2,3) and upperCorner = (4,5,6). The eight corners with their bit patterns and corner numbers are:
    • (1,2,3): 000 = 0

    • (1,2,6): 001 = 1

    • (1,5,3): 010 = 2

    • (1,5,6): 011 = 3

    • (4,2,3): 100 = 4

    • (4,2,6): 101 = 5

    • (4,5,3): 110 = 6

    • (4,5,6): 111 = 7

Template Parameters
  • T – type of values to be interpolated

  • N – number of hyper box corners

  • Point1 – type specifying geometric positions

  • Point2 – type specifying geometric positions

  • Point3 – type specifying geometric positions

  • position[in] position to which to interpolate

  • lowerCorner[in] generalized lower-left corner of hyper box (containing the minima of the hyper box along each dimension)

  • upperCorner[in] generalized upper-right corner of hyper box (containing the maxima of the hyper box along each dimension)

  • values[in] field values at the hyper box corners sorted in the canonical order defined below.


interpolated value at given position


position must describe a position inside the given hyper box, that is \(\text{lowerCorner}[i] \le \text{position}[i] \le \text{upperCorner}[i] \quad \forall i=0, \dots, d-1\).