本文整理汇总了Golang中github.com/soniakeys/unit.NewRA函数的典型用法代码示例。如果您正苦于以下问题:Golang NewRA函数的具体用法?Golang NewRA怎么用?Golang NewRA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewRA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleTimes
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ˢ
}
示例2: TestSep
// First exercise, p. 110.
func TestSep(t *testing.T) {
r1 := unit.NewRA(4, 35, 55.2).Angle()
d1 := unit.NewAngle(' ', 16, 30, 33)
r2 := unit.NewRA(16, 29, 24).Angle()
d2 := unit.NewAngle('-', 26, 25, 55)
d := angle.Sep(r1, d1, r2, d2)
answer := unit.NewAngle(' ', 169, 58, 0)
if math.Abs((d - answer).Rad()) > 1e-4 {
t.Fatal(d, answer)
}
}
示例3: ExampleSep
func ExampleSep() {
// Example 17.a, p. 110.
r1 := unit.NewRA(14, 15, 39.7).Angle()
d1 := unit.NewAngle(' ', 19, 10, 57)
r2 := unit.NewRA(13, 25, 11.6).Angle()
d2 := unit.NewAngle('-', 11, 9, 41)
d := angle.Sep(r1, d1, r2, d2)
fmt.Println(sexa.FmtAngle(d))
// Output:
// 32°47′35″
}
示例4: TestSepHav
func TestSepHav(t *testing.T) {
// Example 17.a, p. 110.
r1 := unit.NewRA(14, 15, 39.7).Angle()
d1 := unit.NewAngle(' ', 19, 10, 57)
r2 := unit.NewRA(13, 25, 11.6).Angle()
d2 := unit.NewAngle('-', 11, 9, 41)
d := angle.SepHav(r1, d1, r2, d2)
s := fmt.Sprint(sexa.FmtAngle(d))
if s != "32°47′35″" {
t.Fatal(s)
}
}
示例5: ExampleAngle
func ExampleAngle() {
// Example p. 123.
rδ := unit.NewRA(5, 32, 0.40).Angle()
dδ := unit.NewAngle('-', 0, 17, 56.9)
rε := unit.NewRA(5, 36, 12.81).Angle()
dε := unit.NewAngle('-', 1, 12, 7.0)
rζ := unit.NewRA(5, 40, 45.52).Angle()
dζ := unit.NewAngle('-', 1, 56, 33.3)
n := line.Angle(rδ, dδ, rε, dε, rζ, dζ)
fmt.Printf("%.4f degrees\n", n.Deg())
fmt.Printf("%m\n", sexa.FmtAngle(n))
// Output:
// 172.4830 degrees
// 172°29′
}
示例6: TestPrecessor_Precess
func TestPrecessor_Precess(t *testing.T) {
// Exercise, p. 136.
eqFrom := &coord.Equatorial{
RA: unit.NewRA(2, 31, 48.704),
Dec: unit.NewAngle(' ', 89, 15, 50.72),
}
mα := unit.HourAngleFromSec(.19877)
mδ := unit.AngleFromSec(-.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",
sexa.FmtRA(eqTo.RA), sexa.FmtAngle(eqTo.Dec)) {
t.Fatal(i)
}
}
}
示例7: ExampleProperMotion3D
func ExampleProperMotion3D() {
// Example 21.d, p. 141.
eqFrom := &coord.Equatorial{
RA: unit.NewRA(6, 45, 8.871),
Dec: unit.NewAngle('-', 16, 42, 57.99),
}
mra := unit.HourAngleFromSec(-0.03847)
mdec := unit.AngleFromSec(-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,
sexa.FmtRA(eqTo.RA), sexa.FmtAngle(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
}
示例8: TestPosition
// 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)
}
}
}
示例9: ExampleApproxTimes
func ExampleApproxTimes() {
// 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)
α := unit.NewRA(2, 46, 55.51)
δ := unit.NewAngle(' ', 18, 26, 27.3)
h0 := rise.Stdh0Stellar
tRise, tTransit, tSet, err := rise.ApproxTimes(p, h0, Th0, α, δ)
if err != nil {
fmt.Println(err)
return
}
// Units for "m" values given near top of p. 104 are day fraction.
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.51816 12ʰ26ᵐ09ˢ
// transit: +0.81965 19ʰ40ᵐ17ˢ
// seting: +0.12113 02ʰ54ᵐ26ˢ
}
示例10: ExampleAngleError
func ExampleAngleError() {
// Example p. 125.
rδ := unit.NewRA(5, 32, 0.40).Angle()
dδ := unit.NewAngle('-', 0, 17, 56.9)
rε := unit.NewRA(5, 36, 12.81).Angle()
dε := unit.NewAngle('-', 1, 12, 7.0)
rζ := unit.NewRA(5, 40, 45.52).Angle()
dζ := unit.NewAngle('-', 1, 56, 33.3)
n, ω := line.AngleError(rδ, dδ, rε, dε, rζ, dζ)
fmt.Printf("%m\n", sexa.FmtAngle(n))
fmt.Println(sexa.FmtAngle(ω))
// Output:
// 7°31′
// -5′24″
}
示例11: ExampleError
func ExampleError() {
// Example p. 124.
rδ := unit.NewRA(5, 32, 0.40).Angle()
dδ := unit.NewAngle('-', 0, 17, 56.9)
rε := unit.NewRA(5, 36, 12.81).Angle()
dε := unit.NewAngle('-', 1, 12, 7.0)
rζ := unit.NewRA(5, 40, 45.52).Angle()
dζ := unit.NewAngle('-', 1, 56, 33.3)
ω := line.Error(rζ, dζ, rδ, dδ, rε, dε)
e := sexa.FmtAngle(ω)
fmt.Printf("%.6j\n", e)
fmt.Printf("%.0f″\n", ω.Sec())
fmt.Println(e)
// Output:
// 0°.089876
// 324″
// 5′24″
}
示例12: ExampleSmallest_b
func ExampleSmallest_b() {
// Exercise, p. 128.
r1 := unit.NewRA(9, 5, 41.44).Angle()
r2 := unit.NewRA(9, 9, 29).Angle()
r3 := unit.NewRA(8, 59, 47.14).Angle()
d1 := unit.NewAngle(' ', 18, 30, 30)
d2 := unit.NewAngle(' ', 17, 43, 56.7)
d3 := unit.NewAngle(' ', 17, 49, 36.8)
d, t := circle.Smallest(r1, d1, r2, d2, r3, d3)
fmt.Printf("Δ = %m\n", sexa.FmtAngle(d))
if t {
fmt.Println("type I")
} else {
fmt.Println("type II")
}
// Output:
// Δ = 2°19′
// type I
}
示例13: ExampleSmallest_a
func ExampleSmallest_a() {
// Example 20.a, p. 128.
r1 := unit.NewRA(12, 41, 8.64).Angle()
r2 := unit.NewRA(12, 52, 5.21).Angle()
r3 := unit.NewRA(12, 39, 28.11).Angle()
d1 := unit.NewAngle('-', 5, 37, 54.2)
d2 := unit.NewAngle('-', 4, 22, 26.2)
d3 := unit.NewAngle('-', 1, 50, 3.7)
d, t := circle.Smallest(r1, d1, r2, d2, r3, d3)
fd := sexa.FmtAngle(d)
fmt.Printf("Δ = %.5j = %m\n", fd, fd)
if t {
fmt.Println("type I")
} else {
fmt.Println("type II")
}
// Output:
// Δ = 4°.26363 = 4°16′
// type II
}
示例14: ExampleAberration
func ExampleAberration() {
// Example 23.a, p. 152
α := unit.NewRA(2, 46, 11.331)
δ := unit.NewAngle(' ', 49, 20, 54.54)
jd := julian.CalendarGregorianToJD(2028, 11, 13.19)
Δα2, Δδ2 := apparent.Aberration(α, δ, jd)
fmt.Printf("%.3s %.3s\n",
sexa.FmtAngle(unit.Angle(Δα2)), // (Δα2 is in HourAngle)
sexa.FmtAngle(Δδ2))
// Output:
// 30.045″ 6.697″
}
示例15: TestEqToGal
func TestEqToGal(t *testing.T) {
g := new(coord.Galactic).EqToGal(&coord.Equatorial{
RA: unit.NewRA(17, 48, 59.74),
Dec: unit.NewAngle('-', 14, 43, 8.2),
})
if s := fmt.Sprintf("%.4f", g.Lon.Deg()); s != "12.9593" {
t.Fatal("lon:", s)
}
if s := fmt.Sprintf("%+.4f", g.Lat.Deg()); s != "+6.0463" {
t.Fatal("lat:", s)
}
}