Skip to content

Commit

Permalink
Go: added function vsopSphereToRect.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinekitty committed Oct 30, 2023
1 parent 38c42de commit 8a73ece
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
9 changes: 9 additions & 0 deletions generate/template/astronomy.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,15 @@ func vsopRotate(eclip terseVector) terseVector {
}
}

func vsopSphereToRect(lon, lat, radius float64) terseVector {
rcoslat := radius * math.Cos(lat)
return terseVector{
rcoslat * math.Cos(lon),
rcoslat * math.Sin(lon),
radius * math.Sin(lat),
}
}

type jupiterMoon struct {
mu float64
al0 float64
Expand Down
40 changes: 20 additions & 20 deletions source/golang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const (
```

<a name="AngleBetween"></a>
## func [AngleBetween](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1103>)
## func [AngleBetween](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1112>)

```go
func AngleBetween(avec AstroVector, bvec AstroVector) float64
Expand All @@ -187,7 +187,7 @@ func DaysFromCalendar(year, month, day, hour, minute int, second float64) float6


<a name="DefineStar"></a>
## func [DefineStar](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1164>)
## func [DefineStar](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1173>)

```go
func DefineStar(body Body, ra, dec, distanceLightYears float64) error
Expand All @@ -196,7 +196,7 @@ func DefineStar(body Body, ra, dec, distanceLightYears float64) error


<a name="DegreesFromRadians"></a>
## func [DegreesFromRadians](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L938>)
## func [DegreesFromRadians](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L947>)

```go
func DegreesFromRadians(radians float64) float64
Expand All @@ -214,7 +214,7 @@ func Dot(a, b AstroVector) float64
Returns the scalar dot product of two vectors.

<a name="MassProduct"></a>
## func [MassProduct](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L981>)
## func [MassProduct](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L990>)

```go
func MassProduct(body Body) float64
Expand All @@ -223,7 +223,7 @@ func MassProduct(body Body) float64
Returns the product of mass and universal gravitational constant of a Solar System body. For problems involving the gravitational interactions of Solar System bodies, it is helpful to know the product GM, where G = the universal gravitational constant and M = the mass of the body. In practice, GM is known to a higher precision than either G or M alone, and thus using the product results in the most accurate results. This function returns the product GM in the units au^3/day^2. The values come from page 10 of a JPL memorandum regarding the DE405/LE405 ephemeris: https://web.archive.org/web/20120220062549/http://iau-comm4.jpl.nasa.gov/de405iom/de405iom.pdf

<a name="ObserverGravity"></a>
## func [ObserverGravity](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1134>)
## func [ObserverGravity](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1143>)

```go
func ObserverGravity(latitude, height float64) float64
Expand All @@ -232,7 +232,7 @@ func ObserverGravity(latitude, height float64) float64
Calculates the gravitational acceleration experienced by an observer on the Earth. This function implements the WGS 84 Ellipsoidal Gravity Formula. The result is a combination of inward gravitational acceleration with outward centrifugal acceleration, as experienced by an observer in the Earth's rotating frame of reference. The resulting value increases toward the Earth's poles and decreases toward the equator, consistent with changes of the weight measured by a spring scale of a fixed mass moved to different latitudes and heights on the Earth. The latitude is of the observer in degrees north or south of the equator. By formula symmetry, positive latitudes give the same answer as negative latitudes, so the sign does not matter. The height is specified above the sea level geoid in meters. No range checking is done; however, accuracy is only valid in the range 0 to 100000 meters. The return value is the gravitational acceleration expressed in meters per second squared.

<a name="PlanetOrbitalPeriod"></a>
## func [PlanetOrbitalPeriod](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L948>)
## func [PlanetOrbitalPeriod](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L957>)

```go
func PlanetOrbitalPeriod(body Body) float64
Expand All @@ -241,7 +241,7 @@ func PlanetOrbitalPeriod(body Body) float64
PlanetOrbitalPeriod returns the average number of days it takes for a planet to orbit the Sun.

<a name="RadiansFromDegrees"></a>
## func [RadiansFromDegrees](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L943>)
## func [RadiansFromDegrees](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L952>)

```go
func RadiansFromDegrees(degrees float64) float64
Expand All @@ -259,7 +259,7 @@ func RefractionAngle(refraction Refraction, altitude float64) float64
RefractionAngle calculates the amount of "lift" to an altitude angle caused by atmospheric refraction. Given an altitude angle and a refraction option, calculates the amount of "lift" caused by atmospheric refraction. This is the number of degrees higher in the sky an object appears due to the lensing of the Earth's atmosphere. This function works best near sea level. To correct for higher elevations, call Atmosphere for that elevation and multiply the refraction angle by the resulting relative density. The refraction parameter specifies which refraction correction to use. If set to NormalRefraction, uses a well\-behaved refraction model that works well for all valid values \(\-90 to \+90\) of altitude. If set to JplHorizonsRefraction, this function returns a value compatible with the JPL Horizons tool. This is provided for internal unit tests that compare against JPL Horizons data. Any other value, including NoRefraction, causes this function to return 0.0. The return value is a non\-negative value expressed in degrees of refraction above the horizontal.

<a name="SiderealTime"></a>
## func [SiderealTime](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1338>)
## func [SiderealTime](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1347>)

```go
func SiderealTime(time *AstroTime) float64
Expand Down Expand Up @@ -387,7 +387,7 @@ type AstroVector struct {
```

<a name="GeoMoon"></a>
### func [GeoMoon](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1896>)
### func [GeoMoon](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1905>)

```go
func GeoMoon(time AstroTime) AstroVector
Expand All @@ -396,7 +396,7 @@ func GeoMoon(time AstroTime) AstroVector
GeoMoon calculates the equatorial geocentric position of the Moon at a given time. The returned vector indicates the Moon's center relative to the Earth's center. The vector components are expressed in AU \(astronomical units\). The coordinates are oriented with respect to the Earth's equator at the J2000 epoch. In Astronomy Engine, this orientation is called EQJ.

<a name="RotateVector"></a>
### func [RotateVector](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1507>)
### func [RotateVector](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1516>)

```go
func RotateVector(rotation RotationMatrix, vector AstroVector) AstroVector
Expand Down Expand Up @@ -552,7 +552,7 @@ type JupiterMoonsInfo struct {
```

<a name="JupiterMoons"></a>
### func [JupiterMoons](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L2059>)
### func [JupiterMoons](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L2068>)

```go
func JupiterMoons(time AstroTime) JupiterMoonsInfo
Expand Down Expand Up @@ -641,7 +641,7 @@ type RotationMatrix struct {
```

<a name="CombineRotation"></a>
### func [CombineRotation](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1529>)
### func [CombineRotation](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1538>)

```go
func CombineRotation(a, b RotationMatrix) RotationMatrix
Expand All @@ -668,7 +668,7 @@ func InverseRotation(rotation RotationMatrix) RotationMatrix
Calculates the inverse of a rotation matrix. Given a rotation matrix that performs some coordinate transform, this function returns the matrix that reverses that transform.

<a name="Pivot"></a>
### func [Pivot](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1565>)
### func [Pivot](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1574>)

```go
func Pivot(rotation RotationMatrix, axis int, angle float64) (*RotationMatrix, error)
Expand All @@ -677,7 +677,7 @@ func Pivot(rotation RotationMatrix, axis int, angle float64) (*RotationMatrix, e
Pivot re\-orients a rotation matrix by pivoting it by an angle around one of its axes. Given a rotation matrix, a selected coordinate axis, and an angle in degrees, this function pivots the rotation matrix by that angle around that coordinate axis. For example, if you have rotation matrix that converts ecliptic coordinates \(ECL\) to horizontal coordinates \(HOR\), but you really want to convert ECL to the orientation of a telescope camera pointed at a given body, you can use Pivot twice: \(1\) pivot around the zenith axis by the body's azimuth, then \(2\) pivot around the western axis by the body's altitude angle. The resulting rotation matrix will then reorient ECL coordinates to the orientation of your telescope camera. The axis parameter is an integer that selects which axis to pivot about: 0=x, 1=y, 2=z. The angle parameter is an angle in degrees indicating the amount of rotation around the specified axis. Positive angles indicate rotation counterclockwise as seen from the positive direction along that axis, looking towards the origin point of the orientation system. Any finite number of degrees is allowed, but best precision will result from keeping angle in the range \[\-360, \+360\].

<a name="RotationEclEqj"></a>
### func [RotationEclEqj](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1608>)
### func [RotationEclEqj](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1617>)

```go
func RotationEclEqj() RotationMatrix
Expand All @@ -686,7 +686,7 @@ func RotationEclEqj() RotationMatrix
Calculates a rotation matrix from J2000 mean ecliptic \(ECL\) to J2000 mean equator \(EQJ\).

<a name="RotationEqdEqj"></a>
### func [RotationEqdEqj](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1601>)
### func [RotationEqdEqj](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1610>)

```go
func RotationEqdEqj(time *AstroTime) RotationMatrix
Expand All @@ -695,7 +695,7 @@ func RotationEqdEqj(time *AstroTime) RotationMatrix
Calculates a rotation matrix that converts equator\-of\-date \(EQD\) to J2000 mean equator \(EQJ\).

<a name="RotationEqjEcl"></a>
### func [RotationEqjEcl](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1628>)
### func [RotationEqjEcl](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1637>)

```go
func RotationEqjEcl() RotationMatrix
Expand All @@ -704,7 +704,7 @@ func RotationEqjEcl() RotationMatrix
Calculates a rotation matrix from J2000 mean equator \(EQJ\) to J2000 mean ecliptic \(ECL\).

<a name="RotationEqjGal"></a>
### func [RotationEqjGal](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1648>)
### func [RotationEqjGal](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1657>)

```go
func RotationEqjGal() RotationMatrix
Expand All @@ -713,7 +713,7 @@ func RotationEqjGal() RotationMatrix
Calculates a rotation matrix from J2000 mean equator \(EQJ\) to galactic \(GAL\).

<a name="RotationGalEqj"></a>
### func [RotationGalEqj](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1668>)
### func [RotationGalEqj](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1677>)

```go
func RotationGalEqj() RotationMatrix
Expand All @@ -722,7 +722,7 @@ func RotationGalEqj() RotationMatrix


<a name="SearchContext"></a>
## type [SearchContext](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L2092-L2094>)
## type [SearchContext](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L2101-L2103>)



Expand Down Expand Up @@ -786,7 +786,7 @@ type StateVector struct {
```

<a name="RotateState"></a>
### func [RotateState](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1516>)
### func [RotateState](<https://github.com/cosinekitty/astronomy/blob/golang/source/golang/astronomy.go#L1525>)

```go
func RotateState(rotation RotationMatrix, state StateVector) StateVector
Expand Down
9 changes: 9 additions & 0 deletions source/golang/astronomy.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,15 @@ func vsopRotate(eclip terseVector) terseVector {
}
}

func vsopSphereToRect(lon, lat, radius float64) terseVector {
rcoslat := radius * math.Cos(lat)
return terseVector{
rcoslat * math.Cos(lon),
rcoslat * math.Sin(lon),
radius * math.Sin(lat),
}
}

type jupiterMoon struct {
mu float64
al0 float64
Expand Down

0 comments on commit 8a73ece

Please sign in to comment.