bands

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bands is light carried as amounts in slices of the spectrum: the form a renderer needs when light has to be added, filtered, redshifted or bent by wavelength, before an eye reduces it to three numbers.

Light in bands is what light is, coarsely. What it looks like is a colour, and colour is libtheme's: its bands package folds this light into a swatch through the 1931 observer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Band

type Band int

Band is one slice of the spectrum. Band i runs from 2^(i/PerOctave) nanometres up to, but not including, 2^((i+1)/PerOctave). Band 0 starts at one nanometre, and the wavelength doubles every PerOctave bands. Visible light is about bands 205 to 230.

func Of

func Of(nm float64) Band

Of is the band a wavelength in nanometres falls in.

func PerOctave

func PerOctave() Band

PerOctave is how many bands there are for every doubling of wavelength. It is picked, not derived, and is the one number this package takes; celestial's research data holds it, and says who picked it and from what.

The bands are even in the logarithm of wavelength, not in nanometres. Redshift multiplies every wavelength by the same factor, so it is a slide along the bands, not a resampling.

func (Band) Edges

func (band Band) Edges() (lo, hi float64)

Edges is where a band starts and where the next one does, in nanometres.

type Light

type Light struct {
	// contains filtered or unexported fields
}

Light is the power in each of a run of neighbouring bands, starting at band first. Its units are whatever the spectrum it came from used, times a nanometre. The zero value is no light.

func Add

func Add(one, other Light) Light

Add is two lights shining on the same place: in every band, the sum.

func Lines

func Lines(spectrum map[float64]float64) Light

Lines is light given at any wavelengths, each a line, grouped into the bands by wavelength in nanometres. Gamma rays are a few thousandths of a nanometre, and they have bands too.

func Lit

func Lit(light Light, share *Share) Light

Lit is light after a share of it: in every band, the light's power times the part passed there. No share at all passes nothing, as the zero Share does.

func Split

func Split(spectrum map[int]float64) Light

Split is a spectrum, given as power by wavelength in nanometres, as light in bands: each wavelength's power goes into the band it falls in.

Every wavelength counts, including those an eye never sees. Light in infrared bands is still light.

func (Light) Power

func (light Light) Power(band Band) float64

Power is the light in one band, nothing outside the span.

func (Light) Scale

func (light Light) Scale(times float64) Light

Scale is the light made so many times as strong in every band.

func (Light) Shift

func (light Light) Shift(steps int) Light

Shift slides the light along the bands: up by steps is redder. Redshift by a factor of 1 + z is PerOctave times log2(1 + z) steps, exact when that is whole. The power in each band travels with it unchanged; dimming with distance is the scene's business.

func (Light) Span

func (light Light) Span() (first, last Band)

Span is the first and last band this light has any entry for. Empty light reports first greater than last.

type Share

type Share struct {
	// contains filtered or unexported fields
}

Share is the fraction of light passed in each of a run of bands: what a filter lets through, or what a surface sends back. It is not light. Light arriving and a share of it are different things, so they are different types, and Lit is the one way to put them together.

Outside its run a share passes nothing, unless it was made Even, which passes the same part in every band. The zero value passes nothing.

func Even

func Even(part float64) (*Share, error)

Even is a share that passes the same part of the light in every band: a grey filter, or a perfectly grey surface. It refuses a part that is not a fraction, and then gives no share.

func Shares

func Shares(spectrum map[int]float64) (*Share, error)

Shares is a share given as the part passed at wavelengths in nanometres, as measured: a reflectance or transmittance curve. It refuses no wavelengths at all, a wavelength not longer than nothing and a part that is not a fraction, and then gives no share.

A band's part is the mean of the wavelengths given in it, since a share is a fraction and fractions do not add. A band inside the run with none given takes the straight line between its neighbours, read at its centre. Outside the run nothing passes.

func (Share) Part

func (share Share) Part(band Band) float64

Part is the fraction the share passes in one band.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL