Skip to content

Compute the sky orientation once per chart - #22

Merged
rhannequin merged 3 commits into
mainfrom
faster-horizontal
Oct 31, 2026
Merged

rhannequin merged 3 commits into
mainfrom
faster-horizontal

Conversation

@rhannequin

@rhannequin rhannequin commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Rendering a full chart took 2.3 s, mostly in the conversion of each point of the sky to horizontal coordinates. Astronoby's pipeline builds the precession and nutation matrices and the sidereal time again for every point, about 325 µs each, although they only depend on the observer and the instant.

Astronoby::HorizontalTransformation, added in Astronoby 0.11 after rhannequin/astronoby#314, computes them once. Context builds one when it is created and Context#horizontal_coordinates uses it, so the layers don't change. Each point then costs about 4 µs.

  • A chart with the boundaries, lines, stars, names, ecliptic, planets, Sun and Moon renders in 0.119 s instead of 2.3 s.
  • Skymap now requires Astronoby ~> 0.11.
  • The first version of this PR had its own Skymap::Sky. On Astronoby's main it gave the same positions as HorizontalTransformation for 5,200 stars at four observers and times, so it is removed.

Every point of the sky went through Astronoby's whole pipeline, which
builds the precession and nutation matrices and the sidereal time again
each time, about 325 microseconds per point. Sky computes them once for
the observer and the instant, so a point costs about 5 microseconds and a
full chart renders in 0.1 s instead of 2.3 s.

Astronoby multiplies the precession and nutation matrices in the other
order when it has no ephemeris. Sky uses the order of its ephemeris path,
so positions move by less than 0.1 arcsecond.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the chart-rendering optimization.

No open issues 🎉

What changed in this PR

Optimizes chart rendering by computing sky orientation once per chart rather than repeating it for every point, while keeping the layer interfaces unchanged.

Changes:

  • Adds Skymap::Sky to cache precession, nutation, and sidereal time, and routes Context coordinate conversion through it.
  • Adds tests comparing horizontal coordinates with Astronoby and checking azimuth bounds.
  • Documents the reported roughly 20× rendering speedup and small positional differences.
File Description
spec/​skymap/​sky_spec.rb Tests coordinate agreement and azimuth bounds.
lib/​skymap/​sky.rb Implements horizontal conversion using cached sky orientation.
lib/​skymap/​context.rb Creates one Sky instance and delegates coordinate conversion.
lib/​skymap.rb Loads the new Sky class.
CHANGELOG.md Records rendering performance and positional changes.

Review effort: Balanced

Astronoby 0.11 computes the rotation and the sidereal time once per
observer and instant, which is what Skymap::Sky did. Context uses it
directly and Sky is removed, and the dependency moves to ~> 0.11.
@rhannequin
rhannequin merged commit fe0224e into main Oct 31, 2026
4 checks passed
@rhannequin
rhannequin deleted the faster-horizontal branch October 31, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants