|
Celeritas 0.7.0-dev.264+develop.12c52268
|
Test for being approximately a unit vector. More...
#include <ArraySoftUnit.hh>
Public Types | |
Type aliases | |
| using | value_type = T |
Public Member Functions | |
| ArraySoftUnit (value_type tol) | |
| Construct with explicit tolereance. | |
| constexpr | ArraySoftUnit () |
| Construct with default tolereance. | |
| template<::celeritas::size_type N> | |
| constexpr bool | operator() (Array< T, N > const &arr) const |
| Calculate whether the array is nearly a unit vector. | |
Test for being approximately a unit vector.
Consider a unit vector v with a small perturbation along a unit vector e :
\[ \vec v + \epsilon \vec e \]
The magnitude of this "nearly unit" is
\[ m^2 = (v + \epsilon e) \cdot (v + \epsilon e) = 1 + 2 (v \cdot e) \epsilon + \epsilon^2 \]
Since by the triangle inequality
\[ |v \cdot e| <= |v||e| = 1 \]
, then the magnitude squared of a perturbed unit vector is bounded
\[ m^2 = 1 \pm 2 \epsilon + \epsilon^2 \]
Instead of calculating the square of the tolerance we use \( \epsilon^2 < \epsilon \) to make the "soft unit vector" condition
\[ | \vec v \vd \vec v - 1 | < 3 \epsilon . \]
|
inlineconstexpr |
Calculate whether the array is nearly a unit vector.
The calculation below is equivalent to
.