func ExampleLen3_Zero() { // Example 3.c, p. 26. x1 := 26. x3 := 28. // the y unit doesn't matter. working in degrees is fine yTable := []float64{ base.DMSToDeg(true, 0, 28, 13.4), base.DMSToDeg(false, 0, 6, 46.3), base.DMSToDeg(false, 0, 38, 23.2), } d3, err := interp.NewLen3(x1, x3, yTable) if err != nil { fmt.Println(err) return } x, err := d3.Zero(false) if err != nil { fmt.Println(err) return } fmt.Printf("February %.5f\n", x) i, frac := math.Modf(x) fmt.Printf("February %d, at %.62s TD", int(i), base.NewFmtTime(frac*24*3600)) // Output: // February 26.79873 // February 26, at 19ʰ10ᵐ TD }
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 }
func ExampleDMSToDeg() { // Example p. 7. fmt.Printf("%.8f\n", base.DMSToDeg(false, 23, 26, 49)) // Output: // 23.44694444 }