sundial

package
v3.0.0-...-8217f41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2018 License: MIT Imports: 2 Imported by: 0

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

func Horizontal(φ unit.Angle, a float64) (lines []Line, center Point, u float64)

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

func Vertical(φ, D unit.Angle, a float64) (lines []Line, center Point, u float64)

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

func Equatorial(φ unit.Angle, a float64) (n, s []Line)

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.

type Point

type Point struct {
	X, Y float64
}

Point return type represents a point to be used in constructing the sundial.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL