예제 #1
0
파일: precess_test.go 프로젝트: pjh59/meeus
// Exercise, p. 136.
func TestPosition(t *testing.T) {
	eqFrom := &coord.Equatorial{
		base.NewRA(2, 31, 48.704).Rad(),
		base.NewAngle(false, 89, 15, 50.72).Rad(),
	}
	eqTo := &coord.Equatorial{}
	mα := base.NewHourAngle(false, 0, 0, 0.19877)
	mδ := base.NewAngle(true, 0, 0, 0.0152)
	for _, tc := range []struct {
		α, δ string
		jde  float64
	}{
		{"1 22 33.90", "88 46 26.18", base.BesselianYearToJDE(1900)},
		{"3 48 16.43", "89 27 15.38", base.JulianYearToJDE(2050)},
		{"5 53 29.17", "89 32 22.18", base.JulianYearToJDE(2100)},
	} {
		epochTo := base.JDEToJulianYear(tc.jde)
		precess.Position(eqFrom, eqTo, 2000.0, epochTo, mα, mδ)
		αStr := fmt.Sprintf("%.2x", base.NewFmtRA(eqTo.RA))
		δStr := fmt.Sprintf("%.2x", base.NewFmtAngle(eqTo.Dec))
		if αStr != tc.α {
			t.Fatal("got:", αStr, "want:", tc.α)
		}
		if δStr != tc.δ {
			t.Fatal(δStr)
		}
	}
}
예제 #2
0
// Exercise, p. 136.
func TestPosition(t *testing.T) {
	eqFrom := &coord.Equatorial{
		unit.NewRA(2, 31, 48.704),
		unit.NewAngle(' ', 89, 15, 50.72),
	}
	eqTo := &coord.Equatorial{}
	mα := unit.HourAngleFromSec(0.19877)
	mδ := unit.AngleFromSec(-0.0152)
	for _, tc := range []struct {
		α, δ string
		jde  float64
	}{
		{"1ʰ22ᵐ33.90ˢ", "88°46′26.18″", base.BesselianYearToJDE(1900)},
		{"3ʰ48ᵐ16.43ˢ", "89°27′15.38″", base.JulianYearToJDE(2050)},
		{"5ʰ53ᵐ29.17ˢ", "89°32′22.18″", base.JulianYearToJDE(2100)},
	} {
		epochTo := base.JDEToJulianYear(tc.jde)
		precess.Position(eqFrom, eqTo, 2000.0, epochTo, mα, mδ)
		αStr := fmt.Sprintf("%.2s", sexa.FmtRA(eqTo.RA))
		δStr := fmt.Sprintf("%.2s", sexa.FmtAngle(eqTo.Dec))
		if αStr != tc.α {
			t.Fatal("got:", αStr, "want:", tc.α)
		}
		if δStr != tc.δ {
			t.Fatal(δStr)
		}
	}
}
예제 #3
0
파일: precess_test.go 프로젝트: pjh59/meeus
// test example epochs on p. 133 that are not constants in meeus/julian.go
func TestEpoch(t *testing.T) {
	if math.Abs(base.BesselianYearToJDE(1950)-2433282.4235) > 1e-4 {
		t.Fatal("B1950")
	}
	if math.Abs((base.JulianYearToJDE(2050)-2469807.5)/2469807.5) > 1e-15 {
		t.Fatal("J2050")
	}
}
예제 #4
0
파일: precess_test.go 프로젝트: pjh59/meeus
func ExampleEclipticPrecessor_ReduceElements() {
	// Example 24.a, p. 160.
	ele := &elementequinox.Elements{
		Inc:  47.122 * math.Pi / 180,
		Peri: 151.4486 * math.Pi / 180,
		Node: 45.7481 * math.Pi / 180,
	}
	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*180/math.Pi)
	fmt.Printf("Ω = %.4f\n", ele.Node*180/math.Pi)
	fmt.Printf("ω = %.4f\n", ele.Peri*180/math.Pi)
	// Output:
	// i = 47.1380
	// Ω = 48.6037
	// ω = 151.4782
}
예제 #5
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
}