天文算法18

第二十章 Smallest Circle containing three Celestial Bodies

1. 问题

设三点为A,B,C,对应三边为a,b,c,其中a为最长边,
当$a>\sqrt {b^2+c^2}$,则包含这三点的最小圆直径为a,
当$a<\sqrt {b^2+c^2}$,则包含这三点的最小圆直径为$$\frac {2abc}{\sqrt {(a+b+c)(a+b-c)(b+c-a)(a+c-b)}}$$

证明

给定三个天体的坐标,求最小圆直径。

// Smallest finds the smallest circle containing three points.
//
// Arguments should represent coordinates in right ascension and declination
// or longitude and latitude.  Result Δ is the diameter of the circle, typeI
// is true if solution is of type I.
//
//	type I   Two points on circle, one interior.
//	type II  All three points on circle.
// 根据三点坐标,求最小圆直径
func Smallest(r1, d1, r2, d2, r3, d3 unit.Angle) (Δ unit.Angle, typeI bool) {
	// Using haversine formula, but reimplementing SepHav here to reuse
	// the computed cosines.
	cd1 := d1.Cos()
	cd2 := d2.Cos()
	cd3 := d3.Cos()
	a := 2 * math.Asin(math.Sqrt(base.Hav(d2-d1)+cd1*cd2*base.Hav(r2-r1)))
	b := 2 * math.Asin(math.Sqrt(base.Hav(d3-d2)+cd2*cd3*base.Hav(r3-r2)))
	c := 2 * math.Asin(math.Sqrt(base.Hav(d1-d3)+cd3*cd1*base.Hav(r1-r3)))
	if b > a {
		a, b = b, a
	}
	if c > a {
		a, c = c, a
	}
	if a*a >= b*b+c*c {
		return unit.Angle(a), true
	}
	// (20.1) p. 128
	return unit.Angle(2 * a * b * c /
		math.Sqrt((a+b+c)*(a+b-c)*(b+c-a)*(a+c-b))), false
}

相关

下一页
上一页
comments powered by Disqus