Documentation
¶
Overview ¶
Sundial: Chapter 58, Calculation of a Planar Sundial.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func General ¶
func General(φ, D unit.Angle, a float64, z unit.Angle) (lines []Line, center Point, u float64, ψ unit.Angle)
General computes data for the general case of a planar sundial.
Argument φ is geographic latitude at which the sundial will be located. D is gnomonic declination, the azimuth of the perpendicular to the plane of the sundial, measured from the southern meridian towards the west. Argument a is the length of a straight stylus perpendicular to the plane of the sundial, z is zenithal distance of the direction defined by the stylus. Units of stylus length a are arbitrary.
Results consist of a set of lines, a center point, u, the length of a polar stylus, and ψ, the angle which the polar stylus makes with the plane of the sundial. The center point, the points defining the hour lines, and u are in units of a, the stylus length.
Example (A) ¶
package main
import (
"fmt"
"github.com/mooncaker816/learnmeeus/v3/sundial"
"github.com/soniakeys/unit"
)
func main() {
// Example 58.a, p. 404.
ls, c, _, ψ := sundial.General(
unit.AngleFromDeg(40),
unit.AngleFromDeg(70),
1,
unit.AngleFromDeg(50))
fmt.Printf("Hours: %d", ls[0].Hour)
for _, l := range ls[1:] {
fmt.Printf(", %d", l.Hour)
}
fmt.Println()
for _, l := range ls {
if l.Hour == 11 {
fmt.Printf("%d: x = %.4f y = %.4f\n",
l.Hour, l.Points[2].X, l.Points[2].Y)
}
if l.Hour == 14 {
fmt.Printf("%d: x = %.4f y = %.4f\n",
l.Hour, l.Points[6].X, l.Points[6].Y)
}
}
fmt.Printf("x0 = %+.4f\n", c.X)
fmt.Printf("y0 = %+.4f\n", c.Y)
fmt.Printf("ψ = %.4f\n", ψ.Deg())
}
Output: Hours: 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 11: x = -2.0007 y = -1.1069 14: x = -0.0390 y = -0.3615 x0 = +3.3880 y0 = -3.1102 ψ = 12.2672
Example (B) ¶
package main
import (
"fmt"
"math"
"github.com/mooncaker816/learnmeeus/v3/sundial"
"github.com/soniakeys/unit"
)
func main() {
// Example 58.b, p. 404.
const p = math.Pi / 180
ls, c, _, ψ := sundial.General(
unit.AngleFromDeg(-35),
unit.AngleFromDeg(160),
1,
unit.AngleFromDeg(90))
for _, l := range ls {
if l.Hour == 12 {
fmt.Printf("%d: x = %+.4f y = %+.4f\n",
l.Hour, l.Points[5].X, l.Points[5].Y)
}
if l.Hour == 15 {
fmt.Printf("%d: x = %+.4f y = %+.4f\n",
l.Hour, l.Points[3].X, l.Points[3].Y)
}
}
fmt.Printf("x0 = %+.4f\n", c.X)
fmt.Printf("y0 = %+.4f\n", c.Y)
fmt.Printf("ψ = %.4f\n", ψ.Deg())
}
Output: 12: x = +0.3640 y = -0.7410 15: x = -0.8439 y = -0.9298 x0 = +0.3640 y0 = +0.7451 ψ = 50.3315
Example (C) ¶
package main
import (
"fmt"
"github.com/mooncaker816/learnmeeus/v3/sundial"
"github.com/soniakeys/unit"
)
func main() {
// Example 58.c, p. 405.
ls, _, _, _ := sundial.General(
unit.AngleFromDeg(40),
unit.AngleFromDeg(160),
1,
unit.AngleFromDeg(75))
fmt.Printf("Hours: %d", ls[0].Hour)
for _, l := range ls[1:] {
fmt.Printf(", %d", l.Hour)
}
fmt.Println()
}
Output: Hours: 5, 6, 13, 14, 15, 16, 17, 18, 19
func Horizontal ¶
Horizontal computes data for a horizontal sundial.
Argument φ is geographic latitude at which the sundial will be located, a is the length of a straight stylus perpendicular to the plane of the sundial.
Results consist of a set of lines, a center point, and u, the length of a polar stylus. They are in units of a, the stylus length.
func Vertical ¶
Vertical computes data for a vertical sundial.
Argument φ is geographic latitude at which the sundial will be located. D is gnomonic declination, the azimuth of the perpendicular to the plane of the sundial, measured from the southern meridian towards the west. Argument a is the length of a straight stylus perpendicular to the plane of the sundial.
Results consist of a set of lines, a center point, and u, the length of a polar stylus. They are in units of a, the stylus length.
Types ¶
type Line ¶
type Line struct {
Hour int // 0 to 24.
Points []Point // One or more points corresponding to the hour.
}
Line holds data to draw an hour line on the sundial.
func Equatorial ¶
Equatorial computes data for a sundial level with the equator.
Argument φ is geographic latitude at which the sundial will be located; a is the length of a straight stylus perpendicular to the plane of the sundial.
The sundial will have two sides, north and south. Results n and s define lines on the north and south sides of the sundial. Result coordinates are in units of a, the stylus length.