measure

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 4 modules, 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 measure represents physical quantities in natural units with c, reduced Planck’s constant, and Boltzmann’s constant equal to one. Mass, temperature, and energy are stored in MeV; length and time in MeV^-1.

Public constructors and accessors use named units, so callers can work in SI while calculations retain natural units inside. Distinct types keep a mass from being passed where an age belongs.

exact.go derives conversions from SI defining constants. measured.go loads measured values and defines nominal solar references. laws.go contains the physical relationships built on those quantities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Angle

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

Angle is an angle, held in radians, which have no unit.

func Arcseconds

func Arcseconds(amount float64) Angle

Arcseconds is an angle in arcseconds, the unit positions and their errors on the sky are given in.

func Degrees

func Degrees(amount float64) Angle

Degrees is an angle in degrees.

func Radians

func Radians(amount float64) Angle

Radians is an angle in radians.

func (Angle) InArcseconds

func (angle Angle) InArcseconds() float64

InArcseconds is the angle in arcseconds.

func (Angle) InDegrees

func (angle Angle) InDegrees() float64

InDegrees is the angle in degrees.

func (Angle) InRadians

func (angle Angle) InRadians() float64

InRadians is the angle in radians.

type Area

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

Area is an area, held in one over MeV squared.

func Sphere

func Sphere(radius Length) Area

Sphere is the area of a sphere of a radius.

func SquareMetres

func SquareMetres(amount float64) Area

SquareMetres is an area in m2.

func Thomson

func Thomson() Area

Thomson is how much of a beam one free electron turns aside: from how strongly light and charge couple, and the electron's mass.

func (Area) InSquareMetres

func (area Area) InSquareMetres() float64

InSquareMetres is the area in m2.

type Coord

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

Coord stores a position as three natural-unit coordinates.

func At

func At(x, y, z Length) Coord

At is the place at three positions.

func Origin

func Origin() Coord

Origin returns the coordinate origin of the caller’s frame.

func (Coord) Minus

func (place Coord) Minus(from Coord) Displacement

Minus is how far this place is from another.

func (Coord) Plus

func (place Coord) Plus(by Displacement) Coord

Plus is the place a displacement from this one.

type Direction

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

Direction is a unit vector with dimensionless components.

func NewDirection

func NewDirection(x, y, z float64) (*Direction, error)

NewDirection normalizes three components. A zero vector, NaN, or infinite component returns an error and no direction.

Components are scaled by their largest magnitude before squaring, so overflow or underflow in their squares does not lose a valid direction.

func Up

func Up() Direction

Up returns the positive y direction used by these coordinates.

func (Direction) Dot

func (way Direction) Dot(other Direction) float64

Dot returns the cosine between directions: one when aligned, zero when perpendicular, and minus one when opposed.

func (Direction) Times

func (way Direction) Times(length Length) Displacement

Times is a displacement of a length this way.

type Displacement

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

Displacement stores the separation vector between positions.

func Offset

func Offset(x, y, z Length) Displacement

Offset is a displacement of three lengths.

func (Displacement) AlongX

func (by Displacement) AlongX() Length

AlongX is the displacement's part along x.

func (Displacement) AlongY

func (by Displacement) AlongY() Length

AlongY is the displacement's part along y, which is up.

func (Displacement) AlongZ

func (by Displacement) AlongZ() Length

AlongZ is the displacement's part along z.

func (Displacement) Cross

func (by Displacement) Cross(moving Velocity) Sweep

Cross is the sweep of something this far out moving at a velocity: the plane of its motion, and twice the area it sweeps each moment.

func (Displacement) Direction

func (by Displacement) Direction() (*Direction, error)

Direction normalizes a displacement and rejects zero separation.

func (Displacement) Dot

func (by Displacement) Dot(other Displacement) Area

Dot is the displacement against another: their lengths times how far one goes along the other, an area.

func (Displacement) Length

func (by Displacement) Length() Length

Length is how far the displacement goes.

func (Displacement) Minus

func (by Displacement) Minus(other Displacement) Displacement

Minus is this displacement less another.

func (Displacement) Plus

func (by Displacement) Plus(other Displacement) Displacement

Plus is this displacement and another, one after the other.

func (Displacement) Times

func (by Displacement) Times(share float64) Displacement

Times is the displacement scaled by a share.

type Duration

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

Duration is a time, held in one over MeV.

func Cosmos

func Cosmos() Duration

Cosmos is how old the universe is.

func Seconds

func Seconds(amount float64) Duration

