Commit Graph

1245 Commits

Author SHA1 Message Date
Don Cross
e487fa651f Go: added function InverseRotation. 2023-10-26 10:51:19 -04:00
Don Cross
af53f189e8 Go: added function IdentityMatrix. 2023-10-26 10:37:13 -04:00
Don Cross
ba62eea34f Go: added bodyState type and exportState function. 2023-10-26 10:32:15 -04:00
Don Cross
66e40d825f Go: added user-defined stars
Internal type: starDef
Internal array variable: starTable
Functions:

    getStar
    userDefinedStar
    DefineStar
2023-10-26 10:25:16 -04:00
Don Cross
a9179ed22a Go: added nutation, state vector, and rotation matrix functions.
Added the following functions to Go:

    nutationRot
    nutation
    nutationPosVel
    RotateState
    CombineRotation
    RotationEqdEqj
2023-10-25 17:26:30 -04:00
Don Cross
c850481306 Go: added calcShadow and vector dot product. 2023-10-25 16:44:39 -04:00
Don Cross
e393349b4e Go: SiderealTime
Fixed a bug in the Earth Tilt function etilt.
Implemented the SiderealTime function.
2023-10-08 15:38:51 -04:00
Don Cross
774b636dac Go: iau2000b, etilt, era.
More low-level functions necessary to calculating Earth orientation.
iau2000b calculates nutation angles.
etilt calculates overall axial tilt of the Earth.
era calculates the Earth Rotation Angle.
2023-10-08 09:56:42 -04:00
Don Cross
6cc0b8cfb0 Go: Atmosphere function 2023-10-07 20:27:00 -04:00
Don Cross
2393bb327e Go: GeoMoon calculates the Moon's geocentric position. 2023-10-07 15:05:12 -04:00
Don Cross
1b53dd60ac Go: added more functions
I'm working toward implementing the GeoMoon function.
I added the following, which are all required to get to that point.

meanObliq
eclOblToEquVec
eclToEquVec
precessionRot
precession
RotateVector
2023-10-06 21:12:44 -04:00
Don Cross
9a500abe2a Go: added functions DaysFromCalendar, TimeFromCalendar. Also added more documentation. 2023-10-06 20:32:34 -04:00
Don Cross
e38e7d5e25 Go: added function CalendarFromDays.
Added the function CalendarFromDays, which converts a UT value to
a calendar date and time.

Added script `rungo` which is a shortcut for compiling and testing
changes to the Go source code template.
2023-10-06 14:01:05 -04:00
Don Cross
d9cb9d6ed2 Go: added some vector and angle functions.
Added functions:
    DegreesFromRadians
    RadiansFromDegrees
    AngleBetween
    StateVector.Position
    StateVector.Velocity

Changed existing functions to pass structs by value,
just like we do in the C code. This is a safety feature
to signal value semantics and a contract not to mutate the
argument state.

Run Go tests with the -v option to log more info about what's happening.
2023-10-05 21:28:11 -04:00
Don Cross
4941fbb5de Go: generate constellation tables. 2023-10-04 22:02:00 -04:00
Don Cross
92dd08e4c4 Add Go to the front-page table of supported languages.
Added SVG logo for Go.
Added a table entry for Go examples, source, and documentation.
Sorted the language list in alphabetical order: moved Python last.
2023-10-04 19:44:18 -04:00
Don Cross
0df81a7ff6 Specify explicit paths for gomarkdoc.
I need gomarkdoc to generate identical output whether
I run it locally or in GitHub Actions, to verify that the
build process is working correctly. Hopefully these options
will do the trick.
2023-10-04 16:27:31 -04:00
Don Cross
21001da8c1 Use gomarkdoc to generate Markdown documentation for the Go source. 2023-10-04 15:05:20 -04:00
Don Cross
cebe749c2a Go: reworking documentation comments in Go Doc format.
Following the standard comment format for documentation
comments in Go:

https://go.dev/doc/comment

Later we will figure out how to generate online documentation
from these comments.
2023-10-04 12:48:54 -04:00
Don Cross
b9c5bcbda2 Go: implemented AddDays function. 2023-10-03 21:49:12 -04:00
Don Cross
9756c1ebe0 Go: use standard naming conventions, remove "status" fields.
In Go, all symbols should use PascalCase or camelCase.
Go programmers dislike ALL_UPPER_CASE_WITH_UNDERSCORES.
Use PascalCase for exported/public symbols, camelCase for internal/private symbols.

In general, we should follow the Go Style Guide:
https://google.github.io/styleguide/go/index

I recommend we more closely follow the implementation of the C# code
than the C code for figuring out how to name things.
The C# version of Astronomy Engine is a better reference because
Go allows quasi-object-oriented syntax and uses a similar preferred naming style.

