bearings

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 7 Imported by: 7

Documentation

Overview

package bearings contains functions for working with absolute and magnetic compass bearings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Declination

func Declination(p orb.Point, t time.Time) (unit.Angle, error)

Declination returns the magnetic declination at the given point and time.

Types

type Bearing

type Bearing interface {
	// Value returns the compass heading, normalized in range (0, 360].
	Value() unit.Angle
	// Rounded returns the compass heading, normalized in range (0, 360] rounded to the nearest degree.
	Rounded() unit.Angle
	// Degrees returns the compass heading in degrees, normalized in range (0, 360].
	Degrees() float64
	// RoundedDegrees returns the compass heading in degrees, normalized in range (0, 360] rounded to the nearest degree.
	RoundedDegrees() float64
	// True bearing conversion computed with the given declination.
	True(declination unit.Angle) Bearing
	// Magnetic bearing conversion computed with the given declination.
	Magnetic(declination unit.Angle) Bearing
	// Reciprocal bearing.
	Reciprocal() Bearing
	// IsTrue returns true if the bearing is a true bearing.
	IsTrue() bool
	// IsMagnetic returns true if the bearing is a magnetic bearing.
	IsMagnetic() bool
	// String returns the value formatted as a three-digit string.
	String() string
}

Bearing is a compass bearing that can be converted to true or magnetic bearing. Use either True or Magnetic immediately before use to assert which kind is used.

type Magnetic

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

Magnetic is a magnetic bearing, pointing at the magnetic north pole.

func NewMagneticBearing

func NewMagneticBearing(value unit.Angle) *Magnetic

NewMagneticBearing creates a new magnetic bearing from the given value.

func (*Magnetic) Degrees

func (b *Magnetic) Degrees() float64

Degrees returns the magnetic bearing in degrees.

func (*Magnetic) IsMagnetic

func (b *Magnetic) IsMagnetic() bool

IsMagnetic returns true for a magnetic bearing.

func (*Magnetic) IsTrue

func (b *Magnetic) IsTrue() bool

IsTrue returns false for a magnetic bearing.

func (*Magnetic) Magnetic

func (b *Magnetic) Magnetic(declination unit.Angle) Bearing

Magnetic returns this magnetic bearing.

func (*Magnetic) Reciprocal

func (b *Magnetic) Reciprocal() Bearing

Reciprocal returns a magnetic reciprocal.

func (*Magnetic) Rounded

func (b *Magnetic) Rounded() unit.Angle

Rounded returns the magnetic bearing rounded to the nearest degree.

func (*Magnetic) RoundedDegrees

func (b *Magnetic) RoundedDegrees() float64

RoundedDegrees returns the magnetic bearing in degrees, rounded to the nearest degree.

func (*Magnetic) String

func (b *Magnetic) String() string

String implements [Bearing.String]

func (*Magnetic) True

func (b *Magnetic) True(declination unit.Angle) Bearing

True converts this magnetic bearing to a true bearing by removing the given declination.

func (*Magnetic) Value

func (b *Magnetic) Value() unit.Angle

Value returns the magnetic bearing value.

type True

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

True is a bearing pointing to geographic north.

func NewTrueBearing

func NewTrueBearing(value unit.Angle) True

NewTrueBearing creates a new bearing from the given value.

func (True) Degrees

func (b True) Degrees() float64

Degrees returns the bearing in degrees.

func (True) IsMagnetic

func (b True) IsMagnetic() bool

IsMagnetic returns false for a true bearing.

func (True) IsTrue

func (b True) IsTrue() bool

IsTrue returns true for a true bearing.

func (True) Magnetic

func (b True) Magnetic(declination unit.Angle) Bearing

Magnetic converts this true bearing to a magnetic bearing by subtracting the given declination.

func (True) Reciprocal

func (b True) Reciprocal() Bearing

Reciprocal returns a reciprocal true bearing.

func (True) Rounded

func (b True) Rounded() unit.Angle

Rounded returns the bearing rounded to the nearest degree.

func (True) RoundedDegrees

func (b True) RoundedDegrees() float64

RoundedDegrees returns the bearing in degrees, rounded to the nearest degree.

func (True) String

func (b True) String() string

String implements [Bearing.String]

func (True) True

func (b True) True(declination unit.Angle) Bearing

True returns this bearing.

func (True) Value

func (b True) Value() unit.Angle

Value returns the bearing value.

Jump to

Keyboard shortcuts

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