当前位置: 首页>>代码示例>>Golang>>正文


Golang unit.NewAngle函数代码示例

本文整理汇总了Golang中github.com/soniakeys/unit.NewAngle函数的典型用法代码示例。如果您正苦于以下问题:Golang NewAngle函数的具体用法?Golang NewAngle怎么用?Golang NewAngle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewAngle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ExampleApproxPlanet

func ExampleApproxPlanet() {
	// Example 15.a, p. 103.
	p := globe.Coord{
		Lon: unit.NewAngle(' ', 71, 5, 0),
		Lat: unit.NewAngle(' ', 42, 20, 0),
	}
	e, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	v, err := pp.LoadPlanet(pp.Venus)
	if err != nil {
		fmt.Println(err)
		return
	}
	tRise, tTransit, tSet, err := rise.ApproxPlanet(1988, 3, 20, p, e, v)
	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ˢ
}
开发者ID:soniakeys,项目名称:meeus,代码行数:30,代码来源:pp_test.go

示例2: ExamplePlanet

func ExamplePlanet() {
	// Example 15.a, p. 103.
	p := globe.Coord{
		Lon: unit.NewAngle(' ', 71, 5, 0),
		Lat: unit.NewAngle(' ', 42, 20, 0),
	}
	e, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	v, err := pp.LoadPlanet(pp.Venus)
	if err != nil {
		fmt.Println(err)
		return
	}
	tRise, tTransit, tSet, err := rise.Planet(1988, 3, 20, p, e, v)
	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ˢ
}
开发者ID:soniakeys,项目名称:meeus,代码行数:29,代码来源:pp_test.go

示例3: 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ˢ
}
开发者ID:soniakeys,项目名称:meeus,代码行数:25,代码来源:rise_test.go

示例4: 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ˢ
}
开发者ID:soniakeys,项目名称:meeus,代码行数:33,代码来源:rise_test.go

示例5: ExampleTimes_computed

func ExampleTimes_computed() {
	// Example 15.a, p. 103, but using meeus packages to compute values
	// given in the text.
	jd := julian.CalendarGregorianToJD(1988, 3, 20)
	p := globe.Coord{
		Lon: unit.NewAngle(' ', 71, 5, 0),
		Lat: unit.NewAngle(' ', 42, 20, 0),
	}
	// Th0 computed rather than taken from the text.
	Th0 := sidereal.Apparent0UT(jd)

	// Venus α, δ computed rather than taken from the text.
	e, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	v, err := pp.LoadPlanet(pp.Venus)
	if err != nil {
		fmt.Println(err)
		return
	}
	α := make([]unit.RA, 3)
	δ := make([]unit.Angle, 3)
	α[0], δ[0] = elliptic.Position(v, e, jd-1)
	α[1], δ[1] = elliptic.Position(v, e, jd)
	α[2], δ[2] = elliptic.Position(v, e, jd+1)
	for i, j := range []float64{jd - 1, jd, jd + 1} {
		_, m, d := julian.JDToCalendar(j)
		fmt.Printf("%s %.0f  α: %0.2s  δ: %0.1s\n",
			time.Month(m), d, sexa.FmtRA(α[i]), sexa.FmtAngle(δ[i]))
	}

	// ΔT computed rather than taken from the text.
	ΔT := deltat.Interp10A(jd)
	fmt.Printf("ΔT: %.1f\n", ΔT)

	h0 := rise.Stdh0Stellar
	tRise, tTransit, tSet, err := rise.Times(p, ΔT, h0, Th0, α, δ)
	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:
	// March 19  α: 2ʰ42ᵐ43.25ˢ  δ: 18°02′51.4″
	// March 20  α: 2ʰ46ᵐ55.51ˢ  δ: 18°26′27.3″
	// March 21  α: 2ʰ51ᵐ07.69ˢ  δ: 18°49′38.7″
	// ΔT: 55.9
	// rising:   +0.51766  12ʰ25ᵐ26ˢ
	// transit:  +0.81980  19ʰ40ᵐ30ˢ
	// seting:   +0.12130  02ʰ54ᵐ40ˢ
}
开发者ID:soniakeys,项目名称:meeus,代码行数:55,代码来源:pp_test.go

示例6: 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)
	}
}
开发者ID:soniakeys,项目名称:meeus,代码行数:12,代码来源:angle_test.go

示例7: 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″
}
开发者ID:soniakeys,项目名称:meeus,代码行数:11,代码来源:angle_test.go

示例8: 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)
	}
}
开发者ID:soniakeys,项目名称:meeus,代码行数:12,代码来源:angle_test.go

示例9: 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)
		}
	}
}
开发者ID:soniakeys,项目名称:meeus,代码行数:27,代码来源:precess_test.go

示例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″
}
开发者ID:soniakeys,项目名称:meeus,代码行数:16,代码来源:line_test.go

示例11: 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)
		}
	}
}
开发者ID:soniakeys,项目名称:meeus,代码行数:29,代码来源:precess_test.go

示例12: 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′
}
开发者ID:soniakeys,项目名称:meeus,代码行数:16,代码来源:line_test.go

示例13: 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
}
开发者ID:soniakeys,项目名称:meeus,代码行数:25,代码来源:precess_test.go

示例14: TestLatDiff

// p. 83
func TestLatDiff(t *testing.T) {
	φ0 := unit.NewAngle(' ', 45, 5, 46.36)
	diff := globe.GeocentricLatitudeDifference(φ0)
	if f := fmt.Sprintf("%.2d", sexa.FmtAngle(diff)); f != "11′32″.73" {
		t.Fatal(f)
	}
}
开发者ID:soniakeys,项目名称:meeus,代码行数:8,代码来源:globe_test.go

示例15: ExampleApproxTimes_computed

func ExampleApproxTimes_computed() {
	// Example 15.a, p. 103, but using meeus packages to compute values
	// given in the text.
	jd := julian.CalendarGregorianToJD(1988, 3, 20)
	p := globe.Coord{
		Lon: unit.NewAngle(' ', 71, 5, 0),
		Lat: unit.NewAngle(' ', 42, 20, 0),
	}

	// Th0 computed rather than taken from the text.
	Th0 := sidereal.Apparent0UT(jd)
	fmt.Printf("Th0: %.2s\n", sexa.FmtTime(Th0))

	// Venus α, δ computed rather than taken from the text.
	e, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	v, err := pp.LoadPlanet(pp.Venus)
	if err != nil {
		fmt.Println(err)
		return
	}
	α, δ := elliptic.Position(v, e, jd)
	fmt.Printf("α: %.2s\n", sexa.FmtRA(α))
	fmt.Printf("δ: %.1s\n", sexa.FmtAngle(δ))

	h0 := rise.Stdh0Stellar
	tRise, tTransit, tSet, err := rise.ApproxTimes(p, h0, Th0, α, δ)
	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:
	// Th0: 11ʰ50ᵐ58.09ˢ
	// α: 2ʰ46ᵐ55.51ˢ
	// δ: 18°26′27.3″
	// rising:   +0.51816  12ʰ26ᵐ09ˢ
	// transit:  +0.81965  19ʰ40ᵐ17ˢ
	// seting:   +0.12113  02ʰ54ᵐ26ˢ
}
开发者ID:soniakeys,项目名称:meeus,代码行数:45,代码来源:pp_test.go


注:本文中的github.com/soniakeys/unit.NewAngle函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。