Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::math Namespace Reference

Math functions and utilities. More...

Namespaces

namespace  constant
 
namespace  detail
 
namespace  radical_inverse_detail
 
namespace  spectral_data
 
namespace  table
 

Classes

class  BvhParams
 
class  ColorError
 Error on the color-related functionalities. More...
 
class  DefaultSpectralSampleProps
 
class  DeterministicSeeder
 Convenient thread-safe seed provider for RNGs. Do not use this for cryptography. More...
 
class  DynamicLinearTranslation
 
class  IndexedKdtreeParams
 
class  MathException
 General exception thrown on error related to math functionalities. More...
 
struct  Murmur3BitMixer32
 
class  Pcg32
 PCG-32 generator. This is the pcg32 generator in O'Neill's original pcg-cpp implementation. References: [1] https://dotat.at/@/2023-06-21-pcg64-dxsm.html [2] https://github.com/imneme/pcg-c-basic [3] https://github.com/wjakob/pcg32. More...
 
class  Pcg64DXSM
 PCG-64 DXSM generator. This is the pcg_engines::cm_setseq_dxsm_128_64 generator in O'Neill's original pcg-cpp implementation. References: [1] https://dotat.at/@/2023-06-21-pcg64-dxsm.html [2] NumPy source code (numpy/numpy/random/src/pcg64/*), version: 308b348bb595bc1b86f9e4bc08be2e3ba5d4f18f. More...
 
class  Random
 Get random values from default RNG. More...
 
class  Real
 
class  RigidTransform
 
class  StaticAffineTransform
 
class  StaticRigidTransform
 
class  TAABB2D
 A 2-D Axis-Aligned Bounding Box (AABB). More...
 
class  TAABB3D
 A 3-D Axis-Aligned Bounding Box (AABB). More...
 
class  TAnalyticalIntegrator1D
 
class  TArithmeticArray
 
class  TArithmeticArrayBase
 
class  TBasicTriangle
 Basic 3-D triangle functionalities. More...
 
class  TBinaryBvhNode
 
class  TBlackmanHarris2D
 Blackman-Harris window function. A window function similar to Gaussian function in shape. It is defined over \( \left[-radius, radius\right] \) and will take on value 0 at boundaries. The peak of the function is at \( (0, 0) \). More...
 
class  TBvhBuilder
 
class  TBvhInfoNode
 General BVH node packed with additional information. This node type is typically used for building other types of BVH or for algorithmic analysis. More...
 
class  TBvhItemInfo
 
class  TBvhSimdComputingContext
 A SIMD computing context for BVH. Use isSupported() to check the availability of the required hardware feature. More...
 
class  TChromaticAdaptationDefinition
 Sinkhole for undefined chromatic adaptation routines. Specialize the class to provide definitions for the specified adaptation configuration. Must satisfy CChromaticAdaptationDefinition. More...
 
class  TChromaticAdaptationDefinition< EChromaticAdaptation::Bradford, T >
 
class  TChromaticAdaptationDefinition< EChromaticAdaptation::VonKries, T >
 
class  TChromaticAdaptationDefinition< EChromaticAdaptation::XYZScaling, T >
 Adapts by simply scale by the corresponding white points–identity CAT matrices are used. More...
 
class  TChromaticAdaptationDefinitionHelper
 
class  TColorSpaceDefinition
 Sinkhole for color spaces without definition. Specialize this class to provide definitions for color space. Must satisfy CTristimulusColorSpaceDefinition or CSpectralColorSpaceDefinition. More...
 
class  TColorSpaceDefinition< EColorSpace::ACEScg, T >
 
class  TColorSpaceDefinition< EColorSpace::CIE_xyY, T >
 
class  TColorSpaceDefinition< EColorSpace::CIE_XYZ, T >
 
class  TColorSpaceDefinition< EColorSpace::Linear_sRGB, T >
 Linear sRGB color space definitions. More...
 
class  TColorSpaceDefinition< EColorSpace::Spectral_Smits, T >
 
class  TColorSpaceDefinition< EColorSpace::sRGB, T >
 
class  TColorSpaceDefinitionHelper
 
class  TConstant2D
 
class  TDecomposedTransform
 Perform affine transformations in decomposed form. More...
 
class  TDisk
 A 2-D disk with normal facing up (0, 1, 0). More...
 
class  TFraction
 
class  TGaussian2D
 
class  THeavisideStep2D
 A step function in 2-D, with a specific normal direction. This is a simplified version of general Heaviside step function in 2-D. This class represents 1-D Heaviside in 2-D, dividing the xy-plane into regions of value 0 & 1 (while a general Heaviside step function in 2-D can have the discontinuity along an arbitarary 2-D contour, this class does not support that). Value along the line of discontinuity is 0.5 (for integer types, this would be 0). More...
 
class  THemisphere
 A hemisphere in 3-D space. More...
 
struct  TIndexedItemEndpoint
 
class  TIndexedKdtree
 
class  TIndexedKdtreeNode
 An indexed kD-tree node with compacted memory layout. More...
 
class  TIndexedPointKdtree
 
class  TIndexedVector3
 
class  TLinearDepthFirstBinaryBvh
 
class  TLinearDepthFirstWideBvh
 
class  TLinearGradient2D
 A linearly increasing/decreasing gradient in a specific direction. Value at (0, 0) is 0. More...
 
class  TLineSegment
 Represents a line segment in space. More...
 
class  TMathFunction2D
 
class  TMatrix2
 Represents a 2x2 matrix. More...
 
class  TMatrix3
 Represents a 3x3 matrix. More...
 
class  TMatrix4
 Represents a 4x4 matrix. More...
 
class  TMatrixMxNBase
 A base for general M by N row-major matrices. More...
 
class  TMatrixNBase
 A base for general N dimensional row-major square matrices. More...
 
class  TMitchellNetravaliCubic2D
 Mitchell–Netravali filter function [13]. More...
 
class  TMt19937
 Standard Mersenne Twister generator. More...
 
class  TOrthonormalBasis3
 Represents a set of orthonormal basis vectors in 3-D space. More...
 
class  TPiecewiseLinear1D
 
class  TPwcDistribution1D
 A 1-D piecewise constant distribution of floating-point type T. The sample weights can be seen as a histogram, and samples are drawn according to each column's relative heights. Each generated sample is guaranteed to have a non-zero PDF. More...
 
class  TPwcDistribution2D
 
class  TQuaternion
 Represents a quaternion. More...
 
class  Transform
 
class  TSampledSpectrum
 
class  TSpectralColorSpaceDefinitionHelper
 
class  TSpectrumBase
 Base for spectrum implementations. More...
 
class  TSphere
 A sphere in 3-D space. More...
 
class  TTriangle
 
class  TTristimulusColorSpaceDefinitionHelper
 
class  TTristimulusSpectrum
 
class  TUniformRandomBitGenerator
 
class  TUrbg32x2
 Combining two 32-bit RNGs to form a new 64-bit RNG. If any of the input RNG is not a 32-bit type, this generator will treat it as a 32-bit RNG (e.g., by converting its generated bits to 32-bit). More...
 
class  TVector2
 Represents a 2-D vector. More...
 
class  TVector3
 Represents a 3-D vector. More...
 
class  TVector4
 Represents a 4-D vector. More...
 
class  TVectorN
 
class  TVectorNBase
 
class  TWatertightTriangle
 
class  TWideBvhNode
 

Concepts

concept  CItemSegmentIntersectionTesterVanilla
 
concept  CItemSegmentIntersectionTesterWithIndex
 
concept  CItemSegmentIntersectionTester
 
concept  CIndexedPointKdtreeItemStorage
 
concept  CChromaticAdaptationDefinition
 
concept  CSpectralSampleProps
 
concept  CColorValuesInterface
 Satisfying this concept makes ImplType usable as color values.
 
concept  CRawColorValues
 Whether ColorValuesType is a raw color values type.
 
concept  CHasColorSpaceProperties
 Basic requirements for a color space definition.
 
concept  CSupportsTristimulusConversions
 Basic requirements a tristimulus color space definition must satisfy in addition to CHasColorSpaceProperties.
 
concept  CSupportsSpectralConversions
 Basic requirements a spectral color space definition must satisfy in addition to CHasColorSpaceProperties. Bound tristimulus color space: A spectral color space must choose a tristimulus color space as its binding space, which will be used by color space operations that cannot operate in the spectral space. The chosen color space is often referred to as "bound space" for simplicity.
 
concept  CTristimulusColorSpaceDefinition
 
concept  CSpectralColorSpaceDefinition
 
concept  CColorSpaceDefinition
 
concept  CURBG
 

Typedefs

using ColorValue = real
 
template<typename T , std::size_t N>
using TRawColorValues = std::array<T, N>
 
template<typename T >
using TTristimulusValues = TRawColorValues<T, 3>
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
using TSpectralSampleValues = TRawColorValues<T, SampleProps::NUM_SAMPLES>
 
template<typename T >
using TChromaticityValues = TRawColorValues<T, 2>
 
using TristimulusValues = TTristimulusValues<ColorValue>
 
using SpectralSampleValues = TSpectralSampleValues<ColorValue>
 
using ChromaticityValues = TChromaticityValues<ColorValue>
 
