本文整理汇总了Golang中github.com/soniakeys/unit.Angle类的典型用法代码示例。如果您正苦于以下问题:Golang Angle类的具体用法?Golang Angle怎么用?Golang Angle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Angle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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.
func Vertical(φ, D unit.Angle, a float64) (lines []Line, center Point, u float64) {
sφ, cφ := φ.Sincos()
tφ := sφ / cφ
sD, cD := D.Sincos()
for i := 0; i < 24; i++ {
l := Line{Hour: i}
H := float64(i-12) * 15 * math.Pi / 180
aH := math.Abs(H)
sH, cH := math.Sincos(H)
for _, d := range m {
tδ := math.Tan(d * math.Pi / 180)
H0 := math.Acos(-tφ * tδ)
if aH > H0 {
continue // sun below horizon
}
Q := sD*sH + sφ*cD*cH - cφ*cD*tδ
if Q < 0 {
continue // sun below plane of sundial
}
x := a * (cD*sH - sφ*sD*cH + cφ*sD*tδ) / Q
y := -a * (cφ*cH + sφ*tδ) / Q
l.Points = append(l.Points, Point{x, y})
}
if len(l.Points) > 0 {
lines = append(lines, l)
}
}
center.X = -a * sD / cD
center.Y = a * tφ / cD
u = a / math.Abs(cφ*cD)
return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:42,代码来源:sundial.go
示例2: Kepler1
// Kepler1 solves Kepler's equation by iteration.
//
// The iterated formula is
//
// E1 = M + e * sin(E0)
//
// Argument e is eccentricity, M is mean anomaly,
// places is the desired number of decimal places in the result.
//
// Result E is eccentric anomaly.
//
// For some vaues of e and M it will fail to converge and the
// function will return an error.
func Kepler1(e float64, M unit.Angle, places int) (E unit.Angle, err error) {
f := func(E0 float64) float64 {
return M.Rad() + e*math.Sin(E0) // (30.5) p. 195
}
ea, err := iterate.DecimalPlaces(f, M.Rad(), places, places*5)
return unit.Angle(ea), err
}
开发者ID:soniakeys,项目名称:meeus,代码行数:20,代码来源:kepler.go
示例3: physical
func (m *moon) physical(A, bʹ unit.Angle) (lʺ, bʺ unit.Angle) {
// (53.2) p. 373
sA, cA := A.Sincos()
lʺ = -m.τ + (m.ρ.Mul(cA) + m.σ.Mul(sA)).Mul(bʹ.Tan())
bʺ = m.σ.Mul(cA) - m.ρ.Mul(sA)
return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:7,代码来源:moon.go
示例4: Kepler2
// Kepler2 solves Kepler's equation by iteration.
//
// The iterated formula is
//
// E1 = E0 + (M + e * sin(E0) - E0) / (1 - e * cos(E0))
//
// Argument e is eccentricity, M is mean anomaly,
// places is the desired number of decimal places in the result.
//
// Result E is eccentric anomaly.
//
// The function converges over a wider range of inputs than does Kepler1
// but it also fails to converge for some values of e and M.
func Kepler2(e float64, M unit.Angle, places int) (E unit.Angle, err error) {
f := func(E0 float64) float64 {
se, ce := math.Sincos(E0)
return E0 + (M.Rad()+e*se-E0)/(1-e*ce) // (30.7) p. 199
}
ea, err := iterate.DecimalPlaces(f, M.Rad(), places, places)
return unit.Angle(ea), err
}
开发者ID:soniakeys,项目名称:meeus,代码行数:21,代码来源:kepler.go
示例5: SepPauwels
// SepPauwels returns the angular separation between two celestial bodies.
//
// The algorithm is a numerically stable form of that used in Sep.
func SepPauwels(r1, d1, r2, d2 unit.Angle) unit.Angle {
sd1, cd1 := d1.Sincos()
sd2, cd2 := d2.Sincos()
cdr := (r2 - r1).Cos()
x := cd1*sd2 - sd1*cd2*cdr
y := cd2 * (r2 - r1).Sin()
z := sd1*sd2 + cd1*cd2*cdr
return unit.Angle(math.Atan2(math.Hypot(x, y), z))
}
开发者ID:soniakeys,项目名称:meeus,代码行数:12,代码来源:angle.go
示例6: GalToEq
// GalToEq converts galactic coordinates to equatorial coordinates.
//
// Resulting equatorial coordinates will be referred to the standard equinox of
// B1950.0. For subsequent conversion to other epochs, see package precess and
// utility functions in package meeus.
func GalToEq(l, b unit.Angle) (α unit.RA, δ unit.Angle) {
sdLon, cdLon := (l - galacticLon0).Sincos()
sgδ, cgδ := galacticNorth.Dec.Sincos()
sb, cb := b.Sincos()
y := math.Atan2(sdLon, cdLon*sgδ-(sb/cb)*cgδ)
α = unit.RAFromRad(y + galacticNorth.RA.Rad())
δ = unit.Angle(math.Asin(sb*sgδ + cb*cgδ*cdLon))
return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:14,代码来源:coord.go
示例7: HzToEq
// HzToEq transforms horizontal coordinates to equatorial coordinates.
//
// A: azimuth
// h: elevation
// φ: latitude of observer on Earth
// ψ: longitude of observer on Earth
// st: sidereal time at Greenwich at time of observation.
//
// Sidereal time must be consistent with the equatorial coordinates
// in the sense that tf coordinates are apparent, sidereal time must be
// apparent as well.
//
// Results:
//
// α: right ascension
// δ: declination
func HzToEq(A, h, φ, ψ unit.Angle, st unit.Time) (α unit.RA, δ unit.Angle) {
sA, cA := A.Sincos()
sh, ch := h.Sincos()
sφ, cφ := φ.Sincos()
H := math.Atan2(sA, cA*sφ+sh/ch*cφ)
α = unit.RAFromRad(st.Rad() - ψ.Rad() - H)
δ = unit.Angle(math.Asin(sφ*sh - cφ*ch*cA))
return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:25,代码来源:coord.go
示例8: Kepler2a
// Kepler2a solves Kepler's equation by iteration.
//
// The iterated formula is the same as in Kepler2 but a limiting function
// avoids divergence.
//
// Argument e is eccentricity, M is mean anomaly,
// places is the desired number of decimal places in the result.
//
// Result E is eccentric anomaly.
func Kepler2a(e float64, M unit.Angle, places int) (E unit.Angle, err error) {
f := func(E0 float64) float64 {
se, ce := math.Sincos(E0)
// method of Leingärtner, p. 205
return E0 + math.Asin(math.Sin((M.Rad()+e*se-E0)/(1-e*ce)))
}
ea, err := iterate.DecimalPlaces(f, M.Rad(), places, places*5)
return unit.Angle(ea), err
}
开发者ID:soniakeys,项目名称:meeus,代码行数:18,代码来源:kepler.go
示例9: ApparentEccentricity
// ApparentEccentricity returns apparent eccenticity of a binary star
// given true orbital elements.
//
// e is eccentricity of the true orbit
// i is inclination relative to the line of sight
// ω is longitude of periastron
func ApparentEccentricity(e float64, i, ω unit.Angle) float64 {
ci := i.Cos()
sω, cω := ω.Sincos()
A := (1 - e*e*cω*cω) * ci * ci
B := e * e * sω * cω * ci
C := 1 - e*e*sω*sω
d := A - C
sD := math.Sqrt(d*d + 4*B*B)
return math.Sqrt(2 * sD / (A + C + sD))
}
开发者ID:soniakeys,项目名称:meeus,代码行数:16,代码来源:binary.go
示例10: Sep
// Sep returns the angular separation between two celestial bodies.
//
// The algorithm is numerically naïve, and while patched up a bit for
// small separations, remains unstable for separations near π.
func Sep(r1, d1, r2, d2 unit.Angle) unit.Angle {
sd1, cd1 := d1.Sincos()
sd2, cd2 := d2.Sincos()
cd := sd1*sd2 + cd1*cd2*(r1-r2).Cos() // (17.1) p. 109
if cd < base.CosSmallAngle {
return unit.Angle(math.Acos(cd))
}
// (17.2) p. 109
return unit.Angle(math.Hypot((r2-r1).Rad()*cd1, (d2 - d1).Rad()))
}
开发者ID:soniakeys,项目名称:meeus,代码行数:14,代码来源:angle.go
示例11: Times
// Times computes UT rise, transit and set times for a celestial object on
// a day of interest.
//
// The function argurments do not actually include the day, but do include
// a number of values computed from the day.
//
// p is geographic coordinates of observer.
// ΔT is delta T.
// h0 is "standard altitude" of the body.
// Th0 is apparent sidereal time at 0h UT at Greenwich.
// α3, δ3 are slices of three right ascensions and declinations.
//
// h0 unit is radians.
//
// Th0 must be the time on the day of interest, in seconds.
// See sidereal.Apparent0UT.
//
// α3, δ3 must be values at 0h dynamical time for the day before, the day of,
// and the day after the day of interest. Units are radians.
//
// Result units are seconds of day and are in the range [0,86400).
func Times(p globe.Coord, ΔT unit.Time, h0 unit.Angle, Th0 unit.Time, α3 []unit.RA, δ3 []unit.Angle) (tRise, tTransit, tSet unit.Time, err error) {
tRise, tTransit, tSet, err = ApproxTimes(p, h0, Th0, α3[1], δ3[1])
if err != nil {
return
}
αf := make([]float64, 3)
for i, α := range α3 {
αf[i] = α.Rad()
}
δf := make([]float64, 3)
for i, δ := range δ3 {
δf[i] = δ.Rad()
}
var d3α, d3δ *interp.Len3
d3α, err = interp.NewLen3(-86400, 86400, αf)
if err != nil {
return
}
d3δ, err = interp.NewLen3(-86400, 86400, δf)
if err != nil {
return
}
// adjust tTransit
{
th0 := (Th0 + tTransit.Mul(360.985647/360)).Mod1()
α := d3α.InterpolateX((tTransit + ΔT).Sec())
// local hour angle as Time
H := th0 - unit.TimeFromRad(p.Lon.Rad()+α)
tTransit -= H
}
// adjust tRise, tSet
sLat, cLat := p.Lat.Sincos()
adjustRS := func(m unit.Time) (unit.Time, error) {
th0 := (Th0 + m.Mul(360.985647/360)).Mod1()
ut := (m + ΔT).Sec()
α := d3α.InterpolateX(ut)
δ := d3δ.InterpolateX(ut)
Hrad := th0.Rad() - p.Lon.Rad() - α
sδ, cδ := math.Sincos(δ)
sH, cH := math.Sincos(Hrad)
h := math.Asin(sLat*sδ + cLat*cδ*cH)
md := (unit.TimeFromRad(h) - h0.Time()).Div(cδ * cLat * sH)
return m + md, nil
}
tRise, err = adjustRS(tRise)
if err != nil {
return
}
tSet, err = adjustRS(tSet)
return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:72,代码来源:rise.go
示例12: pa
func (m *moon) pa(λ, β, b unit.Angle) unit.Angle {
V := m.Ω + m.Δψ + m.σ.Div(sI)
sV, cV := V.Sincos()
sIρ, cIρ := (_I + m.ρ).Sincos()
X := sIρ * sV
Y := sIρ*cV*m.cε - cIρ*m.sε
ω := math.Atan2(X, Y)
α, _ := coord.EclToEq(λ+m.Δψ, β, m.sε, m.cε)
P := unit.Angle(math.Asin(math.Hypot(X, Y) * math.Cos(α.Rad()-ω) / b.Cos()))
if P < 0 {
P += 2 * math.Pi
}
return P
}
开发者ID:soniakeys,项目名称:meeus,代码行数:14,代码来源:moon.go
示例13: Kepler2b
// Kepler2b solves Kepler's equation by iteration.
//
// The iterated formula is the same as in Kepler2 but a (different) limiting
// function avoids divergence.
//
// Argument e is eccentricity, M is mean anomaly,
// places is the desired number of decimal places in the result.
//
// Result E is eccentric anomaly.
func Kepler2b(e float64, M unit.Angle, places int) (E unit.Angle, err error) {
f := func(E0 float64) float64 {
se, ce := math.Sincos(E0)
d := (M.Rad() + e*se - E0) / (1 - e*ce)
// method of Steele, p. 205
if d > .5 {
d = .5
} else if d < -.5 {
d = -.5
}
return E0 + d
}
ea, err := iterate.DecimalPlaces(f, M.Rad(), places, places)
return unit.Angle(ea), err
}
开发者ID:soniakeys,项目名称:meeus,代码行数:24,代码来源:kepler.go
示例14: TopocentricEcliptical
// TopocentricEcliptical returns topocentric ecliptical coordinates including parallax.
//
// Arguments λ, β are geocentric ecliptical longitude and latitude of a body,
// s is its geocentric semidiameter. φ, h are the observer's latitude and
// and height above the ellipsoid in meters. ε is the obliquity of the
// ecliptic, θ is local sidereal time, π is equatorial horizontal parallax
// of the body (see Horizonal()).
//
// Results are observed topocentric coordinates and semidiameter.
func TopocentricEcliptical(λ, β, s, φ unit.Angle, h float64, ε unit.Angle, θ unit.Time, π unit.Angle) (λʹ, βʹ, sʹ unit.Angle) {
S, C := globe.Earth76.ParallaxConstants(φ, h)
sλ, cλ := λ.Sincos()
sβ, cβ := β.Sincos()
sε, cε := ε.Sincos()
sθ, cθ := θ.Angle().Sincos()
sπ := π.Sin()
N := cλ*cβ - C*sπ*cθ
λʹ = unit.Angle(math.Atan2(sλ*cβ-sπ*(S*sε+C*cε*sθ), N))
if λʹ < 0 {
λʹ += 2 * math.Pi
}
cλʹ := λʹ.Cos()
βʹ = unit.Angle(math.Atan(cλʹ * (sβ - sπ*(S*cε-C*sε*sθ)) / N))
sʹ = unit.Angle(math.Asin(cλʹ * βʹ.Cos() * s.Sin() / N))
return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:26,代码来源:parallax.go
示例15: Time
// 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)
}
开发者ID:soniakeys,项目名称:meeus,代码行数:26,代码来源:line.go
示例16: Position
// Position computes apparent position angle and angular distance of
// components of a binary star.
//
// e is eccentricity of the true orbit
// a is angular apparent semimajor axis
// i is inclination relative to the line of sight
// Ω is position angle of the ascending node
// ω is longitude of periastron
// E is eccentric anomaly, computed for example with package kepler
// and the mean anomaly as returned by function M in this package.
//
// Return value θ is the apparent position angle, ρ is the angular distance.
func Position(e float64, a, i, Ω, ω, E unit.Angle) (θ, ρ unit.Angle) {
r := a.Mul(1 - e*E.Cos())
ν := unit.Angle(2 * math.Atan(math.Sqrt((1+e)/(1-e))*E.Div(2).Tan()))
sνω, cνω := (ν + ω).Sincos()
ci := i.Cos()
num := sνω * ci
θ = (unit.Angle(math.Atan2(num, cνω)) + Ω).Mod1()
ρ = r.Mul(math.Sqrt(num*num + cνω*cνω))
return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:22,代码来源:binary.go
示例17: ApproxTimes
// ApproxTimes computes approximate UT rise, transit and set times for
// a celestial object on a day of interest.
//
// The function argurments do not actually include the day, but do include
// values computed from the day.
//
// p is geographic coordinates of observer.
// h0 is "standard altitude" of the body.
// Th0 is apparent sidereal time at 0h UT at Greenwich.
// α, δ are right ascension and declination of the body.
//
// Th0 must be the time on the day of interest.
// See sidereal.Apparent0UT.
//
// α, δ must be values at 0h dynamical time for the day of interest.
func ApproxTimes(p globe.Coord, h0 unit.Angle, Th0 unit.Time, α unit.RA, δ unit.Angle) (tRise, tTransit, tSet unit.Time, err error) {
// approximate local hour angle
sLat, cLat := p.Lat.Sincos()
sδ1, cδ1 := δ.Sincos()
cH0 := (h0.Sin() - sLat*sδ1) / (cLat * cδ1) // (15.1) p. 102
if cH0 < -1 || cH0 > 1 {
err = ErrorCircumpolar
return
}
H0 := unit.TimeFromRad(math.Acos(cH0))
// approximate transit, rise, set times.
// (15.2) p. 102.
mt := unit.TimeFromRad(α.Rad()+p.Lon.Rad()) - Th0
tTransit = mt.Mod1()
tRise = (mt - H0).Mod1()
tSet = (mt + H0).Mod1()
return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:34,代码来源:rise.go
示例18: Angle
// Angle returns the angle between great circles defined by three points.
//
// Coordinates may be right ascensions and declinations or longitudes and
// latitudes. If r1, d1, r2, d2 defines one line and r2, d2, r3, d3 defines
// another, the result is the angle between the two lines.
//
// Algorithm by Meeus.
func Angle(r1, d1, r2, d2, r3, d3 unit.Angle) unit.Angle {
sd2, cd2 := d2.Sincos()
sr21, cr21 := (r2 - r1).Sincos()
sr32, cr32 := (r3 - r2).Sincos()
C1 := math.Atan2(sr21, cd2*d1.Tan()-sd2*cr21)
C2 := math.Atan2(sr32, cd2*d3.Tan()-sd2*cr32)
return unit.Angle(C1 + C2)
}
开发者ID:soniakeys,项目名称:meeus,代码行数:15,代码来源:line.go
示例19: Kepler3
// Kepler3 solves Kepler's equation by binary search.
//
// Argument e is eccentricity, M is mean anomaly.
//
// Result E is eccentric anomaly.
func Kepler3(e float64, M unit.Angle) (E unit.Angle) {
// adapted from BASIC, p. 206
MR := M.Mod1().Rad()
f := 1
if MR > math.Pi {
f = -1
MR = 2*math.Pi - MR
}
E0 := math.Pi * .5
d := math.Pi * .25
for i := 0; i < 53; i++ {
M1 := E0 - e*math.Sin(E0)
if MR-M1 < 0 {
E0 -= d
} else {
E0 += d
}
d *= .5
}
if f < 0 {
E0 = -E0
}
return unit.Angle(E0)
}
开发者ID:soniakeys,项目名称:meeus,代码行数:29,代码来源:kepler.go
示例20: General
// 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.
func General(φ, D unit.Angle, a float64, z unit.Angle) (lines []Line, center Point, u float64, ψ unit.Angle) {
sφ, cφ := φ.Sincos()
tφ := sφ / cφ
sD, cD := D.Sincos()
sz, cz := z.Sincos()
P := sφ*cz - cφ*sz*cD
for i := 0; i < 24; i++ {
l := Line{Hour: i}
H := float64(i-12) * 15 * math.Pi / 180
aH := math.Abs(H)
sH, cH := math.Sincos(H)
for _, d := range m {
tδ := math.Tan(d * math.Pi / 180)
H0 := math.Acos(-tφ * tδ)
if aH > H0 {
continue // sun below horizon
}
Q := sD*sz*sH + (cφ*cz+sφ*sz*cD)*cH + P*tδ
if Q < 0 {
continue // sun below plane of sundial
}
Nx := cD*sH - sD*(sφ*cH-cφ*tδ)
Ny := cz*sD*sH - (cφ*sz-sφ*cz*cD)*cH - (sφ*sz+cφ*cz*cD)*tδ
l.Points = append(l.Points, Point{a * Nx / Q, a * Ny / Q})
}
if len(l.Points) > 0 {
lines = append(lines, l)
}
}
center.X = a / P * cφ * sD
center.Y = -a / P * (sφ*sz + cφ*cz*cD)
aP := math.Abs(P)
u = a / aP
ψ = unit.Angle(math.Asin(aP))
return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:49,代码来源:sundial.go
注:本文中的github.com/soniakeys/unit.Angle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论