예제 #1
0
func ExampleEllipsoid_Distance() {
	// Example 11.c p 85.
	c1 := globe.Coord{
		unit.NewAngle(' ', 48, 50, 11), // geographic latitude
		unit.NewAngle('-', 2, 20, 14),  // geographic longitude
	}
	c2 := globe.Coord{
		unit.NewAngle(' ', 38, 55, 17),
		unit.NewAngle(' ', 77, 3, 56),
	}
	fmt.Printf("%.2f km\n", globe.Earth76.Distance(c1, c2))
	cos := globe.ApproxAngularDistance(c1, c2)
	fmt.Printf("cos d = %.6f\n", cos)
	d := unit.Angle(math.Acos(cos))
	fmt.Printf("    d = %.5j\n", sexa.FmtAngle(d))
	fmt.Printf("    s = %.0f km\n", globe.ApproxLinearDistance(d))
	// Output:
	// 6181.63 km
	// cos d = 0.567146
	//     d = 55°.44855
	//     s = 6166 km
}
예제 #2
0
파일: globe_test.go 프로젝트: pjh59/meeus
func ExampleEllipsoid_Distance() {
	// Example 11.c p 85.
	c1 := globe.Coord{
		base.NewAngle(false, 48, 50, 11).Rad(), // geographic latitude
		base.NewAngle(true, 2, 20, 14).Rad(),   // geographic longitude
	}
	c2 := globe.Coord{
		base.NewAngle(false, 38, 55, 17).Rad(),
		base.NewAngle(false, 77, 3, 56).Rad(),
	}
	fmt.Printf("%.2f km\n", globe.Earth76.Distance(c1, c2))
	cos := globe.ApproxAngularDistance(c1, c2)
	fmt.Printf("cos d = %.6f\n", cos)
	d := math.Acos(cos)
	fmt.Println("    d =",
		base.DecSymAdd(fmt.Sprintf("%.5f", d*180/math.Pi), '°'))
	fmt.Printf("    s = %.0f km\n", globe.ApproxLinearDistance(d))
	// Output:
	// 6181.63 km
	// cos d = 0.567146
	//     d = 55°.44855
	//     s = 6166 km
}