template<EColorSpace COLOR_SPACE>
using TColorSpaceDef = TColorSpaceDefinition<COLOR_SPACE, ColorValue>
 Helper alias for TColorSpaceDefinition which uses the ColorValue type.
 
using LinearSRGBSpectrum = TTristimulusSpectrum<EColorSpace::Linear_sRGB, ColorValue>
 
using ACESSpectrum = TTristimulusSpectrum<EColorSpace::ACEScg, ColorValue>
 
using SampledSpectrum
 
using Spectrum = LinearSRGBSpectrum
 
template<typename T , std::size_t N>
using TRawRowVector = std::array<T, N>
 
template<typename T , std::size_t M>
using TRawColVector = std::array<T, M>
 
template<typename T , std::size_t M, std::size_t N>
using TRawMatrix = std::array<std::array<T, N>, M>
 
using AABB2D = TAABB2D<real>
 
using AABB3D = TAABB3D<real>
 
using Vector2I = TVector2<int32>
 
using Vector2UI = TVector2<uint32>
 
using Vector2R = TVector2<real>
 
using Vector2F = TVector2<float32>
 
using Vector2D = TVector2<float64>
 
using Vector2S = TVector2<std::size_t>
 
using Vector3I = TVector3<int32>
 
using Vector3UI = TVector3<uint32>
 
using Vector3R = TVector3<real>
 
using Vector3F = TVector3<float32>
 
using Vector3D = TVector3<float64>
 
using Vector3S = TVector3<std::size_t>
 
using Vector4R = TVector4<real>
 
using Vector4F = TVector4<float32>
 
using Vector4D = TVector4<float64>
 
using Vector4S = TVector4<std::size_t>
 
using QuaternionR = TQuaternion<real>
 
using QuaternionF = TQuaternion<float32>
 
using QuaternionD = TQuaternion<float64>
 
using Matrix2R = TMatrix2<real>
 
using Matrix2F = TMatrix2<float32>
 
using Matrix2D = TMatrix2<float64>
 
using Matrix3R = TMatrix3<real>
 
using Matrix3F = TMatrix3<float32>
 
using Matrix3D = TMatrix3<float64>
 
using Matrix4R = TMatrix4<real>
 
using Matrix4F = TMatrix4<float32>
 
using Matrix4D = TMatrix4<float64>
 
using Basis3R = TOrthonormalBasis3<real>
 
using Basis3F = TOrthonormalBasis3<float32>
 
using Basis3D = TOrthonormalBasis3<float64>
 

Enumerations

enum class  EBvhNodeSplitMethod {
  EqualItems , EqualIntervals , SAH_Buckets_OneAxis , SAH_Buckets_MultiAxis ,
  SAH_EdgeSort_OneAxis
}
 
enum class  EBvhSplitAxisOrder : uint8f { Unbalanced , Balanced , BalancedPow2 , Single }
 
enum class  EEndpoint { MIN , MAX }
 
enum class  EColorSpace {
  Unspecified = 0 , CIE_XYZ , CIE_xyY , Linear_sRGB ,
  sRGB , ACEScg , Spectral_Smits , NUM ,
  Spectral = Spectral_Smits
}
 
enum class  EReferenceWhite {
  Unspecified = 0 , A , B , C ,
  D50 , D55 , D60 , D65 ,
  D75 , E , F1 , F2 ,
  F3 , F4 , F5 , F6 ,
  F7 , F8 , F9 , F10 ,
  F11 , F12 , LED_B1 , LED_B2 ,
  LED_B3 , LED_B4 , LED_B5 , LED_BH1 ,
  LED_RGB1 , LED_V1 , LED_V2 , ACES ,
  NUM
}
 
enum class  EChromaticAdaptation {
  Unspecified = 0 , XYZScaling , Bradford , VonKries ,
  Default = Bradford
}
 Methods to map image appearance between different illumination sources. This kind of mapping is commonly called Chromatic Adaptation Transform (CAT). More...
 
enum class  EColorUsage { Unspecified = 0 , Raw , EMR , ECF }
 
enum class  ESpectralResample { Unspecified = 0 , PiecewiseAveraged , Default = PiecewiseAveraged }
 

Functions

template<std::size_t N, typename Index >
class ph::math::TBvhSimdComputingContext sizeof (float32) *BATCH_SIZE >
 
template<EChromaticAdaptation ALGORITHM, typename T >
TTristimulusValues< T > chromatic_adapt (const TTristimulusValues< T > &srcCIEXYZColor, EReferenceWhite srcRefWhite, EReferenceWhite dstRefWhite)
 
template<typename T >
TMatrix3< T > create_von_kries_linear_CAT_matrix (const TMatrix3< T > &CIEXYZToConeResponse, const TMatrix3< T > &ConeResponseToCIEXYZ, const EReferenceWhite srcRefWhite, const EReferenceWhite dstRefWhite)
 
template<typename T >
TMatrix3< T > create_von_kries_linear_CAT_matrix (const TMatrix3< T > &CIEXYZToConeResponse, const TMatrix3< T > &ConeResponseToCIEXYZ, const TTristimulusValues< T > &srcRefWhite, const TTristimulusValues< T > &dstRefWhite)
 
template<typename T = ColorValue>
TChromaticityValues< T > chromaticity_of (const EReferenceWhite refWhite)
 
template<typename T = ColorValue>
TTristimulusValues< T > CIEXYZ_of_custom_reference_white (const TChromaticityValues< T > &refWhite)
 
template<typename T = ColorValue>
TTristimulusValues< T > CIEXYZ_of (const EReferenceWhite refWhite)
 
bool is_tristimulus (EColorSpace colorSpace)
 Check whether colorSpace is a tristimulus color space. This is a runtime check. For compile-time check, use TColorSpaceDef<?>::isTristimulus().
 
template<typename InColorValuesType , EColorSpace COLOR_SPACE>
constexpr bool is_compatible ()
 Check whether InColorValuesType is suitable to represent values in COLOR_SPACE.
 
template<EColorSpace SRC_COLOR_SPACE, EColorSpace DST_COLOR_SPACE, typename T , EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
auto transform_color (const auto &srcColorValues, EColorUsage usage)
 
template<EColorSpace SRC_COLOR_SPACE, typename T , EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
relative_luminance (const auto &srcColorValues, EColorUsage usage=EColorUsage::EMR)
 
template<EColorSpace SRC_COLOR_SPACE, typename T , EColorSpace SPECTRAL_COLOR_SPACE = EColorSpace::Spectral, EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
estimate_color_energy (const auto &srcColorValues)
 
template<EColorSpace SRC_COLOR_SPACE, typename T , EColorSpace SPECTRAL_COLOR_SPACE = EColorSpace::Spectral, EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
auto normalize_color_energy (const auto &srcColorValues)
 
template<EColorSpace SRC_COLOR_SPACE, typename T , EColorSpace SPECTRAL_COLOR_SPACE = EColorSpace::Spectral, EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
auto put_color_energy (const auto &srcColorValues, T energyLevel)
 
template<typename T >
TTristimulusValues< T > sRGB_nonlinear_to_linear (const TTristimulusValues< T > &nonlinearSRGB)
 Helper for converting from sRGB to linear-sRGB.
 
template<typename T >
TTristimulusValues< T > sRGB_linear_to_nonlinear (const TTristimulusValues< T > &linearSRGB)
 Helper for converting from linear-sRGB to sRGB.
 
template<EColorSpace DST_COLOR_SPACE, typename T >
auto transform_from_sRGB (const TTristimulusValues< T > &nonlinearSRGB, EColorUsage usage)
 Helper for converting from sRGB to any color space.
 
template<EColorSpace DST_COLOR_SPACE, typename T >
auto transform_from_linear_sRGB (const TTristimulusValues< T > &linearSRGB, EColorUsage usage)
 Helper for converting from linear-sRGB to any color space.
 
template<EColorSpace SRC_COLOR_SPACE, typename T >
TTristimulusValues< T > transform_to_sRGB (const auto &srcColorValues, EColorUsage usage)
 Helper for converting any color space to sRGB.
 
template<EColorSpace SRC_COLOR_SPACE, typename T >
TTristimulusValues< T > transform_to_linear_sRGB (const auto &srcColorValues, EColorUsage usage)
 Helper for converting any color space to linear-sRGB.
 
template<typename T , CSpectralSampleProps SampleProps>
constexprwavelength_interval_of () noexcept
 
template<typename T , CSpectralSampleProps SampleProps>
constexpr std::pair< T, T > wavelength_range_of (std::size_t sampleIndex) noexcept
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
estimate_samples_energy (const TSpectralSampleValues< T, SampleProps > &srcSamples)
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > normalize_samples_energy (const TSpectralSampleValues< T, SampleProps > &srcSamples)
 Normalize spectral samples as if they carry energy. Normalized spectral samples, together, represents the expected amount of energy that 1 unit of total energy would distribute on each wavelength interval (implying that the samples should sum to 1).
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
constexpr TSpectralSampleValues< T, SampleProps > constant_spectral_samples (T constant)
 
