soniakeys / meeus

Implementation of "Astronomical Algorithms" by Jean Meeus
MIT License
342 stars 56 forks source link

index out of range error in planetelements.Mean() #19

Open chrissnell opened 7 months ago

chrissnell commented 7 months ago
    jde := julian.TimeToJD(time.Now())
    var e planetelements.Elements
    planetelements.Mean(planetelements.Earth, jde, &e)
    earthSemiMajorAxis := e.Axis
    fmt.Println("semi-major axis of Earth:", earthSemiMajorAxis)

yields:



goroutine 1 [running]:
github.com/soniakeys/meeus/v3/base.Horner(...)
        /Users/cjs/dev/go/pkg/mod/github.com/soniakeys/meeus/v3@v3.0.1/base/math.go:29
github.com/soniakeys/meeus/v3/planetelements.Mean(0x100c77018?, 0x1400005c010?, 0x14000108e98)
        /Users/cjs/dev/go/pkg/mod/github.com/soniakeys/meeus/v3@v3.0.1/planetelements/planetelements.go:129 +0x20c
main.main()
        /Users/cjs/dev/solar/main.go:35 +0x174
exit status 2```
chrissnell commented 7 months ago

I think a more Go-like way to implement this would be to have the code work something like this:

element := planetelements.New(planet.Earth)
fmt.Println("semi-major axis:", element.Axis())
chrissnell commented 7 months ago

I see that Sonia has passed. Maybe someone else will take up this issue.