Esempio n. 1
0
func ExampleGeneral_b() {
	// Example 58.b, p. 404.
	const p = math.Pi / 180
	ls, c, _, ψ := sundial.General(
		unit.AngleFromDeg(-35),
		unit.AngleFromDeg(160),
		1,
		unit.AngleFromDeg(90))
	for _, l := range ls {
		if l.Hour == 12 {
			fmt.Printf("%d:  x = %+.4f  y = %+.4f\n",
				l.Hour, l.Points[5].X, l.Points[5].Y)
		}
		if l.Hour == 15 {
			fmt.Printf("%d:  x = %+.4f  y = %+.4f\n",
				l.Hour, l.Points[3].X, l.Points[3].Y)
		}
	}
	fmt.Printf("x0 = %+.4f\n", c.X)
	fmt.Printf("y0 = %+.4f\n", c.Y)
	fmt.Printf("ψ = %.4f\n", ψ.Deg())
	// Output:
	// 12:  x = +0.3640  y = -0.7410
	// 15:  x = -0.8439  y = -0.9298
	// x0 = +0.3640
	// y0 = +0.7451
	// ψ = 50.3315
}
Esempio n. 2
0
func ExampleApparentEccentricity() {
	// Example 57.b, p. 400
	fmt.Printf("%.3f\n", binary.ApparentEccentricity(.2763,
		unit.AngleFromDeg(59.025), unit.AngleFromDeg(219.907)))
	// Output:
	// 0.860
}
Esempio n. 3
0
func ExampleGeneral_a() {
	// Example 58.a, p. 404.
	ls, c, _, ψ := sundial.General(
		unit.AngleFromDeg(40),
		unit.AngleFromDeg(70),
		1,
		unit.AngleFromDeg(50))
	fmt.Printf("Hours:  %d", ls[0].Hour)
	for _, l := range ls[1:] {
		fmt.Printf(", %d", l.Hour)
	}
	fmt.Println()
	for _, l := range ls {
		if l.Hour == 11 {
			fmt.Printf("%d:  x = %.4f  y = %.4f\n",
				l.Hour, l.Points[2].X, l.Points[2].Y)
		}
		if l.Hour == 14 {
			fmt.Printf("%d:  x = %.4f  y = %.4f\n",
				l.Hour, l.Points[6].X, l.Points[6].Y)
		}
	}
	fmt.Printf("x0 = %+.4f\n", c.X)
	fmt.Printf("y0 = %+.4f\n", c.Y)
	fmt.Printf("ψ = %.4f\n", ψ.Deg())
	// Output:
	// Hours:  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
	// 11:  x = -2.0007  y = -1.1069
	// 14:  x = -0.0390  y = -0.3615
	// x0 = +3.3880
	// y0 = -3.1102
	// ψ = 12.2672
}
Esempio n. 4
0
func ExampleElements_Position() {
	// Example 33.b, p. 232.
	earth, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	k := &elliptic.Elements{
		TimeP: julian.CalendarGregorianToJD(1990, 10, 28.54502),
		Axis:  2.2091404,
		Ecc:   .8502196,
		Inc:   unit.AngleFromDeg(11.94524),
		Node:  unit.AngleFromDeg(334.75006),
		ArgP:  unit.AngleFromDeg(186.23352),
	}
	j := julian.CalendarGregorianToJD(1990, 10, 6)
	α, δ, ψ := k.Position(j, earth)
	fmt.Printf("α = %.1d\n", sexa.FmtRA(α))
	fmt.Printf("δ = %.0d\n", sexa.FmtAngle(δ))
	fmt.Printf("ψ = %.2f\n", ψ.Deg())
	// Output:
	// α = 10ʰ34ᵐ14ˢ.2
	// δ = 19°9′31″
	// ψ = 40.51
}
Esempio n. 5
0
func ExampleSaturn() {
	// Example 41.d, p. 285
	v := illum.Saturn(9.867882, 10.464606,
		unit.AngleFromDeg(16.442), unit.AngleFromDeg(4.198))
	fmt.Printf("%+.1f\n", v)
	// Output:
	// +0.9
}
Esempio n. 6
0
func ExamplePhaseAngle3() {
	// Example 41.a, p. 284
	i := illum.PhaseAngle3(
		unit.AngleFromDeg(26.10588),
		unit.AngleFromDeg(-2.62102),
		.621794, -.664905, -.033138, .910947)
	fmt.Printf("%.5f\n", i.Cos())
	// Output:
	// 0.29312
}
Esempio n. 7
0
// True returns true geometric longitude and anomaly of the sun referenced to the mean equinox of date.
//
// Argument T is the number of Julian centuries since J2000.
// See base.J2000Century.
//
// Results:
//	s = true geometric longitude, ☉
//	ν = true anomaly
func True(T float64) (s, ν unit.Angle) {
	// (25.2) p. 163
	L0 := unit.AngleFromDeg(base.Horner(T, 280.46646, 36000.76983, 0.0003032))
	M := MeanAnomaly(T)
	C := unit.AngleFromDeg(base.Horner(T, 1.914602, -0.004817, -.000014)*
		M.Sin() +
		(0.019993-.000101*T)*M.Mul(2).Sin() +
		0.000289*M.Mul(3).Sin())
	return (L0 + C).Mod1(), (M + C).Mod1()
}
Esempio n. 8
0
// Mean returns mean orbital elements for a planet
//
// Argument p must be a planet const as defined above, argument e is
// a result parameter.  A valid non-nil pointer to an Elements struct
// must be passed in.
//
// Results are referenced to mean dynamical ecliptic and equinox of date.
//
// Semimajor axis is in AU, angular elements are in radians.
func Mean(p int, jde float64, e *Elements) {
	T := base.J2000Century(jde)
	c := &cMean[p]
	e.Lon = unit.AngleFromDeg(base.Horner(T, c.L...)).Mod1()
	e.Axis = base.Horner(T, c.a...)
	e.Ecc = base.Horner(T, c.e...)
	e.Inc = unit.AngleFromDeg(base.Horner(T, c.i...))
	e.Node = unit.AngleFromDeg(base.Horner(T, c.Ω...))
	e.Peri = unit.AngleFromDeg(base.Horner(T, c.ϖ...))
}
Esempio n. 9
0
func ExampleLimb() {
	// Example 48.a, p. 347.
	χ := base.Limb(
		unit.RAFromDeg(134.6885),
		unit.AngleFromDeg(13.7684),
		unit.RAFromDeg(20.6579),
		unit.AngleFromDeg(8.6964))
	fmt.Printf("χ = %.1f\n", χ.Deg())
	// Output:
	// χ = 285.0
}
Esempio n. 10
0
func ExamplePhaseAngleEq2() {
	i := moonillum.PhaseAngleEq2(
		unit.RAFromDeg(134.6885),
		unit.AngleFromDeg(13.7684),
		unit.RAFromDeg(20.6579),
		unit.AngleFromDeg(8.6964))
	k := base.Illuminated(i)
	fmt.Printf("k = %.4f\n", k)
	// Output:
	// k = 0.6775
}
Esempio n. 11
0
func ExamplePhaseAngleEq() {
	i := moonillum.PhaseAngleEq(
		unit.RAFromDeg(134.6885),
		unit.AngleFromDeg(13.7684),
		368410,
		unit.RAFromDeg(20.6579),
		unit.AngleFromDeg(8.6964),
		149971520)
	fmt.Printf("i = %.4f\n", i.Deg())
	// Output:
	// i = 69.0756
}
Esempio n. 12
0
func ExamplePhaseAngle2() {
	// Example 41.a, p. 284
	i := illum.PhaseAngle2(
		unit.AngleFromDeg(26.10588),
		unit.AngleFromDeg(-2.62102),
		.724604,
		unit.AngleFromDeg(88.35704),
		.983824, .910947)
	fmt.Printf("%.5f\n", i.Cos())
	// Output:
	// 0.29312
}
Esempio n. 13
0
func ExampleEclipticAtHorizon() {
	ε := unit.AngleFromDeg(23.44)
	φ := unit.AngleFromDeg(51)
	θ := unit.TimeFromHour(5)
	λ1, λ2, I := parallactic.EclipticAtHorizon(ε, φ, θ)
	fmt.Println(sexa.FmtAngle(λ1))
	fmt.Println(sexa.FmtAngle(λ2))
	fmt.Println(sexa.FmtAngle(I))
	// Output:
	// 169°21′30″
	// 349°21′30″
	// 61°53′14″
}
Esempio n. 14
0
func ExampleSunAltitude() {
	j := julian.CalendarGregorianToJD(1992, 4, 12)
	earth, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	_, _, _, l0, b0 := moon.Physical(j, earth)
	h := moon.SunAltitude(
		unit.AngleFromDeg(-20), unit.AngleFromDeg(9.7), l0, b0)
	fmt.Printf("%+.3f\n", h.Deg())
	// Output:
	// +2.318
}
Esempio n. 15
0
func ExampleSunrise() {
	earth, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	j0 := julian.CalendarGregorianToJD(1992, 4, 15)
	j := moon.Sunrise(
		unit.AngleFromDeg(-20), unit.AngleFromDeg(9.7), j0, earth)
	y, m, d := julian.JDToCalendar(j)
	fmt.Printf("%d %s %.4f TD\n", y, time.Month(m), d)
	// Output:
	// 1992 April 11.8069 TD
}
Esempio n. 16
0
func TestDiurnalPathAtHorizon(t *testing.T) {
	φ := unit.AngleFromDeg(40)
	ε := unit.AngleFromDeg(23.44)
	J := parallactic.DiurnalPathAtHorizon(0, φ)
	Jexp := math.Pi/2 - φ
	if math.Abs((J-Jexp).Rad()/Jexp.Rad()) > 1e-15 {
		t.Fatal("0 dec:", sexa.FmtAngle(J))
	}
	J = parallactic.DiurnalPathAtHorizon(ε, φ)
	Jexp = unit.NewAngle(' ', 45, 31, 0)
	if math.Abs((J-Jexp).Rad()/Jexp.Rad()) > 1e-3 {
		t.Fatal("solstice:", sexa.FmtAngle(J))
	}
}
Esempio n. 17
0
func ExampleGeneral_c() {
	// Example 58.c, p. 405.
	ls, _, _, _ := sundial.General(
		unit.AngleFromDeg(40),
		unit.AngleFromDeg(160),
		1,
		unit.AngleFromDeg(75))
	fmt.Printf("Hours:  %d", ls[0].Hour)
	for _, l := range ls[1:] {
		fmt.Printf(", %d", l.Hour)
	}
	fmt.Println()
	// Output:
	// Hours:  5, 6, 13, 14, 15, 16, 17, 18, 19
}
Esempio n. 18
0
func ExampleEclipticPosition() {
	// Example 21.c, p. 137.
	eclFrom := &coord.Ecliptic{
		Lat: unit.AngleFromDeg(1.76549),
		Lon: unit.AngleFromDeg(149.48194),
	}
	eclTo := &coord.Ecliptic{}
	epochFrom := 2000.0
	epochTo := base.JDEToJulianYear(julian.CalendarJulianToJD(-214, 6, 30))
	precess.EclipticPosition(eclFrom, eclTo, epochFrom, epochTo, 0, 0)
	fmt.Printf("%.3f\n", eclTo.Lon.Deg())
	fmt.Printf("%+.3f\n", eclTo.Lat.Deg())
	// Output:
	// 118.704
	// +1.615
}
Esempio n. 19
0
// PhaseAngle3 computes the phase angle of the Moon given a julian day.
//
// Less accurate than PhaseAngle functions taking coordinates.
func PhaseAngle3(jde float64) unit.Angle {
	T := base.J2000Century(jde)
	D := unit.AngleFromDeg(base.Horner(T, 297.8501921,
		445267.1114034, -.0018819, 1/545868, -1/113065000)).Mod1().Rad()
	M := unit.AngleFromDeg(base.Horner(T,
		357.5291092, 35999.0502909, -.0001535, 1/24490000)).Mod1().Rad()
	Mʹ := unit.AngleFromDeg(base.Horner(T, 134.9633964,
		477198.8675055, .0087414, 1/69699, -1/14712000)).Mod1().Rad()
	return math.Pi - unit.Angle(D) + unit.AngleFromDeg(
		-6.289*math.Sin(Mʹ)+
			2.1*math.Sin(M)+
			-1.274*math.Sin(2*D-Mʹ)+
			-.658*math.Sin(2*D)+
			-.214*math.Sin(2*Mʹ)+
			-.11*math.Sin(D))
}
Esempio n. 20
0
func ExampleVenus() {
	// Example 41.c, p. 285
	v := illum.Venus(.724604, .910947, unit.AngleFromDeg(72.96))
	fmt.Printf("%.1f\n", v)
	// Output:
	// -3.8
}
Esempio n. 21
0
func ExampleReduceB1950FK4ToJ2000FK5() {
	// Example 24.c, p. 162.
	ele := &elementequinox.Elements{
		Inc:  unit.AngleFromDeg(11.93911),
		Node: unit.AngleFromDeg(334.04096),
		Peri: unit.AngleFromDeg(186.24444),
	}
	elementequinox.ReduceB1950FK4ToJ2000FK5(ele, ele)
	fmt.Printf("i  %.5f\n", ele.Inc.Deg())
	fmt.Printf("Ω  %.5f\n", ele.Node.Deg())
	fmt.Printf("ω  %.5f\n", ele.Peri.Deg())
	// Output:
	// i  11.94521
	// Ω  334.75043
	// ω  186.23327
}
Esempio n. 22
0
func ExampleTimes() {
	// Example 15.a, p. 103.
	// Venus on 1988 March 20
	p := globe.Coord{
		Lon: unit.NewAngle(' ', 71, 5, 0),
		Lat: unit.NewAngle(' ', 42, 20, 0),
	}
	Th0 := unit.NewTime(' ', 11, 50, 58.1)
	α3 := []unit.RA{
		unit.NewRA(2, 42, 43.25),
		unit.NewRA(2, 46, 55.51),
		unit.NewRA(2, 51, 07.69),
	}
	δ3 := []unit.Angle{
		unit.NewAngle(' ', 18, 02, 51.4),
		unit.NewAngle(' ', 18, 26, 27.3),
		unit.NewAngle(' ', 18, 49, 38.7),
	}
	h0 := unit.AngleFromDeg(-.5667)
	ΔT := unit.Time(56)
	tRise, tTransit, tSet, err := rise.Times(p, ΔT, h0, Th0, α3, δ3)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("rising:  %+.5f %02s\n", tRise/86400, sexa.FmtTime(tRise))
	fmt.Printf("transit: %+.5f %02s\n", tTransit/86400, sexa.FmtTime(tTransit))
	fmt.Printf("seting:  %+.5f %02s\n", tSet/86400, sexa.FmtTime(tSet))
	// Output:
	// rising:  +0.51766  12ʰ25ᵐ26ˢ
	// transit: +0.81980  19ʰ40ᵐ30ˢ
	// seting:  +0.12130  02ʰ54ᵐ40ˢ
}
Esempio n. 23
0
func ExampleIlluminated_moon() {
	// Example 48.a, p. 347.
	k := base.Illuminated(unit.AngleFromDeg(69.0756))
	fmt.Printf("k = %.4f\n", k)
	// Output:
	// k = 0.6786
}
Esempio n. 24
0
// ReduceB1950ToJ2000 reduces orbital elements of a solar system body from
// equinox B1950 to J2000.
func ReduceB1950ToJ2000(eFrom, eTo *Elements) *Elements {
	// (24.4) p. 161
	const S = .0001139788
	const C = .9999999935
	W := eFrom.Node - unit.AngleFromDeg(174.298782)
	si, ci := eFrom.Inc.Sincos()
	sW, cW := W.Sincos()
	A := si * sW
	B := C*si*cW - S*ci
	eTo.Inc = unit.Angle(math.Asin(math.Hypot(A, B)))
	eTo.Node = (unit.AngleFromDeg(174.997194) +
		unit.Angle(math.Atan2(A, B))).Mod1()
	eTo.Peri = (eFrom.Peri +
		unit.Angle(math.Atan2(-S*sW, C*si-S*ci*cW))).Mod1()
	return eTo
}
Esempio n. 25
0
// Position returns geocentric location of the Moon.
//
// Results are referenced to mean equinox of date and do not include
// the effect of nutation.
//
//	λ  Geocentric longitude.
//	β  Geocentric latidude.
//	Δ  Distance between centers of the Earth and Moon, in km.
func Position(jde float64) (λ, β unit.Angle, Δ float64) {
	T := base.J2000Century(jde)
	Lʹ := base.Horner(T, 218.3164477*p, 481267.88123421*p,
		-.0015786*p, p/538841, -p/65194000)
	D, M, Mʹ, F := dmf(T)
	A1 := 119.75*p + 131.849*p*T
	A2 := 53.09*p + 479264.29*p*T
	A3 := 313.45*p + 481266.484*p*T
	E := base.Horner(T, 1, -.002516, -.0000074)
	E2 := E * E
	Σl := 3958*math.Sin(A1) + 1962*math.Sin(Lʹ-F) + 318*math.Sin(A2)
	Σr := 0.
	Σb := -2235*math.Sin(Lʹ) + 382*math.Sin(A3) + 175*math.Sin(A1-F) +
		175*math.Sin(A1+F) + 127*math.Sin(Lʹ-Mʹ) - 115*math.Sin(Lʹ+Mʹ)
	for i := range ta {
		r := &ta[i]
		sa, ca := math.Sincos(D*r.D + M*r.M + Mʹ*r.Mʹ + F*r.F)
		switch r.M {
		case 0:
			Σl += r.Σl * sa
			Σr += r.Σr * ca
		case 1, -1:
			Σl += r.Σl * sa * E
			Σr += r.Σr * ca * E
		case 2, -2:
			Σl += r.Σl * sa * E2
			Σr += r.Σr * ca * E2
		}
	}
	for i := range tb {
		r := &tb[i]
		sb := math.Sin(D*r.D + M*r.M + Mʹ*r.Mʹ + F*r.F)
		switch r.M {
		case 0:
			Σb += r.Σb * sb
		case 1, -1:
			Σb += r.Σb * sb * E
		case 2, -2:
			Σb += r.Σb * sb * E2
		}
	}
	λ = unit.Angle(Lʹ).Mod1() + unit.AngleFromDeg(Σl*1e-6)
	β = unit.AngleFromDeg(Σb * 1e-6)
	Δ = 385000.56 + Σr*1e-3
	return
}
Esempio n. 26
0
// Heliocentric returns J2000 heliocentric coordinates of Pluto.
//
// Results l, b are solar longitude and latitude in radians.
// Result r is distance in AU.
func Heliocentric(jde float64) (l, b unit.Angle, r float64) {
	T := base.J2000Century(jde)
	J := unit.AngleFromDeg(34.35 + 3034.9057*T)
	S := unit.AngleFromDeg(50.08 + 1222.1138*T)
	P := unit.AngleFromDeg(238.96 + 144.96*T)
	for i := range t37 {
		t := &t37[i]
		sα, cα := (J.Mul(t.i) + S.Mul(t.j) + P.Mul(t.k)).Sincos()
		l += t.lA.Mul(sα) + t.lB.Mul(cα)
		b += t.bA.Mul(sα) + t.bB.Mul(cα)
		r += t.rA*sα + t.rB*cα
	}
	l += unit.AngleFromDeg(238.958116 + 144.96*T)
	b -= unit.AngleFromDeg(3.908239)
	r += 40.7241346
	return
}
Esempio n. 27
0
func ExampleKepler4() {
	// Input data from example 30.a, p. 196,
	// result from p. 207
	E := kepler.Kepler4(.1, unit.AngleFromDeg(5))
	fmt.Printf("%.6f\n", E.Deg())
	// Output:
	// 5.554599
}
Esempio n. 28
0
// TrueNode returns longitude of the true ascending node.
//
// That is, the node of the instantaneous lunar orbit.
func TrueNode(jde float64) unit.Angle {
	D, M, Mʹ, F := dmf(base.J2000Century(jde))
	return Node(jde) + unit.AngleFromDeg(
		-1.4979*math.Sin(2*(D-F))+
			-.15*math.Sin(M)+
			-.1226*math.Sin(2*D)+
			.1176*math.Sin(2*F)+
			-.0801*math.Sin(2*(Mʹ-F)))
}
Esempio n. 29
0
// Second exercise, p. 110.
func TestMinSep(t *testing.T) {
	sep, err := angle.MinSep(jd1, jd3, r1, d1, r2, d2)
	if err != nil {
		t.Fatal(err)
	}
	answer := unit.AngleFromDeg(.5017) // on p. 111
	if math.Abs((sep-answer).Rad()/sep.Rad()) > 1e-3 {
		t.Fatal(sep, answer)
	}
}
Esempio n. 30
0
func ExampleEclipticPrecessor_ReduceElements() {
	// Example 24.a, p. 160.
	ele := &elementequinox.Elements{
		Inc:  unit.AngleFromDeg(47.122),
		Peri: unit.AngleFromDeg(151.4486),
		Node: unit.AngleFromDeg(45.7481),
	}
	JFrom := base.JDEToJulianYear(base.BesselianYearToJDE(1744))
	JTo := base.JDEToJulianYear(base.BesselianYearToJDE(1950))
	p := precess.NewEclipticPrecessor(JFrom, JTo)
	p.ReduceElements(ele, ele)
	fmt.Printf("i = %.4f\n", ele.Inc.Deg())
	fmt.Printf("Ω = %.4f\n", ele.Node.Deg())
	fmt.Printf("ω = %.4f\n", ele.Peri.Deg())
	// Output:
	// i = 47.1380
	// Ω = 48.6037
	// ω = 151.4782
}