Esempio n. 1
0
func xyz(e *pp.V87Planet, jde float64) (x, y, z float64) {
	l, b, r := e.Position2000(jde)
	s := l + math.Pi
	β := -b
	ss, cs := math.Sincos(s)
	sβ, cβ := math.Sincos(β)
	// (26.2) p. 172
	x = r * cβ * cs
	y = r * cβ * ss
	z = r * sβ
	return
}
Esempio n. 2
0
func ap2a(j1, d float64, a bool, v *pp.V87Planet) (jde, r float64) {
	// Meeus doesn't give a complete algorithm for finding accurate answers.
	// The algorithm here starts with the approximate result algorithm
	// then crawls along the curve at resultion d until three points
	// are found containing the desired extremum.  It's slow if the starting
	// point is far away (the case of Neptune) or if high accuracy is
	// demanded.  1 day accuracy is generally quick.
	j0 := j1 - d
	j2 := j1 + d
	rr := make([]float64, 3)
	_, _, rr[0] = v.Position2000(j0)
	_, _, rr[1] = v.Position2000(j1)
	_, _, rr[2] = v.Position2000(j2)
	for {
		if a {
			if rr[1] > rr[0] && rr[1] > rr[2] {
				break
			}
		} else {
			if rr[1] < rr[0] && rr[1] < rr[2] {
				break
			}
		}
		if rr[0] < rr[2] == a {
			j0 = j1
			j1 = j2
			j2 += d
			rr[0] = rr[1]
			rr[1] = rr[2]
			_, _, rr[2] = v.Position2000(j2)
		} else {
			j2 = j1
			j1 = j0
			j0 -= d
			rr[2] = rr[1]
			rr[1] = rr[0]
			_, _, rr[0] = v.Position2000(j0)
		}
	}
	l, err := interp.NewLen3(j0, j2, rr)
	if err != nil {
		panic(err) // unexpected.
	}
	jde, r, err = l.Extremum()
	if err != nil {
		panic(err) // unexpected.
	}
	return
}
Esempio n. 3
0
func ap2a(j1, d float64, a bool, v *pp.V87Planet) (jde, r float64) {
	j0 := j1 - d
	j2 := j1 + d
	rr := make([]float64, 3)
	_, _, rr[0] = v.Position2000(j0)
	_, _, rr[1] = v.Position2000(j1)
	_, _, rr[2] = v.Position2000(j2)
	for {
		if a {
			if rr[1] > rr[0] && rr[1] > rr[2] {
				break
			}
		} else {
			if rr[1] < rr[0] && rr[1] < rr[2] {
				break
			}
		}
		if rr[0] < rr[2] == a {
			j0 = j1
			j1 = j2
			j2 += d
			rr[0] = rr[1]
			rr[1] = rr[2]
			_, _, rr[2] = v.Position2000(j2)
		} else {
			j2 = j1
			j1 = j0
			j0 -= d
			rr[2] = rr[1]
			rr[1] = rr[0]
			_, _, rr[0] = v.Position2000(j0)
		}
	}
	l, err := interp.NewLen3(j0, j2, rr)
	if err != nil {
		panic(err) // unexpected.
	}
	jde, r, err = l.Extremum()
	if err != nil {
		panic(err) // unexpected.
	}
	return
}
Esempio n. 4
0
// LongitudeJ2000 returns geometric longitude referenced to equinox J2000.
func LongitudeJ2000(e *pp.V87Planet, jde float64) (l float64) {
	l, _, _ = e.Position2000(jde)
	return base.PMod(l+math.Pi-.09033/3600*math.Pi/180, 2*math.Pi)
}
Esempio n. 5
0
// LongitudeJ2000 returns geometric longitude referenced to equinox J2000.
func LongitudeJ2000(e *pp.V87Planet, jde float64) (l unit.Angle) {
	l, _, _ = e.Position2000(jde)
	return (l + math.Pi - unit.AngleFromSec(.09033)).Mod1()
}