globe

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: MIT Imports: 2 Imported by: 8

Documentation

Overview

Globe: Chapter 11, The Earth's Globe.

Globe contains functions concerning the surface of the Earth idealized as an ellipsoid of revolution.

Index

Examples

Constants

View Source
const RotationRate1996_5 = 7.292114992e-5

RotationRate1996_5 is the rotational angular velocity of the Earth with respect to the stars at the epoch 1996.5.

Unit is radian/second.

Variables

View Source
var Earth76 = Ellipsoid{Er: 6378.14, Fl: 1 / 298.257}

IAU 1976 values. Radius in Km.

Functions

func ApproxAngularDistance

func ApproxAngularDistance(p1, p2 Coord) float64

ApproxAngularDistance returns the cosine of the angle between two points.

The accuracy deteriorates at small angles.

func ApproxLinearDistance

func ApproxLinearDistance(d unit.Angle) float64

ApproxLinearDistance computes a distance across the surface of the Earth.

Approximating the Earth as a sphere, the function takes a geocentric angular distance and returns the corresponding linear distance in Km.

func GeocentricLatitudeDifference

func GeocentricLatitudeDifference(φ unit.Angle) unit.Angle

GeocentricLatitudeDifference returns geographic latitude - geocentric latitude (φ - φ′) given geographic latitude (φ).

func OneDegreeOfLatitude

func OneDegreeOfLatitude(rm float64) float64

OneDegreeOfLatitude returns the length of one degree of latitude.

Argument rm is the radius of curvature along a meridian. (as returned by Ellipsoid.RadiusOfCurvature.) Result is distance in units of rm along one degree of the meridian.

func OneDegreeOfLongitude

func OneDegreeOfLongitude(rp float64) float64

OneDegreeOfLongitude returns the length of one degree of longitude.

Argument rp is the radius of a circle that is a parallel of latitude (as returned by Ellipsoid.RadiusAtLatitude.)

Result is distance along one degree of the circle, in same units as rp.

func Rho

func Rho(φ unit.Angle) float64

Rho is distance from Earth center to a point on the ellipsoid at latitude φ.

Result unit is fraction of the equatorial radius.

Types

type Coord

type Coord struct {
	Lat unit.Angle // latitude (φ)
	Lon unit.Angle // longitude (ψ, or L)
}

Coord represents geographic coordinates on the Earth.

Longitude is measured positively westward from the Greenwich meridian.

type Ellipsoid

type Ellipsoid struct {
	Er float64 // equatorial radius
	Fl float64 // flattening
}

Ellipsoid represents an ellipsoid of revolution.

Typical unit for Er is Km.

func (Ellipsoid) A

func (e Ellipsoid) A() float64

A returns equatorial radius in units of e.Er.

A is a common identifier for equatorial radius.

func (Ellipsoid) B

func (e Ellipsoid) B() float64

B returns polar radius in units of e.ER.

B is a common identifier for polar radius.

func (Ellipsoid) Distance

func (e Ellipsoid) Distance(c1, c2 Coord) float64

Distance is distance between two points measured along the surface of an ellipsoid.

Accuracy is much better than that of ApproxAngularDistance or ApproxLinearDistance.

Result unit is units of e.Er, typically Km.

Example
// Example 11.c p 85.
c1 := globe.Coord{
	unit.NewAngle(' ', 48, 50, 11), // geographic latitude
	unit.NewAngle('-', 2, 20, 14),  // geographic longitude
}
c2 := globe.Coord{
	unit.NewAngle(' ', 38, 55, 17),
	unit.NewAngle(' ', 77, 3, 56),
}
fmt.Printf("%.2f km\n", globe.Earth76.Distance(c1, c2))
cos := globe.ApproxAngularDistance(c1, c2)
fmt.Printf("cos d = %.6f\n", cos)
d := unit.Angle(math.Acos(cos))
fmt.Printf("    d = %.5j\n", sexa.FmtAngle(d))
fmt.Printf("    s = %.0f km\n", globe.ApproxLinearDistance(d))
Output:

6181.63 km
cos d = 0.567146
    d = 55°.44855
    s = 6166 km

func (Ellipsoid) Eccentricity

func (e Ellipsoid) Eccentricity() float64

Eccentricity of a meridian.

func (Ellipsoid) ParallaxConstants

func (e Ellipsoid) ParallaxConstants(φ unit.Angle, h float64) (s, c float64)

ParallaxConstants computes parallax constants ρ sin φ′ and ρ cos φ′.

Arguments are geographic latitude φ and height h above the ellipsoid. For e.Er in Km, h must be in meters.

Example
package main

import (
	"fmt"

	"github.com/soniakeys/meeus/v3/globe"
	"github.com/soniakeys/unit"
)

func main() {
	// Example 11.a, p 82.
	// phi = geographic latitude of Palomar
	φ := unit.NewAngle(' ', 33, 21, 22)
	s, c := globe.Earth76.ParallaxConstants(φ, 1706)
	fmt.Printf("ρ sin φ′ = %+.6f\n", s)
	fmt.Printf("ρ cos φ′ = %+.6f\n", c)
}
Output:

ρ sin φ′ = +0.546861
ρ cos φ′ = +0.836339

func (Ellipsoid) RadiusAtLatitude

func (e Ellipsoid) RadiusAtLatitude(φ unit.Angle) float64

RadiusAtLatitude returns the radius of the circle that is the parallel of latitude φ.

Result unit is same as e.Er (typically Km.)

Example
package main

import (
	"fmt"

	"github.com/soniakeys/meeus/v3/globe"
	"github.com/soniakeys/unit"
)

func main() {
	// Example 11.b p 84.
	φ := unit.AngleFromDeg(42)
	rp := globe.Earth76.RadiusAtLatitude(φ)
	fmt.Printf("Rp = %.3f km\n", rp)
	fmt.Printf("1° of longitude = %.4f km\n", globe.OneDegreeOfLongitude(rp))
	fmt.Printf("linear velocity = ωRp = %.5f km/second\n",
		rp*globe.RotationRate1996_5)
	rm := globe.Earth76.RadiusOfCurvature(φ)
	fmt.Printf("Rm = %.3f km\n", rm)
	fmt.Printf("1° of latitude = %.4f km\n", globe.OneDegreeOfLatitude(rm))
}
Output:

Rp = 4747.001 km
1° of longitude = 82.8508 km
linear velocity = ωRp = 0.34616 km/second
Rm = 6364.033 km
1° of latitude = 111.0733 km

func (Ellipsoid) RadiusOfCurvature

func (e Ellipsoid) RadiusOfCurvature(φ unit.Angle) float64

RadiusOfCurvature of meridian at latitude φ.

Result in units of e.ER, typically Km.

Jump to

Keyboard shortcuts

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