Spectral Quantity

template<IsDimensionality Dim, typename Scale, IsSpectral TSpectral>
class SpectralQuantity

A spectral data container with associated physical unit information.

SpectralQuantity wraps a spectral type (e.g. RGB, Visible8) and associates it with a physical dimensionality and scale, providing compile-time unit safety for spectral data.

Usage Examples

using TSpectral = huira::RGB;

// Construct from spectral data (values are in the specified unit)
SpectralWatts<TSpectral> power(TSpectral{10.0f, 20.0f, 30.0f});

// Convert to SI representation
TSpectral si_values = power.to_si();

// Convert between compatible scales
SpectralKilowatts<TSpectral> kw = power.as<std::kilo>();

// Access the underlying spectral data
const TSpectral& raw = power.value();

Template Parameters:
  • Dim – The dimensionality type (e.g. Power, Irradiance).

  • Scale – The scale ratio relative to SI (e.g. std::ratio<1,1> for base, std::kilo for kilo-).

  • TSpectral – The spectral representation type (must satisfy IsSpectral).

Public Types

using dimension_type = Dim
using scale_type = Scale
using spectral_type = TSpectral

Public Functions

constexpr SpectralQuantity()

Default constructor. Initializes spectral data to zero.

explicit constexpr SpectralQuantity(const TSpectral &spectral_value)

Construct from spectral data. Values are interpreted in this quantity’s unit scale.

template<typename OtherScale>
constexpr SpectralQuantity(const SpectralQuantity<Dim, OtherScale, TSpectral> &other)

Convert from another SpectralQuantity with the same dimensionality but different scale.

constexpr SpectralQuantity(const SpectralQuantity&) = default
constexpr SpectralQuantity(SpectralQuantity&&) = default
SpectralQuantity &operator=(const SpectralQuantity&) = default
SpectralQuantity &operator=(SpectralQuantity&&) = default
const TSpectral &value() const

Get the underlying spectral data in the current unit’s scale.

TSpectral to_si() const

Convert the spectral data to SI base units.

template<typename NewScale>
SpectralQuantity<Dim, NewScale, TSpectral> as() const

Convert to a SpectralQuantity with a different scale of the same dimensionality.

std::string to_string() const

String representation.

bool operator==(const SpectralQuantity &other) const
bool operator!=(const SpectralQuantity &other) const