template<typename T , typename U , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > resample_spectral_samples (const U *wavelengthsNM, const U *values, std::size_t numPoints, ESpectralResample algorithm=ESpectralResample::Default)
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > resample_black_body (T temperatureK)
 SPD of black-body radiation, with total energy = 1.
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > resample_black_body_radiance (T temperatureK)
 SPD of black-body radiation in radiance. If a normalized energy distribution is desired, use resample_black_body().
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > resample_black_body_spectral_radiance (T temperatureK)
 SPD of black-body radiation in spectral radiance. Note that this function is not returning radiance but spectral radiance. The returned spectral radiance has the unit of watt per steradian per square meter per meter (W * sr^-1 * m^-2 * m^-1). If radiance is desired, use resample_black_body_radiance(). If a normalized energy distribution is desired, use resample_black_body().
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps, EReferenceWhite NORMALIZER = EReferenceWhite::D65>
TTristimulusValues< T > spectral_samples_to_CIE_XYZ (const TSpectralSampleValues< T, SampleProps > &srcSamples, EColorUsage usage)
 Converting spectral samples to CIE-XYZ using standard CMFs.
 
template<typename T , CSpectralSampleProps SampleProps>
constexpr auto wavelength_range_of (const std::size_t sampleIndex) noexcept -> std::pair< T, T >
 
template<typename T >
TVector2< T > octahedron_unit_vector_encode (const TVector3< T > &unitVec)
 Encode a unit vector using octahedron projection.
 
template<typename T >
TVector3< T > octahedron_unit_vector_decode (const TVector2< T > &encodedVal)
 Decode and get a unit vector using octahedron projection.
 
template<typename T >
TVector2< T > sun_sky_phi_theta (const T solarTime24H, const T julianDate, const T siteLatitudeRadians)
 Locate spherical coordinates of the sun in sky.
 
template<typename Integer >
std::size_t discrete_spatial_hash (Integer x, Integer y, Integer z, std::size_t hashTableSize)
 
template<typename Integer >
std::size_t discrete_spatial_hash (Integer x, Integer y, std::size_t hashTableSize)
 
template<std::integral T>
std::size_t discrete_spatial_hash (const TVector3< T > &point, std::size_t hashTableSize)
 
template<std::floating_point T>
std::size_t discrete_spatial_hash (const TVector3< T > &point, const TVector3< T > &cellSize, std::size_t hashTableSize)
 
uint32 murmur3_bit_mix_32 (uint32 v)
 MurmurHash3's bit mixer. 32-bit version.
 
uint64 murmur3_bit_mix_64 (uint64 v)
 MurmurHash3's bit mixer. 64-bit version.
 
uint64 murmur3_v13_bit_mix_64 (uint64 v)
 MurmurHash3's bit mixer. 64-bit version.
 
uint64 moremur_bit_mix_64 (uint64 v)
 A MurmurHash3-style bit mixer that outperforms the original by quite some margin. 64-bit version.
 
template<typename T , typename BitMixerType = Murmur3BitMixer32>
uint32 murmur3_32 (const T &data, uint32 seed)
 Generate 32-bit hash values using MurmurHash3. Note that there are no collisions when T has <= 32 bits (two distinct inputs will not result in the same output). In general, if there is a way to reverse a function (reversing murmur3_32() is possible), it is guaranteed there cannot be any collisions. Otherwise, it would not be possible to revert.
 
template<typename T , typename BitMixerType >
uint32 murmur3_32 (const T *data, std::size_t dataSize, BitMixerType &&bitMixer, uint32 seed)
 Generate 32-bit hash values using MurmurHash3. This is a lower level variant of MurmurHash3 and can be useful for customizing its behavior, e.g., it can accept arbitrary BitMixerType without requiring it to be default constructible.
 
uint32 permuted_index (uint32 i, uint32 l, uint32 p)
 Get the permuted index or value in O(1) space and O(1) time.
 
void form_orthonormal_basis_frisvad (const Vector3R &unitYaxis, Vector3R *const out_unitXaxis, Vector3R *const out_unitZaxis)
 
bool is_same_hemisphere (const Vector3R &vector, const Vector3R &N)
 Checks whether the specified vector is within the hemisphere defined by the normal vector N. N points to the hemisphere's peak, i.e., theta = 0 in spherical coordinates.
 
bool is_opposite_hemisphere (const Vector3R &vector, const Vector3R &N)
 Checks whether the specified vector is within the hemisphere defined by the normal vector -N. N points to the hemisphere's peak, i.e., theta = 0 in spherical coordinates.
 
template<typename T >
auto matrix2x2 (const T e00, const T e01, const T e10, const T e11) -> std::array< std::array< T, 2 >, 2 >
 
template<typename T >
squared (const T value)
 
template<typename T >
clamp (const T value, const T lowerBound, const T upperBound)
 Clamps a value to [lowerBound, upperBound]. None of value, lowerBound and upperBound can be NaN, or the method's behavior is undefined.
 
template<typename T >
safe_clamp (const T value, const T lowerBound, const T upperBound)
 Clamps a value to [lowerBound, upperBound], fallback to lowerBound. If a floating-point value is non-finite (e.g., being Inf, NaN), its value is clamped to lowerBound. Neither lowerBound nor upperBound can be NaN, or the method's behavior is undefined.
 
template<typename T >
safe_rcp (const T value)
 Calculates the reciprocal of a value, fallback to 0. If the resulting reciprocal is non-finite (e.g., being Inf, NaN), 0 will be returned instead.
 
template<typename T >
to_degrees (const T radians)
 Convert radians to degrees.
 
template<typename T >
to_radians (const T degrees)
 Convert degrees to radians.
 
template<typename T >
int sign (const T value)
 Extract the sign of value.
 
uint32 next_power_of_2 (uint32 value)
 Gets the minimum power of 2 value that is >= value.
 
template<typename T >
log2_floor (const T value)
 Calculate a positive number's base 2 logarithm (floored).
 
template<typename T , std::enable_if_t< std::is_floating_point_v< T >, int > = 0>
fractional_part (const T value)
 Retrieve the fractional part of value (with the sign unchanged). The result is not guaranteed to be the same as the bit representation of 's fractional part. The result is undefined if input value is NaN or +-Inf.
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
wrap (T value, const T lowerBound, const T upperBound)
 Wraps an integer around [lower-bound, upper-bound]. For example, given a bound [-1, 2], 3 will be wrapped to -1.
 
template<typename T >
bool is_even (const T value)
 Checks if a number is even.
 
template<typename T >
bool is_odd (const T value)
 Checks if a number is odd.
 
template<typename NumberType >
constexpr NumberType bytes_to_KiB (const std::size_t numBytes)
 
template<typename NumberType >
constexpr NumberType bytes_to_MiB (const std::size_t numBytes)
 
template<typename NumberType >
constexpr NumberType bytes_to_GiB (const std::size_t numBytes)
 
template<typename NumberType >
constexpr NumberType bytes_to_TiB (const std::size_t numBytes)
 
template<typename NumberType >
constexpr NumberType bytes_to_PiB (const std::size_t numBytes)
 
std::pair< std::size_t, std::size_t > ith_evenly_divided_range (const std::size_t rangeIndex, const std::size_t totalSize, const std::size_t numDivisions)
 Gets the i-th evenly divided range.
 
float fast_rcp_sqrt (float x)
 Computes 1/sqrt(x) in a fast but approximative way.
 
float fast_sqrt (const float x)
 Computes sqrt(x) in a fast but approximative way.
 
template<typename T , typename = std::enable_if_t<std::is_integral_v<T>>>
reverse_bits (const T value)
 Get an integral value with reversed bits.
 
template<std::unsigned_integral UIntType, std::integral RangeType>
UIntType set_bits_in_range (const UIntType bits, const RangeType beginBitIdx, const RangeType endBitIdx)
 Set bits in the range to 1. The bits in [beginBitIdx, endBitIdx) will be set to 1, while the rest remain the same. LSB has the bit index 0.
 
template<std::unsigned_integral UIntType, std::integral RangeType>
UIntType clear_bits_in_range (const UIntType bits, const RangeType beginBitIdx, const RangeType endBitIdx)
 Set bits in the range to 0. The bits in [beginBitIdx, endBitIdx) will be set to 0, while the rest remain the same. LSB has the bit index 0.
 
template<typename T , T MIN, T MAX, std::size_t N>
std::array< T, N > evenly_spaced_array ()
 
template<typename T >
std::vector< T > evenly_spaced_vector (const T min, const T max, const std::size_t n)
 
template<std::floating_point FloatType, std::integral IntType>
FloatType normalize_integer (const IntType intVal)
 Transform an integer to the range [0, 1] ([-1, 1] for signed integer). When transforming an unsigned integer, the minimum value the integer can hold will be mapped to 0, while the maximum value will be mapped to 1; the rest of the integer values will be uniformally mapped to the range [0, 1]. Signed integer types follow the same rule, except the mapped range will be [-1, 1].
 
template<std::integral IntType, std::floating_point FloatType>
IntType quantize_normalized_float (const FloatType floatVal)
 
void uint64_mul (const uint64 lhs, const uint64 rhs, uint64 &out_high64, uint64 &out_low64)
 Multiply two unsigined 64-bit numbers and get a 128-bit result.
 
template<typename T >
black_body_spectral_radiance_at (const T temperatureK, const T wavelengthNM)
 Get Black-body spectral radiance at specific temperature and wavelength. Note that this function is not returning radiance but spectral radiance. The returned spectral radiance has the unit of watt per steradian per square meter per meter (W * sr^-1 * m^-2 * m^-1).
 