Seconds is a time in s.

func Years

func Years(amount float64) Duration

Years is a time in Julian years.

func (Duration) InSeconds

func (span Duration) InSeconds() float64

InSeconds is the time in s.

func (Duration) InYears

func (span Duration) InYears() float64

InYears is the time in Julian years.

func (Duration) Minus

func (span Duration) Minus(less Duration) Duration

Minus subtracts another duration after rounding both operands, for the same fused-arithmetic reason as Mass.Minus.

func (Duration) Over

func (span Duration) Over(other Duration) float64

Over is how many of another time this one is.

type Energy

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

Energy is an energy, in MeV.

func Electronvolts

func Electronvolts(amount float64) Energy

Electronvolts is an energy in eV.

func Joules

func Joules(amount float64) Energy

Joules is an energy in J.

func MeV

func MeV(amount float64) Energy

MeV is an energy in MeV.

func Photon

func Photon(wavelength Length) Energy

Photon is the energy of light of a wavelength: a full turn over the wavelength.

func (Energy) InElectronvolts

func (energy Energy) InElectronvolts() float64

InElectronvolts is the energy in eV.

func (Energy) InJoules

func (energy Energy) InJoules() float64

InJoules is the energy in J.

func (Energy) InMeV

func (energy Energy) InMeV() float64

InMeV is the energy in MeV.

func (Energy) Times

func (energy Energy) Times(share float64) Energy

Times is the energy scaled by a share.

type Length

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

Length is a length, held in one over MeV.

func GM

func GM(mass Mass) Length

GM is a mass times newton's G: in natural units a length, half the horizon radius of a hole of that mass. Bodies whose GM is measured keep it; this is for a mass known as a mass.

func Metres

func Metres(amount float64) Length

Metres is a length in m.

func SolarRadii

func SolarRadii(amount float64) Length

SolarRadii is a length in the Sun's radius.

func (Length) InMetres

func (length Length) InMetres() float64

InMetres is the length in m.

func (Length) InSolarRadii

func (length Length) InSolarRadii() float64

InSolarRadii is the length in the Sun's radius.

func (Length) Over

func (length Length) Over(other Length) float64

Over is how many of another length this one is.

func (Length) Times

func (length Length) Times(share float64) Length

Times is the length scaled by a share.

type LightFraction

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

LightFraction expresses speed as a fraction of c. With c = 1 this is the dimensionless speed used internally.

func (LightFraction) InKilometresPerSecond

func (speed LightFraction) InKilometresPerSecond() float64

InKilometresPerSecond is the speed in km/s.

func (LightFraction) InLightFraction

func (speed LightFraction) InLightFraction() float64

InLightFraction is the speed as a share of light's.

type Mass

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

Mass is a mass, held as the energy it is at rest.

func Daltons

func Daltons(amount float64) Mass

Daltons is a mass in daltons, each a twelfth of a carbon 12 atom.

func Electron

func Electron() Mass

Electron is the electron's mass.

func Helium4

func Helium4() Mass

Helium4 is the mass of a helium 4 atom, its electrons and all.

func Hydrogen1

func Hydrogen1() Mass

Hydrogen1 is the mass of a hydrogen 1 atom, its electron and all.

func Kilograms

func Kilograms(amount float64) Mass

Kilograms is a mass in kg.

func Proton

func Proton() Mass

Proton is the proton's mass.

func SolarMasses

func SolarMasses(amount float64) Mass

SolarMasses is a mass in the Sun's masses.

func (Mass) Energy

func (mass Mass) Energy() Energy

Energy is the energy the mass is, at rest.

func (Mass) InKilograms

func (mass Mass) InKilograms() float64

InKilograms is the mass in kg.

func (Mass) InMeV

func (mass Mass) InMeV() float64

InMeV is the mass in MeV, which is its energy at rest.

func (Mass) InSolarMasses

func (mass Mass) InSolarMasses() float64

InSolarMasses is the mass in the Sun's masses.

func (Mass) Minus

func (mass Mass) Minus(less Mass) Mass

Minus subtracts another mass after explicitly rounding each operand. Without that boundary, arm64 can fuse an inlined multiplication and subtraction, leaving a rounding residual when subtracting equal masses.

func (Mass) Over

func (mass Mass) Over(other Mass) float64

Over is how many of another mass this one is.

func (Mass) Positive

func (mass Mass) Positive() bool

Positive reports whether mass is finite and greater than zero.

func (Mass) Times

func (mass Mass) Times(share float64) Mass

Times is the mass scaled by a share.

