本文整理汇总了Golang中github.com/soniakeys/meeus/base.NewRA函数的典型用法代码示例。如果您正苦于以下问题:Golang NewRA函数的具体用法?Golang NewRA怎么用?Golang NewRA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewRA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestSep
// First exercise, p. 110.
func TestSep(t *testing.T) {
r1 := base.NewRA(4, 35, 55.2).Rad()
d1 := base.NewAngle(false, 16, 30, 33).Rad()
r2 := base.NewRA(16, 29, 24).Rad()
d2 := base.NewAngle(true, 26, 25, 55).Rad()
d := angle.Sep(r1, d1, r2, d2)
answer := base.NewAngle(false, 169, 58, 0).Rad()
if math.Abs(d-answer) > 1e-4 {
t.Fatal(base.NewFmtAngle(d))
}
}
示例2: ExampleSep
func ExampleSep() {
// Example 17.a, p. 110.
r1 := base.NewRA(14, 15, 39.7).Rad()
d1 := base.NewAngle(false, 19, 10, 57).Rad()
r2 := base.NewRA(13, 25, 11.6).Rad()
d2 := base.NewAngle(true, 11, 9, 41).Rad()
d := angle.Sep(r1, d1, r2, d2)
fmt.Println(base.NewFmtAngle(d))
// Output:
// 32°47′35″
}
示例3: TestSepHav
func TestSepHav(t *testing.T) {
// Example 17.a, p. 110.
r1 := base.NewRA(14, 15, 39.7).Rad()
d1 := base.NewAngle(false, 19, 10, 57).Rad()
r2 := base.NewRA(13, 25, 11.6).Rad()
d2 := base.NewAngle(true, 11, 9, 41).Rad()
d := angle.SepHav(r1, d1, r2, d2)
s := fmt.Sprint(base.NewFmtAngle(d))
if s != "32°47′35″" {
t.Fatal(s)
}
}
示例4: ExampleAngleError
func ExampleAngleError() {
// Example p. 125.
rδ := base.NewRA(5, 32, 0.40).Rad()
dδ := base.NewAngle(true, 0, 17, 56.9).Rad()
rε := base.NewRA(5, 36, 12.81).Rad()
dε := base.NewAngle(true, 1, 12, 7.0).Rad()
rζ := base.NewRA(5, 40, 45.52).Rad()
dζ := base.NewAngle(true, 1, 56, 33.3).Rad()
n, ω := line.AngleError(rδ, dδ, rε, dε, rζ, dζ)
fmt.Printf("%.62s\n", base.NewFmtAngle(n))
fmt.Println(base.NewFmtAngle(ω))
// Output:
// 7°31′
// -5′24″
}
示例5: ExampleProperMotion3D
func ExampleProperMotion3D() {
// Example 21.d, p. 141.
eqFrom := &coord.Equatorial{
RA: base.NewRA(6, 45, 8.871).Rad(),
Dec: base.NewAngle(true, 16, 42, 57.99).Rad(),
}
mra := base.NewHourAngle(false, 0, 0, -0.03847)
mdec := base.NewAngle(false, 0, 0, -1.2053)
r := 2.64 // given in correct unit
mr := -7.6 / 977792 // magic conversion factor
eqTo := &coord.Equatorial{}
fmt.Printf("Δr = %.9f, Δα = %.10f, Δδ = %.10f\n", mr, mra, mdec)
for _, epoch := range []float64{1000, 0, -1000, -2000, -10000} {
precess.ProperMotion3D(eqFrom, eqTo, 2000, epoch, r, mr, mra, mdec)
fmt.Printf("%8.1f %0.2d %-0.1d\n", epoch,
base.NewFmtRA(eqTo.RA), base.NewFmtAngle(eqTo.Dec))
}
// Output:
// Δr = -0.000007773, Δα = -0.0000027976, Δδ = -0.0000058435
// 1000.0 6ʰ45ᵐ47ˢ.16 -16°22′56″.0
// 0.0 6ʰ46ᵐ25ˢ.09 -16°03′00″.8
// -1000.0 6ʰ47ᵐ02ˢ.67 -15°43′12″.3
// -2000.0 6ʰ47ᵐ39ˢ.91 -15°23′30″.6
// -10000.0 6ʰ52ᵐ25ˢ.72 -12°50′06″.7
}
示例6: TestPosition
// 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)
}
}
}
示例7: ExampleNewRA
func ExampleNewRA() {
// Example 1.a, p. 8.
a := base.NewRA(9, 14, 55.8)
fmt.Printf("%.6f\n", math.Tan(a.Rad()))
// Output:
// -0.877517
}
示例8: ExampleAngle
func ExampleAngle() {
// Example p. 123.
rδ := base.NewRA(5, 32, 0.40).Rad()
dδ := base.NewAngle(true, 0, 17, 56.9).Rad()
rε := base.NewRA(5, 36, 12.81).Rad()
dε := base.NewAngle(true, 1, 12, 7.0).Rad()
rζ := base.NewRA(5, 40, 45.52).Rad()
dζ := base.NewAngle(true, 1, 56, 33.3).Rad()
n := line.Angle(rδ, dδ, rε, dε, rζ, dζ)
fmt.Printf("%.4f degrees\n", n*180/math.Pi)
fmt.Printf("%.62s\n", base.NewFmtAngle(n))
// Output:
// 172.4830 degrees
// 172°29′
}
示例9: ExampleApproxTimes
func ExampleApproxTimes() {
// Example 15.a, p. 103.
jd := julian.CalendarGregorianToJD(1988, 3, 20)
p := globe.Coord{
Lon: base.NewAngle(false, 71, 5, 0).Rad(),
Lat: base.NewAngle(false, 42, 20, 0).Rad(),
}
// Meeus gives us the value of 11h 50m 58.1s but we have a package
// function for this:
Th0 := sidereal.Apparent0UT(jd)
α := base.NewRA(2, 46, 55.51).Rad()
δ := base.NewAngle(false, 18, 26, 27.3).Rad()
h0 := rise.Stdh0Stellar
rise, transit, set, err := rise.ApproxTimes(p, h0, Th0, α, δ)
if err != nil {
fmt.Println(err)
return
}
// Units for approximate values given near top of p. 104 are circles.
fmt.Printf("rising: %+.5f\n", rise/86400)
fmt.Printf("transit: %+.5f\n", transit/86400)
fmt.Printf("seting: %+.5f\n", set/86400)
// Output:
// rising: +0.51816
// transit: +0.81965
// seting: +0.12113
}
示例10: TestPrecessor_Precess
func TestPrecessor_Precess(t *testing.T) {
// Exercise, p. 136.
eqFrom := &coord.Equatorial{
RA: base.NewRA(2, 31, 48.704).Rad(),
Dec: base.NewAngle(false, 89, 15, 50.72).Rad(),
}
mα := base.NewHourAngle(false, 0, 0, .19877)
mδ := base.NewAngle(false, 0, 0, -.0152)
epochs := []float64{
base.JDEToJulianYear(base.B1900),
2050,
2100,
}
answer := []string{
"α = 1ʰ22ᵐ33ˢ.90 δ = +88°46′26″.18",
"α = 3ʰ48ᵐ16ˢ.43 δ = +89°27′15″.38",
"α = 5ʰ53ᵐ29ˢ.17 δ = +89°32′22″.18",
}
eqTo := &coord.Equatorial{}
for i, epochTo := range epochs {
precess.Position(eqFrom, eqTo, 2000, epochTo, mα, mδ)
if answer[i] != fmt.Sprintf("α = %0.2d δ = %+0.2d",
base.NewFmtRA(eqTo.RA), base.NewFmtAngle(eqTo.Dec)) {
t.Fatal(i)
}
}
}
示例11: ExampleLen4Half
func ExampleLen4Half() {
// Example 3.f, p. 32.
half, err := interp.Len4Half([]float64{
base.NewRA(10, 18, 48.732).Rad(),
base.NewRA(10, 23, 22.835).Rad(),
base.NewRA(10, 27, 57.247).Rad(),
base.NewRA(10, 32, 31.983).Rad(),
})
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%.3d", base.NewFmtRA(half))
// Output:
// 10ʰ25ᵐ40ˢ.001
}
示例12: ExampleError
func ExampleError() {
// Example p. 124.
rδ := base.NewRA(5, 32, 0.40).Rad()
dδ := base.NewAngle(true, 0, 17, 56.9).Rad()
rε := base.NewRA(5, 36, 12.81).Rad()
dε := base.NewAngle(true, 1, 12, 7.0).Rad()
rζ := base.NewRA(5, 40, 45.52).Rad()
dζ := base.NewAngle(true, 1, 56, 33.3).Rad()
ω := line.Error(rζ, dζ, rδ, dδ, rε, dε)
fmt.Println(base.DecSymAdd(fmt.Sprintf("%.6f", ω*180/math.Pi), '°'))
fmt.Printf("%.0f″\n", ω*3600*180/math.Pi)
fmt.Println(base.NewFmtAngle(ω))
// Output:
// 0°.089876
// 324″
// 5′24″
}
示例13: ExampleSmallest_b
func ExampleSmallest_b() {
// Exercise, p. 128.
r1 := base.NewRA(9, 5, 41.44).Rad()
r2 := base.NewRA(9, 9, 29).Rad()
r3 := base.NewRA(8, 59, 47.14).Rad()
d1 := base.NewAngle(false, 18, 30, 30).Rad()
d2 := base.NewAngle(false, 17, 43, 56.7).Rad()
d3 := base.NewAngle(false, 17, 49, 36.8).Rad()
d, t := circle.Smallest(r1, d1, r2, d2, r3, d3)
fmt.Printf("Δ = %.62s\n", base.NewFmtAngle(d))
if t {
fmt.Println("type I")
} else {
fmt.Println("type II")
}
// Output:
// Δ = 2°19′
// type I
}
示例14: ExampleAberration
func ExampleAberration() {
// Example 23.a, p. 152
α := base.NewRA(2, 46, 11.331).Rad()
δ := base.NewAngle(false, 49, 20, 54.54).Rad()
jd := julian.CalendarGregorianToJD(2028, 11, 13.19)
Δα2, Δδ2 := apparent.Aberration(α, δ, jd)
fmt.Printf("%.3s %.3s\n", base.NewFmtAngle(Δα2), base.NewFmtAngle(Δδ2))
// Output:
// 30.045″ 6.697″
}
示例15: ExampleNutation
func ExampleNutation() {
// Example 23.a, p. 152
α := base.NewRA(2, 46, 11.331).Rad()
δ := base.NewAngle(false, 49, 20, 54.54).Rad()
jd := julian.CalendarGregorianToJD(2028, 11, 13.19)
Δα1, Δδ1 := apparent.Nutation(α, δ, jd)
fmt.Printf("%.3s %.3s\n", base.NewFmtAngle(Δα1), base.NewFmtAngle(Δδ1))
// Output:
// 15.843″ 6.217″
}