template<typename T >
std::vector< T > black_body_spectral_radiance_curve (const T temperatureK, const T lambdaMinNM, const T lambdaMaxNM, const std::size_t numCurvePoints, std::vector< T > *const out_lambdaValues=nullptr)
 Get a curve for Black-body radiation. Note that this function is not returning radiance but spectral radiance. The returned spectral radiance has the unit of watt per steradian per square meter per meter (W * sr^-1 * m^-2 * m^-1).
 
template<auto BASE, std::floating_point Result, std::integral Value>
Result radical_inverse (const Value value)
 Compute radical inverse of a value.
 
template<auto BASE, std::floating_point Result, std::integral Value, typename DigitPermuter >
Result radical_inverse_permuted (const Value dimIndex, const Value value, DigitPermuter permuter)
 Same as radical_inverse(), with permutation ability. It is guaranteed that no more than radical_inverse_detail::num_meaningful_digits() digits will be processed during the radical inverse.
 
template<typename To , typename From , std::size_t N>
std::array< To, N > sample_cast (const std::array< From, N > &sample)
 
template<typename T >
bool pick (const T pickProbability, const T sample)
 Randomly pick a branch with some probability.
 
template<typename T >
bool reused_pick (const T pickProbability, T &sample)
 
template<typename T , typename BitsType >
bits_to_sample (const BitsType &bits)
 Converts input bits to a sample. For standard unsigned integral types, this is effectively normalizing the integer value represented by bits into the range [0, 1].
 
template<typename IndexPairConsumer >
void shuffle_durstenfeld_index_pairs (const std::size_t beginIndex, const std::size_t endIndex, IndexPairConsumer consumer)
 
template<typename RandomIterator , typename Swapper = detail::shuffle::StandardSwapper<typename std::iterator_traits<RandomIterator>::value_type>>
void shuffle_durstenfeld (RandomIterator begin, RandomIterator end, Swapper swapper=Swapper())
 
template<typename TimeType , typename UnitType >
auto duration_to_HMS (const std::chrono::duration< TimeType, UnitType > &totalTime) -> std::array< TimeType, 3 >
 
template<typename TimeType >
auto milliseconds_to_HMS (const TimeType &totalTime) -> std::array< TimeType, 3 >
 
template<typename TimeType >
auto seconds_to_HMS (const TimeType &totalSeconds) -> std::array< TimeType, 3 >
 
template<typename T >
mean_solar_time_to_solar_time_24H (const T standardTime24H, const T standardMeridianRadians, const T siteLongitudeRadians, const T julianDate)
 Convert mean solar time to solar time.
 
 PH_DEFINE_EXTERNAL_LOG_GROUP (StaticRigidTransform, Math)
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > resample_illuminant_E ()
 SPD of standard illuminants. Any light source which statistically has the same relative SPD as a standard illuminant can be considered a standard light source, and is the reason why the SPD resample functions return a energy-normalized SPD (for convenience, as this is what you want almost always).
 
template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > resample_illuminant_D65 ()
 SPD of standard illuminants D65, with total energy = 1.
 
template<typename T , std::size_t N>
summation (const std::array< T, N > &values, T initialValue=0)
 Sum all values within a container together.
 
template<typename T >
summation (const std::vector< T > &values, T initialValue=0)
 
template<typename T , std::size_t EXTENT = std::dynamic_extent>
summation (TSpanView< T, EXTENT > values, T initialValue=0)
 
template<typename T , std::size_t N>
product (const std::array< T, N > &values, T initialValue=1)
 Multiplies all values within a container together.
 
template<typename T >
product (const std::vector< T > &values, T initialValue=1)
 
template<typename T , std::size_t EXTENT = std::dynamic_extent>
product (TSpanView< T, EXTENT > values, T initialValue=1)
 
template<std::unsigned_integral UIntType>
UIntType flag_bit (const UIntType bitIdx)
 Set a single bit to 1, others remain 0. LSB has the bit index 0.
 
template<std::unsigned_integral UIntType, UIntType BIT_IDX>
consteval UIntType flag_bit ()
 
uint16 fp32_to_fp16_bits (const float32 value)
 Convert a 32-bit float to 16-bit representation.
 
float32 fp16_bits_to_fp32 (const uint16 fp16Bits)
 Convert a 16-bit representation back to 32-bit float.
 
template<typename T , std::size_t N>
length (const std::array< T, N > &vec)
 Treating input values as a vector and calculates its length.
 
template<typename T >
length (const std::vector< T > &vec)
 
template<typename T , std::size_t EXTENT = std::dynamic_extent>
length (TSpanView< T, EXTENT > vec)
 
template<typename T , std::size_t N>
length_squared (const std::array< T, N > &vec)
 Treating input values as a vector and calculates its squared length.
 
template<typename T >
length_squared (const std::vector< T > &vec)
 
template<typename T , std::size_t EXTENT = std::dynamic_extent>
length_squared (TSpanView< T, EXTENT > vec)
 
template<typename T , std::size_t N>
p_norm (const std::array< T, N > &vec)
 Treating input values as a vector and calculates its p-norm.
 
template<typename T >
p_norm (const std::vector< T > &vec)
 
template<std::size_t P, typename T , std::size_t EXTENT = std::dynamic_extent>
p_norm (TSpanView< T, EXTENT > vec)
 
template<typename T , std::size_t N>
void normalize (std::array< T, N > &vec)
 Treating input values as a vector and normalize it. Notice that normalizing a integer typed vector will result in 0-vector most of the time.
 
template<typename T >
void normalize (std::vector< T > &vec)
 
template<typename T , std::size_t EXTENT = std::dynamic_extent>
void normalize (TSpan< T, EXTENT > vec)
 
template<typename T , std::size_t N>
dot_product (const std::array< T, N > &vecA, const std::array< T, N > &vecB)
 Treating input values as vectors and calculates their dot product.
 
template<typename T >
dot_product (const std::vector< T > &vecA, const std::vector< T > &vecB)
 
template<typename T , std::size_t EXTENT = std::dynamic_extent>
dot_product (TSpanView< T, EXTENT > vecA, TSpanView< T, EXTENT > vecB)
 

Variables

class ph::math::TBvhSimdComputingContext MaskType
 
class ph::math::TBvhSimdComputingContextBATCH_SIZE
 

Detailed Description

Math functions and utilities.

Typedef Documentation

◆ AABB2D

using ph::math::AABB2D = TAABB2D<real>

◆ AABB3D

using ph::math::AABB3D = TAABB3D<real>

◆ ACESSpectrum

◆ Basis3D

◆ Basis3F

◆ Basis3R

◆ ChromaticityValues

◆ ColorValue

using ph::math::ColorValue = real

◆ LinearSRGBSpectrum

◆ Matrix2D

using ph::math::Matrix2D = TMatrix2<float64>

◆ Matrix2F

using ph::math::Matrix2F = TMatrix2<float32>

◆ Matrix2R

◆ Matrix3D

using ph::math::Matrix3D = TMatrix3<float64>

◆ Matrix3F

using ph::math::Matrix3F = TMatrix3<float32>

◆ Matrix3R

◆ Matrix4D

using ph::math::Matrix4D = TMatrix4<float64>

◆ Matrix4F

using ph::math::Matrix4F = TMatrix4<float32>

◆ Matrix4R

◆ QuaternionD

◆ QuaternionF

◆ QuaternionR

◆ SampledSpectrum

Initial value:
TSampledSpectrum<
EColorSpace::Spectral,
DefaultSpectralSampleProps>
real ColorValue
Definition color_basics.h:42

◆ SpectralSampleValues

◆ Spectrum

◆ TChromaticityValues

template<typename T >
using ph::math::TChromaticityValues = TRawColorValues<T, 2>

◆ TColorSpaceDef

template<EColorSpace COLOR_SPACE>
using ph::math::TColorSpaceDef = TColorSpaceDefinition<COLOR_SPACE, ColorValue>

Helper alias for TColorSpaceDefinition which uses the ColorValue type.

◆ TRawColorValues

template<typename T , std::size_t N>
using ph::math::TRawColorValues = std::array<T, N>

◆ TRawColVector

template<typename T , std::size_t M>
using ph::math::TRawColVector = std::array<T, M>

◆ TRawMatrix

template<typename T , std::size_t M, std::size_t N>
using ph::math::TRawMatrix = std::array<std::array<T, N>, M>

◆ TRawRowVector

template<typename T , std::size_t N>
using ph::math::TRawRowVector = std::array<T, N>

◆ TristimulusValues

◆ TSpectralSampleValues

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
using ph::math::TSpectralSampleValues = TRawColorValues<T, SampleProps::NUM_SAMPLES>

Properties of spectral sample values (such as wavelength range) are specified in SampleProps.

◆ TTristimulusValues

template<typename T >
using ph::math::TTristimulusValues = TRawColorValues<T, 3>

◆ Vector2D

using ph::math::Vector2D = TVector2<float64>

◆ Vector2F

using ph::math::Vector2F = TVector2<float32>

◆ Vector2I

using ph::math::Vector2I = TVector2<int32>

◆ Vector2R

◆ Vector2S

using ph::math::Vector2S = TVector2<std::size_t>

◆ Vector2UI

using ph::math::Vector2UI = TVector2<uint32>

