RGB::fromWaveLength

Get the RGB color of monochromatic light

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

```RGB::fromWaveLength(`λ`, <`γ`>)
```

Description

`RGB::fromWaveLength( λ )` returns an approximative RGB specification for light of wavelength λnm.

Light consists of photons, each of which has a distinct wavelength. These different wavelengths cause color perception. `RGB::fromWaveLength` calculates an RGB triple corresponding to a given wave length.

Different displays show the same RGB color in slightly different ways. For this reason, the so-called "gamma correction" has been invented. `RGB::fromWaveLength` accepts a second argument, for fine-tuning the assumed gamma correction that enters the calculation.

Color perception depends on a number of factors, including individual differences. Therefore, such a calculation can only return an approximation. `RGB::fromWaveLength` uses the model published by Dan Bruton for the conversion.

For wavelengths outside the visible spectrum (which ranges from 380 nm to 780 nm), `RGB::fromWaveLength` returns black.

Examples

Example 1

White light, when sent through a prism, is split into the commonly known spectrum, because the prism refracts different wavelengths differently. This spectrum can easily be reproduced by `RGB::fromWaveLength`:

```plot(plot::Raster([[RGB::fromWaveLength(i) \$ i=380..780]]), Scaling = Unconstrained, Height = 20)```

Example 2

Bruton's conversion model looks like this:

```plotfunc2d( plot::Raster([[RGB::fromWaveLength(i) \$ i = 380..780]], x = 380..780, y = -0.2..0), (x -> RGB::fromWaveLength(x)[i]) \$ i = 1..3, x = 380..780, Colors = [RGB::Red, RGB::Green, RGB::Blue], LegendVisible = FALSE, XTicksNumber = Low, Scaling = Unconstrained, Axes = Automatic)```

Parameters

 `λ` The wavelength: a real-valued constant (interpreted as nanometers) or a length unit `γ` The "gamma correcture" for the display, defaults to 0.8

Return Values

RGB color: a list of three floating-point values