Beispiel #1
0
func conj(t1, t5 float64, dr, dd []float64) (t, Δd float64, err error) {
	var l5 *interp.Len5
	if l5, err = interp.NewLen5(t1, t5, dr); err != nil {
		return
	}
	if t, err = l5.Zero(true); err != nil {
		return
	}
	if l5, err = interp.NewLen5(t1, t5, dd); err != nil {
		return
	}
	Δd, err = l5.InterpolateXStrict(t)
	return
}
Beispiel #2
0
func conj(t1, t5 float64, dr, dd []float64) (t float64, Δd unit.Angle, err error) {
	var l5 *interp.Len5
	if l5, err = interp.NewLen5(t1, t5, dr); err != nil {
		return
	}
	if t, err = l5.Zero(true); err != nil {
		return
	}
	if l5, err = interp.NewLen5(t1, t5, dd); err != nil {
		return
	}
	ΔdRad, err := l5.InterpolateXStrict(t)
	return t, unit.Angle(ΔdRad), err
}
Beispiel #3
0
// Time computes the time at which a moving body is on a straight line (great
// circle) between two fixed points, such as stars.
//
// Coordinates may be right ascensions and declinations or longitudes and
// latitudes.  Fixed points are r1, d1, r2, d2.  Moving body is an ephemeris
// of 5 rows, r3, d3, starting at time t1 and ending at time t5.  Time scale
// is arbitrary.
//
// Result is time of alignment.
func Time(r1, d1, r2, d2 float64, r3, d3 []float64, t1, t5 float64) (float64, error) {
	if len(r3) != 5 || len(d3) != 5 {
		return 0, errors.New("r3, d3 must be length 5")
	}
	gc := make([]float64, 5)
	for i, r3i := range r3 {
		// (19.1) p. 121
		gc[i] = math.Tan(d1)*math.Sin(r2-r3i) +
			math.Tan(d2)*math.Sin(r3i-r1) +
			math.Tan(d3[i])*math.Sin(r1-r2)
	}
	l5, err := interp.NewLen5(t1, t5, gc)
	if err != nil {
		return 0, err
	}
	return l5.Zero(false)
}
Beispiel #4
0
func ExampleLen5_Zero() {
	// Exercise, p. 30.
	x1 := 25.
	x5 := 29.
	yTable := []float64{
		base.DMSToDeg(true, 1, 11, 21.23),
		base.DMSToDeg(true, 0, 28, 12.31),
		base.DMSToDeg(false, 0, 16, 07.02),
		base.DMSToDeg(false, 1, 01, 00.13),
		base.DMSToDeg(false, 1, 45, 46.33),
	}
	d5, err := interp.NewLen5(x1, x5, yTable)
	if err != nil {
		fmt.Println(err)
		return
	}
	z, err := d5.Zero(false)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("1988 January %.6f\n", z)
	zInt, zFrac := math.Modf(z)
	fmt.Printf("1988 January %d at %.62s TD\n", int(zInt),
		base.NewFmtTime(zFrac*24*3600))

	// compare result to that from just three central values
	d3, err := interp.NewLen3(26, 28, yTable[1:4])
	if err != nil {
		fmt.Println(err)
		return
	}
	z3, err := d3.Zero(false)
	if err != nil {
		fmt.Println(err)
		return
	}
	dz := z - z3
	fmt.Printf("%.6f day\n", dz)
	fmt.Printf("%.1f minute\n", dz*24*60)
	// Output:
	// 1988 January 26.638587
	// 1988 January 26 at 15ʰ20ᵐ TD
	// 0.000753 day
	// 1.1 minute
}
Beispiel #5
0
// Time computes the time at which a moving body is on a straight line (great
// circle) between two fixed points, such as stars.
//
// Coordinates may be right ascensions and declinations or longitudes and
// latitudes.  Fixed points are r1, d1, r2, d2.  Moving body is an ephemeris
// of 5 rows, r3, d3, starting at time t1 and ending at time t5.  Time scale
// is arbitrary.
//
// Result is time of alignment.
func Time(r1, d1, r2, d2 unit.Angle, r3, d3 []unit.Angle, t1, t5 float64) (float64, error) {
	if len(r3) != 5 || len(d3) != 5 {
		return 0, errors.New("r3, d3 must be length 5")
	}
	gc := make([]float64, 5)
	for i, r3i := range r3 {
		// (19.1) p. 121
		gc[i] = d1.Tan()*(r2-r3i).Sin() +
			d2.Tan()*(r3i-r1).Sin() +
			d3[i].Tan()*(r1-r2).Sin()
	}
	l5, err := interp.NewLen5(t1, t5, gc)
	if err != nil {
		return 0, err
	}
	return l5.Zero(false)
}
Beispiel #6
0
func ExampleLen5_InterpolateX() {
	// Example 3.e, p. 28.
	x1 := 27.
	x5 := 29.
	// work in radians to get answer in radians
	yTable := []float64{
		base.NewAngle(false, 0, 54, 36.125).Rad(),
		base.NewAngle(false, 0, 54, 24.606).Rad(),
		base.NewAngle(false, 0, 54, 15.486).Rad(),
		base.NewAngle(false, 0, 54, 08.694).Rad(),
		base.NewAngle(false, 0, 54, 04.133).Rad(),
	}
	x := 28 + (3+20./60)/24
	d5, err := interp.NewLen5(x1, x5, yTable)
	if err != nil {
		fmt.Println(err)
		return
	}
	y := d5.InterpolateX(x)
	// radians easy to format
	fmt.Printf("%.3d", base.NewFmtAngle(y))
	// Output:
	// 54′13″.369
}
Beispiel #7
0
func ExampleLen5_InterpolateX() {
	// Example 3.e, p. 28.
	x1 := 27.
	x5 := 29.
	// work in degrees
	yTable := []float64{
		unit.FromSexa(' ', 0, 54, 36.125),
		unit.FromSexa(' ', 0, 54, 24.606),
		unit.FromSexa(' ', 0, 54, 15.486),
		unit.FromSexa(' ', 0, 54, 08.694),
		unit.FromSexa(' ', 0, 54, 04.133),
	}
	d5, err := interp.NewLen5(x1, x5, yTable)
	if err != nil {
		fmt.Println(err)
		return
	}
	n := (3 + 20./60) / 24
	x := 28 + n
	y := d5.InterpolateX(x)
	fmt.Printf("%.3d", sexa.FmtAngle(unit.AngleFromDeg(y)))
	// Output:
	// 54′13″.369
}