type Nominal

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

Nominal is a star's measures as the IAU fixes them for reference: its GM, radius and luminosity, and the mass that follows.

func Sun

func Sun() Nominal

Sun is the IAU's nominal Sun: its GM, radius and luminosity as the IAU fixes them, and its mass from its GM over G.

func (Nominal) GM

func (star Nominal) GM() Length

GM is the star's mass times G, as the IAU fixes it.

func (Nominal) Luminosity

func (star Nominal) Luminosity() Power

Luminosity is the star's luminosity.

func (Nominal) Mass

func (star Nominal) Mass() Mass

Mass is the star's mass, its GM over G.

func (Nominal) Radius

func (star Nominal) Radius() Length

Radius is the star's radius.

type Power

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

Power is energy given off over time, held in MeV squared.

func BlackBody

func BlackBody(heat Temperature, area Area) Power

BlackBody is the power a black surface of an area gives off at a temperature.

func Eddington

func Eddington(mass Mass) Power

Eddington is the brightest a mass can shine before its own light pushes its gas away: gravity pulling on each proton against light pushing on each electron, for gas of pure hydrogen.

Past it, a star sheds itself, and a hole's food is blown back out.

func SolarLuminosities

func SolarLuminosities(amount float64) Power

SolarLuminosities is a power in the Sun's luminosity.

func Watts

func Watts(amount float64) Power

Watts is a power in W.

func (Power) InSolarLuminosities

func (power Power) InSolarLuminosities() float64

InSolarLuminosities is the power in the Sun's luminosity.

func (Power) InWatts

func (power Power) InWatts() float64

InWatts is the power in W.

func (Power) Over

func (power Power) Over(other Power) float64

Over is how many of another power this one is.

func (Power) Spending

func (power Power) Spending(energy Energy) Duration

Spending returns the duration required to emit an energy at this power.

func (Power) Times

func (power Power) Times(share float64) Power

Times is the power scaled by a share.

type Sweep

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

Sweep is displacement crossed with velocity: it sets the orbital plane’s normal and twice the area swept per unit time, the quantity preserved by Kepler’s second law.

func (Sweep) North

func (sweep Sweep) North() (*Direction, error)

North returns the sweep’s unit normal. Zero sweep means radial motion with no defined orbital plane and returns an error.

func (Sweep) Size

func (sweep Sweep) Size() Length

Size is how much the sweep is: in natural units a length.

type Temperature

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

Temperature is a temperature, held as the energy k T.

func Kelvin

func Kelvin(amount float64) Temperature

Kelvin is a temperature in K.

func SurfaceTemperature

func SurfaceTemperature(power Power, area Area) Temperature

SurfaceTemperature is how hot a black surface of an area must be to give off a power: the fourth root of Stefan's law, undone.

func (Temperature) InKelvin

func (heat Temperature) InKelvin() float64

InKelvin is the temperature in K.

func (Temperature) InMeV

func (heat Temperature) InMeV() float64

InMeV is the temperature as the energy k T, in MeV.

type Velocity

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

Velocity stores three components as fractions of c. Arithmetic uses ordinary vector addition, not relativistic velocity composition; use it only where that approximation is appropriate.

func KilometresPerSecond

func KilometresPerSecond(x, y, z float64) (*Velocity, error)

KilometresPerSecond constructs a velocity from three km/s components. Nonfinite components and speeds at or above c return an error.

The comparison uses c in km/s directly: converting c to a fraction of itself first would round its own speed to just below one.

func (Velocity) AlongX

func (moving Velocity) AlongX() LightFraction

AlongX is the velocity's part along x.

func (Velocity) AlongY

func (moving Velocity) AlongY() LightFraction

AlongY is the velocity's part along y, which is up.

func (Velocity) AlongZ

func (moving Velocity) AlongZ() LightFraction

AlongZ is the velocity's part along z.

func (Velocity) Dot

func (moving Velocity) Dot(other Velocity) float64

Dot is the velocity against another, with no unit.

func (Velocity) Minus

func (moving Velocity) Minus(other Velocity) Velocity

Minus is this velocity seen from something moving at another.

func (Velocity) Plus

func (moving Velocity) Plus(other Velocity) Velocity

Plus is this velocity and another together.

func (Velocity) Speed

func (moving Velocity) Speed() LightFraction

Speed is how fast, whichever way.

func (Velocity) Times

func (moving Velocity) Times(share float64) Velocity

Times is the velocity scaled by a share.

Jump to

Keyboard shortcuts

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