◆ Vector3D

using ph::math::Vector3D = TVector3<float64>

◆ Vector3F

using ph::math::Vector3F = TVector3<float32>

◆ Vector3I

using ph::math::Vector3I = TVector3<int32>

◆ Vector3R

◆ Vector3S

using ph::math::Vector3S = TVector3<std::size_t>

◆ Vector3UI

using ph::math::Vector3UI = TVector3<uint32>

◆ Vector4D

using ph::math::Vector4D = TVector4<float64>

◆ Vector4F

using ph::math::Vector4F = TVector4<float32>

◆ Vector4R

◆ Vector4S

using ph::math::Vector4S = TVector4<std::size_t>

Enumeration Type Documentation

◆ EBvhNodeSplitMethod

enum class ph::math::EBvhNodeSplitMethod
strong
Enumerator
EqualItems 
EqualIntervals 
SAH_Buckets_OneAxis 
SAH_Buckets_MultiAxis 
SAH_EdgeSort_OneAxis 

◆ EBvhSplitAxisOrder

enum class ph::math::EBvhSplitAxisOrder : uint8f
strong
Enumerator
Unbalanced 

As the unbalanced split axes described in [7].

Balanced 

As the balanced split axes described in [7].

BalancedPow2 

Power-of-2 special case of Balanced.

Single 

Child nodes are split according to a single axis. This is basically a generalization of the binary case to N-wide case.

◆ EChromaticAdaptation

enum class ph::math::EChromaticAdaptation
strong

Methods to map image appearance between different illumination sources. This kind of mapping is commonly called Chromatic Adaptation Transform (CAT).

Enumerator
Unspecified 
XYZScaling 

The most simple transform. Generally considered to be an inferior CAT.

Bradford 

Adobe uses this CAT in all of their products according to many sources.

VonKries 
Default 

◆ EColorSpace

enum class ph::math::EColorSpace
strong
Enumerator
Unspecified 

If applicable, most likely will treat values as raw data or fallback to linear sRGB. Will result in error if used in a non-applicable situation.

CIE_XYZ 

The CIE 1931 color space that many color spaces based on.

CIE_xyY 

The CIE xyY color space.

Linear_sRGB 

Linearized version of sRGB.

sRGB 

The good old sRGB color space.

ACEScg 

A color space proposed by the AMPAS and they recommended it for rendering and compositing.

Spectral_Smits 

Using spectral values as a color space, and performing down-sample (e.g., spectral to tristimulus) and up-sample (e.g., tristimulus to spectral) operations with Smit's method.

NUM 

Number of entries (should always be the one next to last entry).

Spectral 

Default spectral representation. Also for general spectral representation that does not want to be tied to a specific spectral color space.

◆ EColorUsage

enum class ph::math::EColorUsage
strong

These can be considered as hints that can be specified while converting data between color spaces. Specifying a hint to a method may result in better-converted data depending on the implementation.

Enumerator
Unspecified 
Raw 

Raw numeric data such as position, normal, density information.

EMR 

EMR stands for ElectroMagnetic Radiation, used by energy emitters such as light sources.

ECF 

ECF stands for Energy Conservative Fraction; surface albedo, reflectance, transmittance... are all ECFs. It is required that an ECF have value within [0, 1].

◆ EEndpoint

enum class ph::math::EEndpoint
strong
Enumerator
MIN 
MAX 

◆ EReferenceWhite

enum class ph::math::EReferenceWhite
strong
Enumerator
Unspecified 
D50 
D55 
D60 
D65 
D75 
F1 
F2 
F3 
F4 
F5 
F6 
F7 
F8 
F9 
F10 
F11 
F12 
LED_B1 
LED_B2 
LED_B3 
LED_B4 
LED_B5 
LED_BH1 
LED_RGB1 
LED_V1 
LED_V2 
ACES 

The Academy Color Encoding System (ACES) white point, it is close to D60 (but not D60! many implementations got this wrong).

NUM 

◆ ESpectralResample

enum class ph::math::ESpectralResample
strong
Enumerator
Unspecified 
PiecewiseAveraged 
Default 

Function Documentation

◆ bits_to_sample()

template<typename T , typename BitsType >
T ph::math::bits_to_sample ( const BitsType & bits)
inline

Converts input bits to a sample. For standard unsigned integral types, this is effectively normalizing the integer value represented by bits into the range [0, 1].

Parameters
bitsThe bits to convert.

◆ black_body_spectral_radiance_at()

template<typename T >
T ph::math::black_body_spectral_radiance_at ( const T temperatureK,
const T wavelengthNM )
inline

Get Black-body spectral radiance at specific temperature and wavelength. Note that this function is not returning radiance but spectral radiance. The returned spectral radiance has the unit of watt per steradian per square meter per meter (W * sr^-1 * m^-2 * m^-1).

Parameters
temperatureKTemperature in Kelvin.
wavelengthNMWavelength of the interest, in nanometers.
Returns
Emitted spectral radiance on specified parameters, in SI unit (W * sr^-1 * m^-2 * m^-1).

◆ black_body_spectral_radiance_curve()

template<typename T >
std::vector< T > ph::math::black_body_spectral_radiance_curve ( const T temperatureK,
const T lambdaMinNM,
const T lambdaMaxNM,
const std::size_t numCurvePoints,
std::vector< T > *const out_lambdaValues = nullptr )

Get a curve for Black-body radiation. Note that this function is not returning radiance but spectral radiance. The returned spectral radiance has the unit of watt per steradian per square meter per meter (W * sr^-1 * m^-2 * m^-1).

Parameters
lambdaMinNMMinimum wavelength of the curve data, in nanometers.
lambdaMaxNMMaximum wavelength of the curve data, in nanometers.
numCurvePointsNumber of points for the curve. Evenly spaced in [lambdaMinNM, lambdaMaxNM]. Must be >= 2.
Returns
Emitted spectral radiance on each wavelength, in SI unit (W * sr^-1 * m^-2 * m^-1).

◆ bytes_to_GiB()

template<typename NumberType >
NumberType ph::math::bytes_to_GiB ( const std::size_t numBytes)
inlineconstexpr

◆ bytes_to_KiB()

template<typename NumberType >
NumberType ph::math::bytes_to_KiB ( const std::size_t numBytes)
inlineconstexpr

◆ bytes_to_MiB()

template<typename NumberType >
NumberType ph::math::bytes_to_MiB ( const std::size_t numBytes)
inlineconstexpr

◆ bytes_to_PiB()

template<typename NumberType >
NumberType ph::math::bytes_to_PiB ( const std::size_t numBytes)
inlineconstexpr

◆ bytes_to_TiB()

template<typename NumberType >
NumberType ph::math::bytes_to_TiB ( const std::size_t numBytes)
inlineconstexpr

◆ chromatic_adapt()

template<EChromaticAdaptation ALGORITHM, typename T >
TTristimulusValues< T > ph::math::chromatic_adapt ( const TTristimulusValues< T > & srcCIEXYZColor,
EReferenceWhite srcRefWhite,
EReferenceWhite dstRefWhite )
inline

◆ chromaticity_of()

template<typename T = ColorValue>
TChromaticityValues< T > ph::math::chromaticity_of ( const EReferenceWhite refWhite)
inline

◆ CIEXYZ_of()

template<typename T = ColorValue>
TTristimulusValues< T > ph::math::CIEXYZ_of ( const EReferenceWhite refWhite)
inline

◆ CIEXYZ_of_custom_reference_white()

template<typename T = ColorValue>
TTristimulusValues< T > ph::math::CIEXYZ_of_custom_reference_white ( const TChromaticityValues< T > & refWhite)
inline

◆ clamp()

template<typename T >
T ph::math::clamp ( const T value,
const T lowerBound,
const T upperBound )
inline

Clamps a value to [lowerBound, upperBound]. None of value, lowerBound and upperBound can be NaN, or the method's behavior is undefined.

◆ clear_bits_in_range()

template<std::unsigned_integral UIntType, std::integral RangeType>
UIntType ph::math::clear_bits_in_range ( const UIntType bits,
const RangeType beginBitIdx,
const RangeType endBitIdx )
inline

Set bits in the range to 0. The bits in [beginBitIdx, endBitIdx) will be set to 0, while the rest remain the same. LSB has the bit index 0.

◆ constant_spectral_samples()

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > ph::math::constant_spectral_samples ( T constant)
inlineconstexpr

◆ create_von_kries_linear_CAT_matrix() [1/2]

template<typename T >
TMatrix3< T > ph::math::create_von_kries_linear_CAT_matrix ( const TMatrix3< T > & CIEXYZToConeResponse,
const TMatrix3< T > & ConeResponseToCIEXYZ,
const EReferenceWhite srcRefWhite,
const EReferenceWhite dstRefWhite )
inline

◆ create_von_kries_linear_CAT_matrix() [2/2]

template<typename T >
TMatrix3< T > ph::math::create_von_kries_linear_CAT_matrix ( const TMatrix3< T > & CIEXYZToConeResponse,
const TMatrix3< T > & ConeResponseToCIEXYZ,
const TTristimulusValues< T > & srcRefWhite,
const TTristimulusValues< T > & dstRefWhite )
inline

◆ discrete_spatial_hash() [1/4]