We will use idiomatic error reporting and handling, as described here:
https://go.dev/blog/error-handling-and-go
I removed the "status" fields from all the structs, and deleted
the enumerated type astroStatus. I will add a custom error type later,
and report human-readable error messages as is preferred by Go programmers.
2023-10-01 11:44:23 -04:00
Don Cross
d6565550ac Add unit test framework for Go. 2023-09-30 19:15:17 -04:00
Don Cross
a3ee98f870 Merge branch 'master' into golang 2023-09-30 16:08:58 -04:00
Don Cross
17af457d9d Go: add go.mod, and update code generator.
Rework astronomy.go as a module named "astronomy".
Provide a go.mod to define the module.
Add Go as a known programming language to the code generator.
2023-09-30 15:34:05 -04:00
danny
a7d5f79dad add astro_time_t and test TerrestrialTime 2023-09-30 00:35:16 +03:30
Don Cross
3cf4065126 Minor C code style suggestion from cppcheck. 2023-09-21 17:42:53 -04:00
Don Cross
c247250df7 C Windows: use GetSystemTimePreciseAsFileTime.
It turns out that GetSystemTimeAsFileTime only returns
time with millisecond resolution.
In order to get microsecond resolution in Astronomy_CurrentTime(),
I had to switch to GetSystemTimePreciseAsFileTime for Windows.

Example output from unit test:

C Test_AstroTime: PASS - realtime increment = 3.143e-07 seconds after 1 iterations.
2023-08-28 14:32:43 -04:00
Don Cross
dd0245cbf8 C: Astronomy_GetCurrentTime supports microsecond resolution.
This is a follow-up to work provided by:
Eric Wheeler, KJ7LNW <astronomy-git@z.ewheeler.org>

Before now, the C function Astronomy_GetCurrentTime returned
the current time from the system clock, but only with whole
second resolution. Now it supports microsecond resolution on
Linux/Unix, Mac OS, and Windows.

For unsupported platforms, a compiler error will occur
to indicate that microsecond resolution is not available.
However, it is possible to define one of the following two
preprocessor symbols to work around the compiler error:

1. ASTRONOMY_ENGINE_NO_CURRENT_TIME
   Excludes the function Astronomy_CurrentTime from the build.
   If your project does not need to obtain the current time,
   or your hardware platform does not provide current date
   and time in the first place, this is likely the better option.

2. ASTRONOMY_ENGINE_WHOLE_SECOND
   If your project does need to use the current date and time
   for astronomy calculations, and it can tolerate whole
   second resolution, this option provides a version of
   Astronomy_CurrentTime that uses a call to `time(NULL)`.

Notes:

- Added unit test to confirm at least millisecond resolution.
  Because these tests have to run on GitHub Actions cloud platform,
  and those systems can be heavily CPU-loaded, I want to be tolerant
  of resolution and avoid false failures.

- Added detection of Mac platform.

- Added preprocessor options documented above.

- On Windows, use ULARGE_INTEGER and eliminated one integer division.

- Added comments and developer documentation.

- Converted tabs to spaces in astronomy.c, for consistent code format.
2023-08-28 12:24:20 -04:00
Eric Wheeler
311a0cca59 Support microsecond time resolution
This patch adds support for microsecond time resolution on the UNIX and
WIN32 platforms.

Implementation details:

Previously, the `Astronomy_CurrentTime()` function used `time(NULL)` to
get the current time, thus providing 1-second resolution.  This patch
uses `gettimeofday()` for UNIX and `GetSystemTimeAsFileTime()` for WIN32
platforms.  If neither are supported, it will fall back to `time()` and
issue a #warning.  (Note that windows.h defines ARRAYSIZE, which may or
may not be compatible.  Thus, the internal define `ARRAYSIZE` is renamed
to `ASTRO_ARRAYSIZE`.)

The UNIX code was tested in Linux, and in arm-eabi-none under newlib.
The WIN32 code was tested using MinGW/64 under WINE.

Use case:

One-second resolution is enough in most cases.  However, there are cases
where higher resolutions are desirable.  For example:

We are using the astronomy.c library to control a mechanical rotor to
track celestial objects (planets, stars, and satellites).  The rotor
controller uses a PID controller with 100 tick/sec updates, and tracks
the velocity of the azimuth and elevation angles from the previous tick.
With 1-second resolution, the PID controller jerks and oscillates once
per second as it adjusts to the new position.  With at least
10-millisecond resolution (100/sec), it can calculate the per-tick
velocity change and track smoothly with far less jitter.

