Documentation
¶
Overview ¶
Coord: Chapter 13, Transformation of Coordinates.
Transforms in this package are provided in two forms, function and method. The results of the two forms should be identical.
The function forms pass all arguments and results as single values. These forms are best used when you are transforming a single pair of coordinates and wish to avoid memory allocation.
The method forms take and return pointers to structs. These forms are best used when you are transforming multiple coordinates and can reuse one or more of the structs. In this case reuse of structs will minimize allocations, and the struct pointers will pass more efficiently on the stack. These methods transform their arguments, placing the result in the receiver. The receiver is then returned for convenience.
Index ¶
- Variables
- func EclToEq(λ, β unit.Angle, sε, cε float64) (α unit.RA, δ unit.Angle)
- func EqToEcl(α unit.RA, δ unit.Angle, sε, cε float64) (λ, β unit.Angle)
- func EqToGal(α unit.RA, δ unit.Angle) (l, b unit.Angle)
- func EqToHz(α unit.RA, δ, φ, ψ unit.Angle, st unit.Time) (A, h unit.Angle)
- func GalToEq(l, b unit.Angle) (α unit.RA, δ unit.Angle)
- func HzToEq(A, h, φ, ψ unit.Angle, st unit.Time) (α unit.RA, δ unit.Angle)
- type Ecliptic
- type Equatorial
- type Galactic
- type Horizontal
- type Obliquity
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // IAU B1950.0 coordinates of galactic North Pole GalacticNorth1950 = &Equatorial{ RA: unit.NewRA(12, 49, 0), Dec: unit.AngleFromDeg(27.4), } // Meeus gives 33 as the origin of galactic longitudes relative to the // ascending node of of the galactic equator. 33 + 90 = 123, the IAU // value for origin relative to the equatorial pole. Galactic0Lon1950 = unit.AngleFromDeg(33) )
Functions ¶
func EclToEq ¶
EclToEq converts ecliptic coordinates to equatorial coordinates.
λ: ecliptic longitude coordinate to transform β: ecliptic latitude coordinate to transform sε: sine of obliquity of the ecliptic cε: cosine of obliquity of the ecliptic
Results:
α: right ascension赤经(时角) δ: declination赤纬
黄道转赤道
Example ¶
// Exercise, end of Example 13.a, p. 95.
α, δ := coord.EclToEq(
unit.AngleFromDeg(113.21563),
unit.AngleFromDeg(6.68417),
base.SOblJ2000,
base.COblJ2000)
fmt.Printf("α = %.3d, δ = %+.2d\n", sexa.FmtRA(α), sexa.FmtAngle(δ))
Output: α = 7ʰ45ᵐ18ˢ.946, δ = +28°1′34″.26
func EqToEcl ¶
EqToEcl converts equatorial coordinates to ecliptic coordinates.
α: right ascension coordinate to transform δ: declination coordinate to transform sε: sine of obliquity of the ecliptic cε: cosine of obliquity of the ecliptic
Results:
λ: ecliptic longitude黄经 β: ecliptic latitude黄纬 赤道转黄道
Example ¶
// Example 13.a, p. 95 but using precomputed obliquity sine and cosine.
λ, β := coord.EqToEcl(
unit.NewRA(7, 45, 18.946),
unit.NewAngle(' ', 28, 1, 34.26),
base.SOblJ2000, base.COblJ2000)
fmt.Printf("λ = %.5j\n", sexa.FmtAngle(λ))
fmt.Printf("β = %+.6j\n", sexa.FmtAngle(β))
Output: λ = 113°.21563 β = +6°.684170
func EqToGal ¶
EqToGal converts equatorial coordinates to galactic coordinates.
Equatorial coordinates must be referred to the standard equinox of B1950.0. For conversion to B1950, see package precess and utility functions in package "common". 赤道转银河
Example ¶
// Exercise, p. 96.
l, b := coord.EqToGal(
unit.NewRA(17, 48, 59.74),
unit.NewAngle('-', 14, 43, 8.2))
fmt.Printf("l = %.4j, b = %+.4j\n", sexa.FmtAngle(l), sexa.FmtAngle(b))
Output: l = 12°.9593, b = +6°.0463
func EqToHz ¶
EqToHz computes Horizontal coordinates from equatorial coordinates.
α: right ascension coordinate to transform δ: declination coordinate to transform φ: latitude of observer on Earth ψ: longitude of observer on Earth st: sidereal time at Greenwich at time of observation.
Sidereal time must be consistent with the equatorial coordinates. If coordinates are apparent, sidereal time must be apparent as well.
Results:
A: azimuth of observed point, measured westward from the South. h: elevation, or height of observed point above horizon.
赤道转地平
Example ¶
// Example 13.b, p. 95.
jd := julian.TimeToJD(time.Date(1987, 4, 10, 19, 21, 0, 0, time.UTC))
A, h := coord.EqToHz(
unit.NewRA(23, 9, 16.641),
unit.NewAngle('-', 6, 43, 11.61),
unit.NewAngle(' ', 38, 55, 17),
unit.NewAngle(' ', 77, 3, 56),
sidereal.Apparent(jd))
fmt.Printf("A = %+.3j\n", sexa.FmtAngle(A))
fmt.Printf("h = %+.3j\n", sexa.FmtAngle(h))
Output: A = +68°.034 h = +15°.125
func GalToEq ¶
GalToEq converts galactic coordinates to equatorial coordinates.
Resulting equatorial coordinates will be referred to the standard equinox of B1950.0. For subsequent conversion to other epochs, see package precess and utility functions in package meeus. 银河转赤道
Example ¶
// Exercise, p. 96, inverse
α, δ := coord.GalToEq(
unit.AngleFromDeg(12.9593), unit.AngleFromDeg(6.0463))
fmt.Printf("α = %.1d, δ = %+d\n", sexa.FmtRA(α), sexa.FmtAngle(δ))
Output: α = 17ʰ48ᵐ59ˢ.7, δ = -14°43′8″
func HzToEq ¶
HzToEq transforms horizontal coordinates to equatorial coordinates.
A: azimuth方位角 h: elevation仰角 φ: latitude of observer on Earth观测纬度 ψ: longitude of observer on Earth观测经度 st: sidereal time at Greenwich at time of observation.恒星时
Sidereal time must be consistent with the equatorial coordinates in the sense that tf coordinates are apparent, sidereal time must be apparent as well. 恒星时必须和所给条件保持一致
Results:
α: right ascension赤经(时角) δ: declination赤纬
地平转赤道
Example ¶
// Example 13.b, p. 95, inverse.
jd := julian.TimeToJD(time.Date(1987, 4, 10, 19, 21, 0, 0, time.UTC))
α, δ := coord.HzToEq(
unit.AngleFromDeg(68.0337),
unit.AngleFromDeg(15.1249),
unit.NewAngle(' ', 38, 55, 17),
unit.NewAngle(' ', 77, 3, 56),
sidereal.Apparent(jd))
fmt.Printf("α = %+.1d, δ = %+d\n", sexa.FmtRA(α), sexa.FmtAngle(δ))
Output: α = +23ʰ9ᵐ16ˢ.6, δ = -6°43′12″
Types ¶
type Ecliptic ¶
Ecliptic coordinates are referenced to the plane of the ecliptic. 黄道坐标结构
func (*Ecliptic) EqToEcl ¶
func (ecl *Ecliptic) EqToEcl(eq *Equatorial, ε *Obliquity) *Ecliptic
EqToEcl converts equatorial coordinates to ecliptic coordinates. 赤道转黄道
Example ¶
// Example 13.a, p. 95.
eq := &coord.Equatorial{
RA: unit.NewRA(7, 45, 18.946),
Dec: unit.NewAngle(' ', 28, 1, 34.26),
}
obl := coord.NewObliquity(unit.AngleFromDeg(23.4392911))
ecl := new(coord.Ecliptic).EqToEcl(eq, obl)
fmt.Printf("λ = %.5j\n", sexa.FmtAngle(ecl.Lon))
fmt.Printf("β = %+.6j\n", sexa.FmtAngle(ecl.Lat))
Output: λ = 113°.21563 β = +6°.684170
type Equatorial ¶
type Equatorial struct {
RA unit.RA // Right ascension (α)赤经(时角)
Dec unit.Angle // Declination (δ)赤纬
}
Equatorial coordinates are referenced to the Earth's rotational axis. 赤道坐标结构
func (*Equatorial) EclToEq ¶
func (eq *Equatorial) EclToEq(ecl *Ecliptic, ε *Obliquity) *Equatorial
EclToEq converts ecliptic coordinates to equatorial coordinates. 黄道转赤道
Example ¶
// Exercise, end of Example 13.a, p. 95.
ecl := &coord.Ecliptic{
Lon: unit.AngleFromDeg(113.21563),
Lat: unit.AngleFromDeg(6.68417),
}
ε := coord.NewObliquity(unit.AngleFromDeg(23.4392911))
eq := new(coord.Equatorial).EclToEq(ecl, ε)
fmt.Printf("α = %.3d, δ = %+.2d\n",
sexa.FmtRA(eq.RA), sexa.FmtAngle(eq.Dec))
Output: α = 7ʰ45ᵐ18ˢ.946, δ = +28°1′34″.26
func (*Equatorial) GalToEq ¶
func (eq *Equatorial) GalToEq(g *Galactic) *Equatorial
GalToEq converts galactic coordinates to equatorial coordinates.
Resulting equatorial coordinates will be referred to the standard equinox of B1950.0. For subsequent conversion to other epochs, see package precess and utility functions in package meeus. 银河转赤道
Example ¶
// Exercise, p. 96, inverse
g := &coord.Galactic{
Lon: unit.AngleFromDeg(12.9593),
Lat: unit.AngleFromDeg(6.0463),
}
eq := new(coord.Equatorial).GalToEq(g)
fmt.Printf("α = %.1d, δ = %+d\n", sexa.FmtRA(eq.RA), sexa.FmtAngle(eq.Dec))
Output: α = 17ʰ48ᵐ59ˢ.7, δ = -14°43′8″
func (*Equatorial) HzToEq ¶
func (eq *Equatorial) HzToEq(hz *Horizontal, g globe.Coord, st unit.Time) *Equatorial
HzToEq transforms horizontal coordinates to equatorial coordinates.
Sidereal time st must be consistent with the equatorial coordinates in the sense that if coordinates are apparent, sidereal time must be apparent as well. 地平转赤道
Example ¶
// Example 13.b, p. 95, inverse.
hz := &coord.Horizontal{
Az: unit.AngleFromDeg(68.0337),
Alt: unit.AngleFromDeg(15.1249),
}
g := globe.Coord{
Lat: unit.NewAngle(' ', 38, 55, 17),
Lon: unit.NewAngle(' ', 77, 3, 56),
}
jd := julian.TimeToJD(time.Date(1987, 4, 10, 19, 21, 0, 0, time.UTC))
eq := new(coord.Equatorial).HzToEq(hz, g, sidereal.Apparent(jd))
fmt.Printf("α = %+.1d, δ = %+d\n", sexa.FmtRA(eq.RA), sexa.FmtAngle(eq.Dec))
Output: α = +23ʰ9ᵐ16ˢ.6, δ = -6°43′12″
type Galactic ¶
type Galactic struct {
Lat unit.Angle // Latitude (b) in radians
Lon unit.Angle // Longitude (l) in radians
}
Galactic coordinates are referenced to the plane of the Milky Way. 银河坐标结构
func (*Galactic) EqToGal ¶
func (g *Galactic) EqToGal(eq *Equatorial) *Galactic
EqToGal converts equatorial coordinates to galactic coordinates.
Equatorial coordinates must be referred to the standard equinox of B1950.0. For conversion to B1950, see package precess and utility functions in package "unit". 赤道转银河
Example ¶
// Exercise, p. 96.
eq := &coord.Equatorial{
RA: unit.NewRA(17, 48, 59.74),
Dec: unit.NewAngle('-', 14, 43, 8.2),
}
g := new(coord.Galactic).EqToGal(eq)
fmt.Printf("l = %.4j, b = %+.4j\n",
sexa.FmtAngle(g.Lon), sexa.FmtAngle(g.Lat))
Output: l = 12°.9593, b = +6°.0463
type Horizontal ¶
Horizontal coordinates are referenced to the local horizon of an observer on the surface of the Earth. 地平坐标结构
func (*Horizontal) EqToHz ¶
func (hz *Horizontal) EqToHz(eq *Equatorial, g *globe.Coord, st unit.Time) *Horizontal
EqToHz computes Horizontal coordinates from equatorial coordinates.
Argument g is the location of the observer on the Earth. Argument st is the sidereal time at Greenwich.
Sidereal time must be consistent with the equatorial coordinates. If coordinates are apparent, sidereal time must be apparent as well. 赤道转地平
Example ¶
// Example 13.b, p. 95.
eq := &coord.Equatorial{
RA: unit.NewRA(23, 9, 16.641),
Dec: unit.NewAngle('-', 6, 43, 11.61),
}
g := &globe.Coord{
Lat: unit.NewAngle(' ', 38, 55, 17),
Lon: unit.NewAngle(' ', 77, 3, 56),
}
jd := julian.TimeToJD(time.Date(1987, 4, 10, 19, 21, 0, 0, time.UTC))
st := sidereal.Apparent(jd)
hz := new(coord.Horizontal).EqToHz(eq, g, st)
fmt.Printf("A = %+.3j\n", sexa.FmtAngle(hz.Az))
fmt.Printf("h = %+.3j\n", sexa.FmtAngle(hz.Alt))
Output: A = +68°.034 h = +15°.125
type Obliquity ¶
type Obliquity struct {
S, C float64 // sine and cosine of obliquity
}
Obliquity represents the obliquity of the ecliptic. 黄赤交角对应的 sin,cos 值
func NewObliquity ¶
NewObliquity constructs a new Obliquity.
Struct members are initialized from the given value ε of the obliquity of the ecliptic. 计算黄赤交角对应的 sin,cos 值