template<std::floating_point T>
std::size_t ph::math::discrete_spatial_hash ( const TVector3< T > & point,
const TVector3< T > & cellSize,
std::size_t hashTableSize )
inline

Discretized spatial hash for floating point values are done by first quantizing the value to integers according to cell size.

◆ discrete_spatial_hash() [2/4]

template<std::integral T>
std::size_t ph::math::discrete_spatial_hash ( const TVector3< T > & point,
std::size_t hashTableSize )
inline

◆ discrete_spatial_hash() [3/4]

template<typename Integer >
std::size_t ph::math::discrete_spatial_hash ( Integer x,
Integer y,
Integer z,
std::size_t hashTableSize )
inline

Implements the hash function described in the paper "Optimized Spatial Hashing for Collision Detection of Deformable Objects" by Teschner et al. [15] Note that although they stated in the paper that 73856093, 19349663 and 83492791 are all prime numbers, 19349663 is in fact a composite number (41 * 471943).

Reference: http://www.beosil.com/download/CollisionDetectionHashing_VMV03.pdf

◆ discrete_spatial_hash() [4/4]

template<typename Integer >
std::size_t ph::math::discrete_spatial_hash ( Integer x,
Integer y,
std::size_t hashTableSize )
inline

Extending the original 3-D version of discrete_spatial_hash() to 2-D.

◆ dot_product() [1/3]

template<typename T , std::size_t N>
T ph::math::dot_product ( const std::array< T, N > & vecA,
const std::array< T, N > & vecB )
inline

Treating input values as vectors and calculates their dot product.

◆ dot_product() [2/3]

template<typename T >
T ph::math::dot_product ( const std::vector< T > & vecA,
const std::vector< T > & vecB )
inline

◆ dot_product() [3/3]

template<typename T , std::size_t EXTENT = std::dynamic_extent>
T ph::math::dot_product ( TSpanView< T, EXTENT > vecA,
TSpanView< T, EXTENT > vecB )
inline

◆ duration_to_HMS()

template<typename TimeType , typename UnitType >
auto ph::math::duration_to_HMS ( const std::chrono::duration< TimeType, UnitType > & totalTime) -> std::array<TimeType, 3>
inline

◆ estimate_color_energy()

template<EColorSpace SRC_COLOR_SPACE, typename T , EColorSpace SPECTRAL_COLOR_SPACE = EColorSpace::Spectral, EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
T ph::math::estimate_color_energy ( const auto & srcColorValues)
inline

◆ estimate_samples_energy()

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
T ph::math::estimate_samples_energy ( const TSpectralSampleValues< T, SampleProps > & srcSamples)
inline

◆ evenly_spaced_array()

template<typename T , T MIN, T MAX, std::size_t N>
std::array< T, N > ph::math::evenly_spaced_array ( )
inline

◆ evenly_spaced_vector()

template<typename T >
std::vector< T > ph::math::evenly_spaced_vector ( const T min,
const T max,
const std::size_t n )
inline

◆ fast_rcp_sqrt()

float ph::math::fast_rcp_sqrt ( float x)
inline

Computes 1/sqrt(x) in a fast but approximative way.

This method is best known for its implementation in Quake III Arena (1999). Here the implementation follows what described in the referenced paper, which uses a slightly better (in terms of maximal relative error) magic number.

Reference: http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf

◆ fast_sqrt()

float ph::math::fast_sqrt ( const float x)
inline

Computes sqrt(x) in a fast but approximative way.

◆ flag_bit() [1/2]

template<std::unsigned_integral UIntType, UIntType BIT_IDX>
UIntType ph::math::flag_bit ( )
inlineconsteval

◆ flag_bit() [2/2]

template<std::unsigned_integral UIntType>
UIntType ph::math::flag_bit ( const UIntType bitIdx)
inline

Set a single bit to 1, others remain 0. LSB has the bit index 0.

◆ form_orthonormal_basis_frisvad()

void ph::math::form_orthonormal_basis_frisvad ( const Vector3R & unitYaxis,
Vector3R *const out_unitXaxis,
Vector3R *const out_unitZaxis )

◆ fp16_bits_to_fp32()

float32 ph::math::fp16_bits_to_fp32 ( const uint16 fp16Bits)
inline

Convert a 16-bit representation back to 32-bit float.

◆ fp32_to_fp16_bits()

uint16 ph::math::fp32_to_fp16_bits ( const float32 value)
inline

Convert a 32-bit float to 16-bit representation.

The implementation of half floats does not contain "safety checks", i.e., according to IEEE 754-2008, +/-65504 is the max representable value of half floats, input values that exceed the max value will not be represented correctly and will cause problems in OpenGL or other APIs. If the input (fp32) is too samll, 0 will be returned.

◆ fractional_part()

template<typename T , std::enable_if_t< std::is_floating_point_v< T >, int > = 0>
T ph::math::fractional_part ( const T value)
inline

Retrieve the fractional part of value (with the sign unchanged). The result is not guaranteed to be the same as the bit representation of 's fractional part. The result is undefined if input value is NaN or +-Inf.

◆ is_compatible()

template<typename InColorValuesType , EColorSpace COLOR_SPACE>
bool ph::math::is_compatible ( )
inlineconstexpr

Check whether InColorValuesType is suitable to represent values in COLOR_SPACE.

◆ is_even()

template<typename T >
bool ph::math::is_even ( const T value)
inline

Checks if a number is even.

Parameters
valueThe number to be tested. Should be an integer type.

◆ is_odd()

template<typename T >
bool ph::math::is_odd ( const T value)
inline

Checks if a number is odd.

Parameters
valueThe number to be tested. Should be an integer type.

◆ is_opposite_hemisphere()

bool ph::math::is_opposite_hemisphere ( const Vector3R & vector,
const Vector3R & N )

Checks whether the specified vector is within the hemisphere defined by the normal vector -N. N points to the hemisphere's peak, i.e., theta = 0 in spherical coordinates.

Note
For the case where vector is perpendicular to N, both this function and is_same_hemisphere() returns false.

◆ is_same_hemisphere()

bool ph::math::is_same_hemisphere ( const Vector3R & vector,
const Vector3R & N )

Checks whether the specified vector is within the hemisphere defined by the normal vector N. N points to the hemisphere's peak, i.e., theta = 0 in spherical coordinates.

◆ is_tristimulus()

bool ph::math::is_tristimulus ( EColorSpace colorSpace)
inline

Check whether colorSpace is a tristimulus color space. This is a runtime check. For compile-time check, use TColorSpaceDef<?>::isTristimulus().

◆ ith_evenly_divided_range()

std::pair< std::size_t, std::size_t > ph::math::ith_evenly_divided_range ( const std::size_t rangeIndex,
const std::size_t totalSize,
const std::size_t numDivisions )
inline

Gets the i-th evenly divided range.

Gets the i-th range [beginIndex, endIndex) which is the result of dividing totalSize into numDivisions parts as evenly as possible.

◆ length() [1/3]

template<typename T , std::size_t N>
T ph::math::length ( const std::array< T, N > & vec)
inline

Treating input values as a vector and calculates its length.

◆ length() [2/3]

template<typename T >
T ph::math::length ( const std::vector< T > & vec)
inline

◆ length() [3/3]

template<typename T , std::size_t EXTENT = std::dynamic_extent>
T ph::math::length ( TSpanView< T, EXTENT > vec)
inline

◆ length_squared() [1/3]

template<typename T , std::size_t N>
T ph::math::length_squared ( const std::array< T, N > & vec)
inline

Treating input values as a vector and calculates its squared length.

◆ length_squared() [2/3]

template<typename T >
T ph::math::length_squared ( const std::vector< T > & vec)
inline

◆ length_squared() [3/3]

template<typename T , std::size_t EXTENT = std::dynamic_extent>
T ph::math::length_squared ( TSpanView< T, EXTENT > vec)
inline

◆ log2_floor()

template<typename T >
T ph::math::log2_floor ( const T value)
inline

Calculate a positive number's base 2 logarithm (floored).

Parameters
valueShould be > 0, or the behavior of this method is undefined.

◆ matrix2x2()

template<typename T >
auto ph::math::matrix2x2 ( const T e00,
const T e01,
const T e10,
const T e11 ) -> std::array<std::array<T, 2>, 2>
inline

◆ mean_solar_time_to_solar_time_24H()

template<typename T >
T ph::math::mean_solar_time_to_solar_time_24H ( const T standardTime24H,
const T standardMeridianRadians,
const T siteLongitudeRadians,
const T julianDate )
inline

Convert mean solar time to solar time.

The equation is from Appendix A.6 of the paper "A Practical Analytic Model for Daylight" by Preetham et al.,

Parameters
standardTime24HLocal standard time in decimal hours.
standardMeridianRadiansStandard meridian used for local standard time, in radians.
siteLongitudeRadiansLongitude of the site of interest, in radians.
julianDateThe day of the year as an integer in the range [1, 366].
Returns
Solar time in decimal hours.

◆ milliseconds_to_HMS()

template<typename TimeType >
auto ph::math::milliseconds_to_HMS ( const TimeType & totalTime) -> std::array<TimeType, 3>
inline

◆ moremur_bit_mix_64()

uint64 ph::math::moremur_bit_mix_64 ( uint64 v)
inline

A MurmurHash3-style bit mixer that outperforms the original by quite some margin. 64-bit version.

