Exemplo n.º 1
0
func ExampleKepler2b() {
	// Example data from p. 205
	E, err := kepler.Kepler2b(.99, .2, 14)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("%.12f\n", E)
	// Output:
	// 1.066997365282
}
Exemplo n.º 2
0
// Position returns observed equatorial coordinates of a body with Keplerian elements.
//
// Argument e must be a valid V87Planet object for Earth.
//
// Results are right ascension and declination α and δ, and elongation ψ,
// all in radians.
func (k *Elements) Position(jde float64, e *pp.V87Planet) (α, δ, ψ float64) {
	// (33.6) p. 227
	n := base.K / k.Axis / math.Sqrt(k.Axis)
	const sε = base.SOblJ2000
	const cε = base.COblJ2000
	sΩ, cΩ := math.Sincos(k.Node)
	si, ci := math.Sincos(k.Inc)
	// (33.7) p. 228
	F := cΩ
	G := sΩ * cε
	H := sΩ * sε
	P := -sΩ * ci
	Q := cΩ*ci*cε - si*sε
	R := cΩ*ci*sε + si*cε
	// (33.8) p. 229
	A := math.Atan2(F, P)
	B := math.Atan2(G, Q)
	C := math.Atan2(H, R)
	a := math.Hypot(F, P)
	b := math.Hypot(G, Q)
	c := math.Hypot(H, R)

	f := func(jde float64) (x, y, z float64) {
		M := n * (jde - k.TimeP)
		E, err := kepler.Kepler2b(k.Ecc, M, 15)
		if err != nil {
			E = kepler.Kepler3(k.Ecc, M)
		}
		ν := kepler.True(E, k.Ecc)
		r := kepler.Radius(E, k.Ecc, k.Axis)
		// (33.9) p. 229
		x = r * a * math.Sin(A+k.ArgP+ν)
		y = r * b * math.Sin(B+k.ArgP+ν)
		z = r * c * math.Sin(C+k.ArgP+ν)
		return
	}
	return AstrometricJ2000(f, jde, e)
}