ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
Acts::RangeXD< Dims, Type, Vector > Class Template Reference

An orthogonal range in an arbitrary number of dimensions. More...

#include <Acts/Utilities/RangeXD.hpp>

Inheritance diagram for Acts::RangeXD< Dims, Type, Vector >:
[legend]

Public Member Functions

 RangeXD ()
 RangeXD (const std::pair< Type, Type > &p)
 Construct a range from a pair of minimum and maximum values.
 RangeXD (Type minimum, Type maximum)
 Construct a range from a pair of single minimum and maximum values.
 RangeXD (Vector< Type, Dims > minima, Vector< Type, Dims > maxima)
 Construct a range from a pair of minimum and maximum values.
template<template< typename, std::size_t > typename coordinate_t = std::array>
bool contains (const coordinate_t< Type, Dims > &v) const
 Determine whether the range contains a certain point.
bool degenerate () const
 Determine whether this range is degenerate.
void expand (std::size_t i, const Type &min, const Type &max)
 Expand a range on both ends.
void expandMax (std::size_t i, const Type &v)
 Expand a range by increasing the maximum value.
void expandMin (std::size_t i, const Type &v)
 Expand a range by decreasing the minimum value.
Typemax (std::size_t i)
 Return the maximum value of the range i (inclusive).
Type max (std::size_t i) const
 Return the maximum value of the range i (inclusive).
Typemin (std::size_t i)
 Return the minimum value of the range i (inclusive).
Type min (std::size_t i) const
 Return the minimum value of the range i (inclusive).
RangeXD< Dims, Type, Vector > operator& (const RangeXD< Dims, Type, Vector > &o) const
 Compute the intersection of this range with another range.
bool operator&& (const RangeXD< Dims, Type, Vector > &r) const
 Determine whether this range intersects another.
RangeXD< Dims, Type, Vector > & operator&= (const RangeXD< Dims, Type, Vector > &o)
 Update the range to the intersection with another range.
bool operator<= (const RangeXD< Dims, Type, Vector > &o) const
 Determine whether one range is a subset of another range.
template<template< typename, std::size_t > typename V>
RangeXDoperator= (const RangeXD< Dims, Type, V > &o)
 Assignment operator.
bool operator== (const RangeXD< Dims, Type, Vector > &o) const
 Determine whether two ranges are equal.
bool operator>= (const RangeXD< Dims, Type, Vector > &o) const
 Determine whether one range is a superset of another range.
RangeXD< 1, Type, SingleElementContainer > operator[] (const std::size_t &i)
 Access one of the dimensional ranges of the volume.
RangeXD< 1, Typeoperator[] (const std::size_t &i) const
 Access one of the dimensional ranges of the volume.
void set (std::size_t i, const Type &min, const Type &max)
 Set the minimum and maximum value.
void setMax (std::size_t i, const Type &v)
 Set the maximum value.
void setMin (std::size_t i, const Type &v)
 Set the minimum value.
void shrink (std::size_t i, const Type &min, const Type &max)
 Shrink a range on both ends.
void shrinkMax (std::size_t i, const Type &v)
 Shrink a range by decreasing the maximum value.
void shrinkMin (std::size_t i, const Type &v)
 Shrink a range by increasing the minimum value.
std::string toString (void) const
 Represent the range as a string.
void expandMin (const Type &v)
 Methods for manipulating a range of dimension 1.
void expandMax (const Type &v)
 Expand a range by increasing the maximum value.
void expand (const Type &min, const Type &max)
 Expand a range on both ends.
void shrinkMin (const Type &v)
 Shrink a range by increasing the minimum value.
void shrinkMax (const Type &v)
 Shrink a range by decreasing the maximum value.
void shrink (const Type &min, const Type &max)
 Shrink a range on both ends.
void setMin (const Type &v)
 Set the minimum value.
void setMax (const Type &v)
 Set the maximum value.
void set (const Type &min, const Type &max)
 Set the minimum and maximum value.