◆ murmur3_32() [1/2]

template<typename T , typename BitMixerType = Murmur3BitMixer32>
uint32 ph::math::murmur3_32 ( const T & data,
uint32 seed )
inline

Generate 32-bit hash values using MurmurHash3. Note that there are no collisions when T has <= 32 bits (two distinct inputs will not result in the same output). In general, if there is a way to reverse a function (reversing murmur3_32() is possible), it is guaranteed there cannot be any collisions. Otherwise, it would not be possible to revert.

◆ murmur3_32() [2/2]

template<typename T , typename BitMixerType >
uint32 ph::math::murmur3_32 ( const T * data,
std::size_t dataSize,
BitMixerType && bitMixer,
uint32 seed )
inline

Generate 32-bit hash values using MurmurHash3. This is a lower level variant of MurmurHash3 and can be useful for customizing its behavior, e.g., it can accept arbitrary BitMixerType without requiring it to be default constructible.

Parameters
dataPointer to a data array of type T.
dataSizeNumber of elements in the data array.
bitMixerThe finalizer for the hashing algorithm.
seedA value for generating the hash. Can be from a RNG or anything you prefer.

◆ murmur3_bit_mix_32()

uint32 ph::math::murmur3_bit_mix_32 ( uint32 v)
inline

MurmurHash3's bit mixer. 32-bit version.

◆ murmur3_bit_mix_64()

uint64 ph::math::murmur3_bit_mix_64 ( uint64 v)
inline

MurmurHash3's bit mixer. 64-bit version.

◆ murmur3_v13_bit_mix_64()

uint64 ph::math::murmur3_v13_bit_mix_64 ( uint64 v)
inline

MurmurHash3's bit mixer. 64-bit version.

◆ next_power_of_2()

uint32 ph::math::next_power_of_2 ( uint32 value)
inline

Gets the minimum power of 2 value that is >= value.

Note that if is 0, then 0 will be returned.

Reference: Stanford CG Lab's webpage: "Bit Twiddling Hacks" by Sean Eron Anderson

◆ normalize() [1/3]

template<typename T , std::size_t N>
void ph::math::normalize ( std::array< T, N > & vec)
inline

Treating input values as a vector and normalize it. Notice that normalizing a integer typed vector will result in 0-vector most of the time.

Parameters
vecThe vector to be normalized in-place.

◆ normalize() [2/3]

template<typename T >
void ph::math::normalize ( std::vector< T > & vec)
inline

◆ normalize() [3/3]

template<typename T , std::size_t EXTENT = std::dynamic_extent>
void ph::math::normalize ( TSpan< T, EXTENT > vec)
inline

◆ normalize_color_energy()

template<EColorSpace SRC_COLOR_SPACE, typename T , EColorSpace SPECTRAL_COLOR_SPACE = EColorSpace::Spectral, EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
auto ph::math::normalize_color_energy ( const auto & srcColorValues)
inline

◆ normalize_integer()

template<std::floating_point FloatType, std::integral IntType>
FloatType ph::math::normalize_integer ( const IntType intVal)
inline

Transform an integer to the range [0, 1] ([-1, 1] for signed integer). When transforming an unsigned integer, the minimum value the integer can hold will be mapped to 0, while the maximum value will be mapped to 1; the rest of the integer values will be uniformally mapped to the range [0, 1]. Signed integer types follow the same rule, except the mapped range will be [-1, 1].

◆ normalize_samples_energy()

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > ph::math::normalize_samples_energy ( const TSpectralSampleValues< T, SampleProps > & srcSamples)
inline

Normalize spectral samples as if they carry energy. Normalized spectral samples, together, represents the expected amount of energy that 1 unit of total energy would distribute on each wavelength interval (implying that the samples should sum to 1).

◆ octahedron_unit_vector_decode()

template<typename T >
TVector3< T > ph::math::octahedron_unit_vector_decode ( const TVector2< T > & encodedVal)
inline

Decode and get a unit vector using octahedron projection.

Parameters
encodedValThe encoded unit vector (in [0, 1] for any bit size) to be decoded.
Returns
Decoded unit vector (normalized).

◆ octahedron_unit_vector_encode()

template<typename T >
TVector2< T > ph::math::octahedron_unit_vector_encode ( const TVector3< T > & unitVec)
inline

Encode a unit vector using octahedron projection.

Parameters
unitVecThe unit vector to be encoded. Assumed being normalized already.
Returns
Encoded unit vector in [0, 1] for any bit size.

◆ p_norm() [1/3]

template<typename T , std::size_t N>
T ph::math::p_norm ( const std::array< T, N > & vec)
inline

Treating input values as a vector and calculates its p-norm.

◆ p_norm() [2/3]

template<typename T >
T ph::math::p_norm ( const std::vector< T > & vec)
inline

◆ p_norm() [3/3]

template<std::size_t P, typename T , std::size_t EXTENT = std::dynamic_extent>
T ph::math::p_norm ( TSpanView< T, EXTENT > vec)
inline

◆ permuted_index()

uint32 ph::math::permuted_index ( uint32 i,
uint32 l,
uint32 p )
inline

Get the permuted index or value in O(1) space and O(1) time.

Parameters
iThe index or value to be permuted.
lThe size of the permutation vector.
pThe seed to use for the shuffle.
Returns
The permuted index or value.

◆ PH_DEFINE_EXTERNAL_LOG_GROUP()

ph::math::PH_DEFINE_EXTERNAL_LOG_GROUP ( StaticRigidTransform ,
Math  )

◆ pick()

template<typename T >
bool ph::math::pick ( const T pickProbability,
const T sample )
inline

Randomly pick a branch with some probability.

Parameters
pickProbabilityThe probability for the function to return true.
sampleThe source of randomness.
Returns
true if the pick is successful.

◆ product() [1/3]

template<typename T , std::size_t N>
T ph::math::product ( const std::array< T, N > & values,
T initialValue = 1 )
inline

Multiplies all values within a container together.

◆ product() [2/3]

template<typename T >
T ph::math::product ( const std::vector< T > & values,
T initialValue = 1 )
inline

◆ product() [3/3]

template<typename T , std::size_t EXTENT = std::dynamic_extent>
T ph::math::product ( TSpanView< T, EXTENT > values,
T initialValue = 1 )
inline

◆ put_color_energy()

template<EColorSpace SRC_COLOR_SPACE, typename T , EColorSpace SPECTRAL_COLOR_SPACE = EColorSpace::Spectral, EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
auto ph::math::put_color_energy ( const auto & srcColorValues,
T energyLevel )
inline

◆ quantize_normalized_float()

template<std::integral IntType, std::floating_point FloatType>
IntType ph::math::quantize_normalized_float ( const FloatType floatVal)
inline

◆ radical_inverse()

template<auto BASE, std::floating_point Result, std::integral Value>
Result ph::math::radical_inverse ( const Value value)
inline

Compute radical inverse of a value.

Template Parameters
BASEThe base to use.
Returns
Radical inverse of value in decimal.

◆ radical_inverse_permuted()

template<auto BASE, std::floating_point Result, std::integral Value, typename DigitPermuter >
Result ph::math::radical_inverse_permuted ( const Value dimIndex,
const Value value,
DigitPermuter permuter )
inline

Same as radical_inverse(), with permutation ability. It is guaranteed that no more than radical_inverse_detail::num_meaningful_digits() digits will be processed during the radical inverse.

Parameters
permuterMust be callable with <BASE>(digit) and return a permuted digit.

◆ relative_luminance()

template<EColorSpace SRC_COLOR_SPACE, typename T , EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
T ph::math::relative_luminance ( const auto & srcColorValues,
EColorUsage usage = EColorUsage::EMR )
inline
Returns
Relative luminance of srcColorValues. Normally for a tristimulus color, its reference white's relative luminance will be 1. For spectral samples, it is the result of performing an inner product with the luminous efficiency function. For ECF usages, its relative luminance is guaranteed to be within [0, 1].

◆ resample_black_body()

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > ph::math::resample_black_body ( T temperatureK)
inline

SPD of black-body radiation, with total energy = 1.

◆ resample_black_body_radiance()

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > ph::math::resample_black_body_radiance ( T temperatureK)
inline

SPD of black-body radiation in radiance. If a normalized energy distribution is desired, use resample_black_body().

◆ resample_black_body_spectral_radiance()

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > ph::math::resample_black_body_spectral_radiance ( T temperatureK)
inline

SPD of black-body radiation in spectral radiance. Note that this function is not returning radiance but spectral radiance. The returned spectral radiance has the unit of watt per steradian per square meter per meter (W * sr^-1 * m^-2 * m^-1). If radiance is desired, use resample_black_body_radiance(). If a normalized energy distribution is desired, use resample_black_body().

◆ resample_illuminant_D65()

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > ph::math::resample_illuminant_D65 ( )
inline

SPD of standard illuminants D65, with total energy = 1.

◆ resample_illuminant_E()

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > ph::math::resample_illuminant_E ( )
inline

SPD of standard illuminants. Any light source which statistically has the same relative SPD as a standard illuminant can be considered a standard light source, and is the reason why the SPD resample functions return a energy-normalized SPD (for convenience, as this is what you want almost always).

SPD of standard illuminants E, with total energy = 1.

◆ resample_spectral_samples()