More information about the project:
	Source using astronomy.c:
	    https://github.com/KJ7NLL/space-ham

	Lego-controlled az/el:
	    https://youtu.be/vrlw4QPKMRY

	Lego-controlled telescope focus:
	    https://youtu.be/p-5dOQG95xg

	APID+SMC control algorithm:
		https://doi.org/10.1016/j.precisioneng.2022.01.006

Signed-off-by: Eric Wheeler, KJ7LNW <astronomy-git@z.ewheeler.org>
Tested-by: Zeke Wheeler, KJ7NLL <kj7nll@gmail.com>
2023-08-27 18:22:58 -07:00
Don Cross
63ed3746b2 Misc fixes for Raspberry Pi 4 build.
On the Raspberry Pi 4, using latest versions of cppcheck
and pylint, a few more minor fixes were needed for eliminating
warnings.

Also had to soften a tolerance for the Kotlin unit tests.
2023-06-19 16:28:34 -04:00
Don Cross
7cf1a7eb7d Minor tweaks for cppcheck. Use const pointers for grav sim.
Slightly different cppcheck dev 2.11 behaviors have added
another warning that I don't care about. I don't want to
have to convert callback pointers to const, then cast them
to const.

However, it did find a couple of useful cases I fixed in
astronomy.c where GravSim parameters could be made const.
2023-06-19 12:37:39 -04:00
Don Cross
69311b3ccf Adjusted cppcheck options and fixed more warnings. 2023-03-26 06:47:09 -04:00
Don Cross
501c19015b Run cppcheck. Fixed errors in C code found by cppcheck. 2023-03-25 14:46:42 -04:00
Don Cross
bd2db6a380 Version 2.1.17: add metersAboveGround parameter to SearchRiseSet. 2023-03-13 21:40:01 -04:00
Don Cross
c85881c25b Python: added metersAboveGround parameter to SearchRiseSet. 2023-03-13 20:42:46 -04:00
Don Cross
6c59d14bd4 Python: added Atmosphere function. 2023-03-13 16:16:53 -04:00
Don Cross
8c55fbad79 JS: Added metersAboveGround parameter to SearchRiseSet. 2023-03-13 13:06:37 -04:00
Don Cross
66cd0147b5 JS: Added Atmosphere function. 2023-03-13 09:54:54 -04:00
Don Cross
5e2292dfa6 Kotlin: added metersAboveGround parameter to searchRiseSet. 2023-03-12 22:10:50 -04:00
Don Cross
de8521fa49 Kotlin: atmosphere function. 2023-03-12 14:34:14 -04:00
Don Cross
09016badda C#: use my own hypot function internally. 2023-03-12 12:16:24 -04:00
Don Cross
6c3a7ab753 C#: Atmosphere, metersAboveGround in SearchRiseSet. 2023-03-12 11:17:47 -04:00
Don Cross
7bb9d02053 C#: Atmosphere function. 2023-03-11 20:23:20 -05:00
Don Cross
cdd75c7810 C SearchRiseSetEx: moved metersAboveGround parameter to end.
Because I plan on adding metersAboveGround as a parameter
that defaults to 0.0 in the other languages, and I want
the language implementations to be reasonably consistent,
I moved the metersAboveGround parameter to the end of
the parameter list for the C version of SearchRiseSetEx.
2023-03-11 18:50:57 -05:00
Don Cross
9a0151d9d4 C: Added unit tests for Atmosphere function. 2023-03-06 14:15:30 -05:00
Don Cross
c275922c0e C: rise/set now corrects for height above ground.
I realized I had to rework the RiseSetEx function so that
it accepts a height above ground level, rather than a generic
altitude angle correction, because atmospheric effects are
important both for the horizon dip angle and for the amount
of refraction at ground level.

The atmosphere calculations were interesting enough that
I made them public as a new function Astronomy_Atmosphere.
This returns the idealized temperature, pressure, and relative
density of air at the given elevation above/below sea level.
2023-03-05 22:05:40 -05:00
Don Cross
cc7d9f5bc9 C: Implemented horizon dip calculation for observer above ground.
This is the first step toward calculating body rise/set times
for an observer that is significantly above the ground.
It figures out the angular correction of the horizon
using both parallax and refractive correction of a light
ray from the horizon to the observer's eye.
2023-03-05 13:56:26 -05:00
Don Cross
543ffa358a Version 2.1.16 2023-02-26 18:02:18 -05:00
Don Cross
1de31cf21f C#: Implemented Observer.ToString(). 2023-02-26 17:08:07 -05:00
Don Cross
ce0acf6d44 Kotlin: support calendar dates for years -999999 to +999999.
Enhanced the Time class to correctly calculate calendar
dates for the year range -999999 to +999999.

Made unit tests in C, C#, and Kotlin all exercise
the full year range, for February 28 and March 1 in each year,
to make sure we cover before and after each potential leap day.
2023-02-26 12:54:57 -05:00