Type min () const
 Return the minimum value of the range (inclusive).
Typemin ()
 Return the minimum value of the range (inclusive).
Type max () const
 Return the maximum value of the range (inclusive).
Typemax ()
 Return the maximum value of the range (inclusive).
Type size () const
 Compute the size of the range.
bool contains (const Type &v) const
 Determine if the range contains a given value.

Detailed Description

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
class Acts::RangeXD< Dims, Type, Vector >

An orthogonal range in an arbitrary number of dimensions.

By combining a number one-dimensional ranges we can (under the assumption that our axes are orthogonal) construct an orthogonal range of values. In other words, a hyperrectangular volume in space.

Template Parameters
DimsThe number of dimensions in our range
TypeThe scalar type of our ranges
VectorThe vector type used to define coordinates

Constructor & Destructor Documentation

◆ RangeXD() [1/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Acts::RangeXD< Dims, Type, Vector >::RangeXD ( )

◆ RangeXD() [2/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Acts::RangeXD< Dims, Type, Vector >::RangeXD ( Vector< Type, Dims > minima,
Vector< Type, Dims > maxima )

Construct a range from a pair of minimum and maximum values.

Parameters
minimaThe minimum values of the range
maximaThe maximum values of the range

◆ RangeXD() [3/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Acts::RangeXD< Dims, Type, Vector >::RangeXD ( Type minimum,
Type maximum )

Construct a range from a pair of single minimum and maximum values.

Note
Only available for one-dimensional ranges
Parameters
minimumThe minimum value of the range
maximumThe maximum value of the range

◆ RangeXD() [4/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Acts::RangeXD< Dims, Type, Vector >::RangeXD ( const std::pair< Type, Type > & p)
explicit

Construct a range from a pair of minimum and maximum values.

Note
Only available for one-dimensional ranges
Parameters
pThe pair of minimum and maximum values

Member Function Documentation

◆ contains() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
template<template< typename, std::size_t > typename coordinate_t = std::array>
bool Acts::RangeXD< Dims, Type, Vector >::contains ( const coordinate_t< Type, Dims > & v) const

Determine whether the range contains a certain point.

This is true if and only if the range contains the point in all of its dimensions.

Parameters
vThe coordinate to check for membership in the range
Returns
true The coordinate is inside the range
false The coordinate is outside the range

◆ contains() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
bool Acts::RangeXD< Dims, Type, Vector >::contains ( const Type & v) const

Determine if the range contains a given value.

A value is inside a range if and only if it is greater than the minimum and smaller than the maximum.

Parameters
vThe value to check
Returns
true The value is inside the range
false The value is not inside the range

◆ degenerate()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
bool Acts::RangeXD< Dims, Type, Vector >::degenerate ( ) const

Determine whether this range is degenerate.

A degenerate multi-dimensional range has no volume and cannot contain any values. This is the case if any of its dimensions are degenerate.

Returns
true The range is degenerate
false The range is not degenerate

◆ expand() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::expand ( const Type & min,
const Type & max )

Expand a range on both ends.

Expand a range by decreasing the minimum value as well as increasing the maximum value. If either of the values are already larger or smaller (respectively) than the proposed values, then that particular boundary of the interval is not expanded.

Note
After this operation, the range is always equal to or larger than [min, max].
Parameters
minThe proposed new minimum for the range
maxThe proposed new maximum for the range

◆ expand() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::expand ( std::size_t i,
const Type & min,
const Type & max )

Expand a range on both ends.

Expand a range by decreasing the minimum value as well as increasing the maximum value. If either of the values are already larger or smaller (respectively) than the proposed values, then that particular boundary of the interval is not expanded.

Note
After this operation, the range is always equal to or larger than [min, max].
Parameters
iThe index of the dimension to expand
minThe proposed new minimum for the range
maxThe proposed new maximum for the range

◆ expandMax() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::expandMax ( const Type & v)

Expand a range by increasing the maximum value.

Expand the range by increasing the maximum value. If the given value is smaller than the current maximum (in other words, if the proposed new range would be smaller than the current range), this is a no-op.

Parameters
vThe proposed new maximum for the range

◆ expandMax() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::expandMax ( std::size_t i,
const Type & v )

Expand a range by increasing the maximum value.

Expand the range by increasing the maximum value. If the given value is smaller than the current maximum (in other words, if the proposed new range would be smaller than the current range), this is a no-op.

Parameters
iThe index of the dimension to expand
vThe proposed new maximum for the range

◆ expandMin() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::expandMin ( const Type & v)

Methods for manipulating a range of dimension 1.

Expand a range by decreasing the minimum value

Expand the range by decreasing the minimum value. If the given value is larger than the current minimum (in other words, if the proposed new range would be smaller than the current range), this is a no-op.

Parameters
vThe proposed new minimum for the range

◆ expandMin() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::expandMin ( std::size_t i,
const Type & v )

Expand a range by decreasing the minimum value.

Expand the range by decreasing the minimum value. If the given value is larger than the current minimum (in other words, if the proposed new range would be smaller than the current range), this is a no-op.

Parameters
iThe index of the dimension to expand
vThe proposed new minimum for the range

◆ max() [1/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Type & Acts::RangeXD< Dims, Type, Vector >::max ( )

Return the maximum value of the range (inclusive).

Returns
Reference to the maximum value for modification

◆ max() [2/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Type Acts::RangeXD< Dims, Type, Vector >::max ( ) const

Return the maximum value of the range (inclusive).

Returns
The maximum value of the one-dimensional range

◆ max() [3/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Type & Acts::RangeXD< Dims, Type, Vector >::max ( std::size_t i)

Return the maximum value of the range i (inclusive).

Parameters
iThe index of the dimension to access
Returns
Reference to the maximum value for modification

◆ max() [4/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Type Acts::RangeXD< Dims, Type, Vector >::max ( std::size_t i) const

Return the maximum value of the range i (inclusive).

Parameters
iThe index of the dimension to access
Returns
The maximum value of the specified dimension

◆ min() [1/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Type & Acts::RangeXD< Dims, Type, Vector >::min ( )

Return the minimum value of the range (inclusive).

Returns
Reference to the minimum value for modification

◆ min() [2/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Type Acts::RangeXD< Dims, Type, Vector >::min ( ) const

Return the minimum value of the range (inclusive).

Returns
The minimum value of the one-dimensional range

◆ min() [3/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Type & Acts::RangeXD< Dims, Type, Vector >::min ( std::size_t i)

Return the minimum value of the range i (inclusive).

Parameters
iThe index of the dimension to access
Returns
Reference to the minimum value for modification

◆ min() [4/4]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Type Acts::RangeXD< Dims, Type, Vector >::min ( std::size_t i) const

Return the minimum value of the range i (inclusive).

Parameters
iThe index of the dimension to access
Returns
The minimum value of the specified dimension

◆ operator&()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
RangeXD< Dims, Type, Vector > Acts::RangeXD< Dims, Type, Vector >::operator& ( const RangeXD< Dims, Type, Vector > & o) const

Compute the intersection of this range with another range.

The intersection of one orthogonal range with another orthogonal range is in itself an orthogonal range. This operation is commutative. This intersection between two n-dimensional ranges is defined simply as the intersection in each dimension of the two ranges.

Parameters
oThe orthogonal range to compute the intersection with
Returns
The intersection between the ranges

◆ operator&&()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
bool Acts::RangeXD< Dims, Type, Vector >::operator&& ( const RangeXD< Dims, Type, Vector > & r) const

Determine whether this range intersects another.

Two n-dimensional ranges intersect if and only if they intersect in every one of their n dimensions. Otherwise, they are disjoint.

Parameters
rThe other range to check
Returns
true The ranges intersect
false The ranges do not intersect

◆ operator&=()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
RangeXD< Dims, Type, Vector > & Acts::RangeXD< Dims, Type, Vector >::operator&= ( const RangeXD< Dims, Type, Vector > & o)

Update the range to the intersection with another range.

This is the assignment version of the operator& method, meaning that it updates the object on which it is called rather than producing a new range.

Parameters
oThe range to compute the intersection with
Returns
This object

◆ operator<=()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
bool Acts::RangeXD< Dims, Type, Vector >::operator<= ( const RangeXD< Dims, Type, Vector > & o) const

Determine whether one range is a subset of another range.

One range is a subset of another range if and only if all points contained within the first set are also contained within the second set. Alternatively, this is equivalent to each of the first range's one-dimensional ranges being a subset of the second range's equivalent one-dimensional range.

Parameters
oThe other range to compare to
Returns
true The first range is a subset of the second range
false The first range is not a subset of the second range

◆ operator=()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
template<template< typename, std::size_t > typename V>
RangeXD & Acts::RangeXD< Dims, Type, Vector >::operator= ( const RangeXD< Dims, Type, V > & o)

Assignment operator.

Copy the right-hand range into the left-hand range, which means setting the minimum and maximum to equal the minimum and maximum of the right-hand side.

Parameters
oThe range of values to copy
Returns
This range

◆ operator==()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
bool Acts::RangeXD< Dims, Type, Vector >::operator== ( const RangeXD< Dims, Type, Vector > & o) const

Determine whether two ranges are equal.

Two n-dimensional ranges are equal if and only if they are equal in each of their n dimensions.

Parameters
oThe other range to check for equality
Returns
true The ranges are equal
false The ranges are not equal

◆ operator>=()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
bool Acts::RangeXD< Dims, Type, Vector >::operator>= ( const RangeXD< Dims, Type, Vector > & o) const

Determine whether one range is a superset of another range.

One range is a superset of another range if and only if all points contained within the second range are also contained within the first range. Alternatively, this is equivalent to each of the one-dimensional ranges in the first range being a superset of the corresponding one-dimensional range in the second range.

Parameters
oThe other range to compare to
Returns
true The left-hand range is a superset of the right-hand range
false The left-hand range is not a superset of the right-hand range

◆ operator[]() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
RangeXD< 1, Type, SingleElementContainer > Acts::RangeXD< Dims, Type, Vector >::operator[] ( const std::size_t & i)

Access one of the dimensional ranges of the volume.

Parameters
iThe index of the dimension to access
Returns
A reference to the dimension contained in this range

◆ operator[]() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
RangeXD< 1, Type > Acts::RangeXD< Dims, Type, Vector >::operator[] ( const std::size_t & i) const

Access one of the dimensional ranges of the volume.

Parameters
iThe index of the dimension to access
Returns
A reference to the dimension contained in this range

◆ set() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::set ( const Type & min,
const Type & max )

Set the minimum and maximum value.

Override both the minimum and maximum value of the range, regardless of what they were set to.

Note
If you want to shrink or expand the range, use the shrink and expand methods.
After this operation, the range should be exactly equal to [min, max]
Parameters
minThe new minimum value of the range
maxThe new maximum value of the range

◆ set() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::set ( std::size_t i,
const Type & min,
const Type & max )

Set the minimum and maximum value.

Override both the minimum and maximum value of the range, regardless of what they were set to.

Note
If you want to shrink or expand the range, use the shrink and expand methods.
After this operation, the range should be exactly equal to [min, max]
Parameters
iThe index of the dimension to set
minThe new minimum value of the range
maxThe new maximum value of the range

◆ setMax() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::setMax ( const Type & v)

Set the maximum value.

Override the maximum value of the range, regardless of what was already set.

Note
If you want to shrink or expand the range, use the shrink and expand methods.
Parameters
vThe value to use as the new maximum

◆ setMax() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::setMax ( std::size_t i,
const Type & v )

Set the maximum value.

Override the maximum value of the range, regardless of what was already set.

Note
If you want to shrink or expand the range, use the shrink and expand methods.
Parameters
iThe index of the dimension to set
vThe value to use as the new maximum

◆ setMin() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::setMin ( const Type & v)

Set the minimum value.

Override the minimum value of the range, regardless of what was already set.

Note
If you want to shrink or expand the range, use the shrink and expand methods.
Parameters
vThe value to use as the new minimum

◆ setMin() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::setMin ( std::size_t i,
const Type & v )

Set the minimum value.

Override the minimum value of the range, regardless of what was already set.

Note
If you want to shrink or expand the range, use the shrink and expand methods.
Parameters
iThe index of the dimension to set
vThe value to use as the new minimum

◆ shrink() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::shrink ( const Type & min,
const Type & max )

Shrink a range on both ends.

Shrink a range by increasing the minimum value as well as decreasing the maximum value. If either of the values are already smaller or larger (respectively) than the proposed values, then that particular boundary of the interval is not shrunk.

Note
After this operation, the range is always equal to or smaller than [min, max].
Parameters
minThe proposed new minimum for the range
maxThe proposed new maximum for the range

◆ shrink() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::shrink ( std::size_t i,
const Type & min,
const Type & max )

Shrink a range on both ends.

Shrink a range by increasing the minimum value as well as decreasing the maximum value. If either of the values are already smaller or larger (respectively) than the proposed values, then that particular boundary of the interval is not shrunk.

Note
After this operation, the range is always equal to or smaller than [min, max].
Parameters
iThe index of the dimension to shrink
minThe proposed new minimum for the range
maxThe proposed new maximum for the range

◆ shrinkMax() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::shrinkMax ( const Type & v)

Shrink a range by decreasing the maximum value.

Shrink the range by decreasing the maximum value. If the given value is larger than the current maximum (in other words, if the proposed new range would be larger than the current range), this is a no-op.

Parameters
vThe proposed new maximum for the range

◆ shrinkMax() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::shrinkMax ( std::size_t i,
const Type & v )

Shrink a range by decreasing the maximum value.

Shrink the range by decreasing the maximum value. If the given value is larger than the current maximum (in other words, if the proposed new range would be larger than the current range), this is a no-op.

Parameters
iThe index of the dimension to shrink
vThe proposed new maximum for the range

◆ shrinkMin() [1/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::shrinkMin ( const Type & v)

Shrink a range by increasing the minimum value.

Shrink the range by increasing the minimum value. If the given value is smaller than the current minimum (in other words, if the proposed new range would be larger than the current range), this is a no-op.

Parameters
vThe proposed new minimum for the range

◆ shrinkMin() [2/2]

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
void Acts::RangeXD< Dims, Type, Vector >::shrinkMin ( std::size_t i,
const Type & v )

Shrink a range by increasing the minimum value.

Shrink the range by increasing the minimum value. If the given value is smaller than the current minimum (in other words, if the proposed new range would be larger than the current range), this is a no-op.

Parameters
iThe index of the dimension to shrink
vThe proposed new minimum for the range

◆ size()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
Type Acts::RangeXD< Dims, Type, Vector >::size ( ) const

Compute the size of the range.

The size of a range is defined as the difference between the minimum and the maximum. For degenerate ranges, this is zero.

Warning
Due to the nature of numbers, the result of this function can be somewhat ambiguous. For natural numbers, you could argue that the range [n, n] has size 0 or size 1. In this case we say it has size 0. The uncountable nature of the reals means this doesn't matter for them, but this can be awkward when working with integers.
Returns
The size of the range

◆ toString()

template<std::size_t Dims, typename Type, template< typename, std::size_t > typename Vector = std::array>
std::string Acts::RangeXD< Dims, Type, Vector >::toString ( void ) const

Represent the range as a string.

This method produces a helpful string that can be used to debug the range if needed. Not really designed to be used in production code.

Returns
A string representing the range