template<typename T , typename U , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps>
TSpectralSampleValues< T, SampleProps > ph::math::resample_spectral_samples ( const U * wavelengthsNM,
const U * values,
std::size_t numPoints,
ESpectralResample algorithm = ESpectralResample::Default )
inline

◆ reused_pick()

template<typename T >
bool ph::math::reused_pick ( const T pickProbability,
T & sample )
inline

◆ reverse_bits()

template<typename T , typename = std::enable_if_t<std::is_integral_v<T>>>
T ph::math::reverse_bits ( const T value)
inline

Get an integral value with reversed bits.

Reference: The lookup table method from Stanford CG Lab's webpage: "Bit Twiddling Hacks" by Sean Eron Anderson.

◆ safe_clamp()

template<typename T >
T ph::math::safe_clamp ( const T value,
const T lowerBound,
const T upperBound )
inline

Clamps a value to [lowerBound, upperBound], fallback to lowerBound. If a floating-point value is non-finite (e.g., being Inf, NaN), its value is clamped to lowerBound. Neither lowerBound nor upperBound can be NaN, or the method's behavior is undefined.

◆ safe_rcp()

template<typename T >
T ph::math::safe_rcp ( const T value)
inline

Calculates the reciprocal of a value, fallback to 0. If the resulting reciprocal is non-finite (e.g., being Inf, NaN), 0 will be returned instead.

◆ sample_cast()

template<typename To , typename From , std::size_t N>
std::array< To, N > ph::math::sample_cast ( const std::array< From, N > & sample)
inline

◆ seconds_to_HMS()

template<typename TimeType >
auto ph::math::seconds_to_HMS ( const TimeType & totalSeconds) -> std::array<TimeType, 3>
inline

◆ set_bits_in_range()

template<std::unsigned_integral UIntType, std::integral RangeType>
UIntType ph::math::set_bits_in_range ( const UIntType bits,
const RangeType beginBitIdx,
const RangeType endBitIdx )
inline

Set bits in the range to 1. The bits in [beginBitIdx, endBitIdx) will be set to 1, while the rest remain the same. LSB has the bit index 0.

◆ shuffle_durstenfeld()

template<typename RandomIterator , typename Swapper = detail::shuffle::StandardSwapper<typename std::iterator_traits<RandomIterator>::value_type>>
void ph::math::shuffle_durstenfeld ( RandomIterator begin,
RandomIterator end,
Swapper swapper = Swapper() )

◆ shuffle_durstenfeld_index_pairs()

template<typename IndexPairConsumer >
void ph::math::shuffle_durstenfeld_index_pairs ( const std::size_t beginIndex,
const std::size_t endIndex,
IndexPairConsumer consumer )

◆ sign()

template<typename T >
int ph::math::sign ( const T value)
inline

Extract the sign of value.

Function is defined only if the provided value is comparable to 0. Note that the input is passed by value.

Returns
1 when value > 0; -1 when value < 0; 0 when value == 0.
Note
This function is branchless.

◆ sizeof()

template<std::size_t N, typename Index >
class ph::math::TBvhSimdComputingContext ph::math::sizeof ( float32 )

◆ spectral_samples_to_CIE_XYZ()

template<typename T , CSpectralSampleProps SampleProps = DefaultSpectralSampleProps, EReferenceWhite NORMALIZER = EReferenceWhite::D65>
TTristimulusValues< T > ph::math::spectral_samples_to_CIE_XYZ ( const TSpectralSampleValues< T, SampleProps > & srcSamples,
EColorUsage usage )
inline

Converting spectral samples to CIE-XYZ using standard CMFs.

Template Parameters
NORMALIZERPick a reference white as a normalization target. This will ensure a normalized SPD of the associated standard illuminant get the corresponding standard white point defined in CIE-XYZ. This normalization only take place if the color usage is related to illumination.

◆ squared()

template<typename T >
T ph::math::squared ( const T value)
inline

◆ sRGB_linear_to_nonlinear()

template<typename T >
TTristimulusValues< T > ph::math::sRGB_linear_to_nonlinear ( const TTristimulusValues< T > & linearSRGB)
inline

Helper for converting from linear-sRGB to sRGB.

◆ sRGB_nonlinear_to_linear()

template<typename T >
TTristimulusValues< T > ph::math::sRGB_nonlinear_to_linear ( const TTristimulusValues< T > & nonlinearSRGB)
inline

Helper for converting from sRGB to linear-sRGB.

◆ summation() [1/3]

template<typename T , std::size_t N>
T ph::math::summation ( const std::array< T, N > & values,
T initialValue = 0 )
inline

Sum all values within a container together.

◆ summation() [2/3]

template<typename T >
T ph::math::summation ( const std::vector< T > & values,
T initialValue = 0 )
inline

◆ summation() [3/3]

template<typename T , std::size_t EXTENT = std::dynamic_extent>
T ph::math::summation ( TSpanView< T, EXTENT > values,
T initialValue = 0 )
inline

◆ sun_sky_phi_theta()

template<typename T >
TVector2< T > ph::math::sun_sky_phi_theta ( const T solarTime24H,
const T julianDate,
const T siteLatitudeRadians )
inline

Locate spherical coordinates of the sun in sky.

The equation is from Appendix A.6 of the paper "A Practical Analytic Model for Daylight" by Preetham et al.,

Parameters
solarTime24HLocal solar time in decimal hours.
julianDateThe day of the year as an integer in the range [1, 366].
siteLatitudeRadiansLatitude of the site of interest, in radians.
Returns
Spherical coordinates of the sun in sky.

◆ to_degrees()

template<typename T >
T ph::math::to_degrees ( const T radians)
inline

Convert radians to degrees.

◆ to_radians()

template<typename T >
T ph::math::to_radians ( const T degrees)
inline

Convert degrees to radians.

◆ transform_color()

template<EColorSpace SRC_COLOR_SPACE, EColorSpace DST_COLOR_SPACE, typename T , EChromaticAdaptation ALGORITHM = EChromaticAdaptation::Default>
auto ph::math::transform_color ( const auto & srcColorValues,
EColorUsage usage )
inline
Parameters
srcColorValuesA TTristimulusValues or a TSpectralSampleValues depending on whetherSRC_COLOR_SPACE is tristimulus.
Returns
A TTristimulusValues or a TSpectralSampleValues depending on whether DST_COLOR_SPACE is tristimulus.

◆ transform_from_linear_sRGB()

template<EColorSpace DST_COLOR_SPACE, typename T >
auto ph::math::transform_from_linear_sRGB ( const TTristimulusValues< T > & linearSRGB,
EColorUsage usage )
inline

Helper for converting from linear-sRGB to any color space.

◆ transform_from_sRGB()

template<EColorSpace DST_COLOR_SPACE, typename T >
auto ph::math::transform_from_sRGB ( const TTristimulusValues< T > & nonlinearSRGB,
EColorUsage usage )
inline

Helper for converting from sRGB to any color space.

◆ transform_to_linear_sRGB()

template<EColorSpace SRC_COLOR_SPACE, typename T >
TTristimulusValues< T > ph::math::transform_to_linear_sRGB ( const auto & srcColorValues,
EColorUsage usage )
inline

Helper for converting any color space to linear-sRGB.

◆ transform_to_sRGB()

template<EColorSpace SRC_COLOR_SPACE, typename T >
TTristimulusValues< T > ph::math::transform_to_sRGB ( const auto & srcColorValues,
EColorUsage usage )
inline

Helper for converting any color space to sRGB.

◆ uint64_mul()

void ph::math::uint64_mul ( const uint64 lhs,
const uint64 rhs,
uint64 & out_high64,
uint64 & out_low64 )
inline

Multiply two unsigined 64-bit numbers and get a 128-bit result.

Parameters
[out]out_high64The higher 64 bits of the 128-bit result.
[out]out_low64The lower 64 bits of the 128-bit result.

◆ wavelength_interval_of()

template<typename T , CSpectralSampleProps SampleProps>
T ph::math::wavelength_interval_of ( )
inlineconstexprnoexcept
Returns
Wavelength sample interval of SampleProps, in nanometers (nm).

◆ wavelength_range_of() [1/2]

template<typename T , CSpectralSampleProps SampleProps>
auto ph::math::wavelength_range_of ( std::size_t sampleIndex)
inlineconstexprnoexcept
Returns
Wavelength sample range of the sample with sampleIndex, in nanometers (nm).

◆ wavelength_range_of() [2/2]

template<typename T , CSpectralSampleProps SampleProps>
std::pair< T, T > ph::math::wavelength_range_of ( std::size_t sampleIndex)
inlineconstexprnoexcept
Returns
Wavelength sample range of the sample with sampleIndex, in nanometers (nm).

◆ wrap()

template<typename T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
T ph::math::wrap ( T value,
const T lowerBound,
const T upperBound )
inline

Wraps an integer around [lower-bound, upper-bound]. For example, given a bound [-1, 2], 3 will be wrapped to -1.

Variable Documentation

◆ BATCH_SIZE

class ph::math::TBvhSimdComputingContext* ph::math::BATCH_SIZE

◆ MaskType

class ph::math::TBvhSimdComputingContext ph::math::MaskType
Returns
A mask storing the hit result. The i-th bit is 1 if the i-th AABB is hit; 0 otherwise.