Skip to content

Add ReferenceFrame#separation_from for angular separation#269

Merged
rhannequin merged 1 commit into
mainfrom
angular-separation
Jun 6, 2026
Merged

Add ReferenceFrame#separation_from for angular separation#269
rhannequin merged 1 commit into
mainfrom
angular-separation

Conversation

@rhannequin
Copy link
Copy Markdown
Owner

This adds an angular separation method on ReferenceFrame class, so it works uniformly across all frame and body types (planets, Moon, Sun, deep-sky objects, TEME).

This adds an angular separation method on `ReferenceFrame` class,
so it works uniformly across all frame and body types (planets, `Moon`, `Sun`,
deep-sky objects, `TEME`).
@rhannequin rhannequin self-assigned this Jun 5, 2026
@rhannequin rhannequin merged commit f3e3bc2 into main Jun 6, 2026
27 checks passed
@rhannequin rhannequin requested a review from Copilot June 6, 2026 07:39
@rhannequin rhannequin deleted the angular-separation branch June 6, 2026 07:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a first-class angular separation API on Astronoby::ReferenceFrame so callers can compute separations uniformly across bodies and frame types (including deep-sky objects and TEME), and reuses that API to simplify existing calculations.

Changes:

  • Add ReferenceFrame#separation_from (vector-based angular separation) with comparability checks.
  • Add Util::Maths.cross_product plus unit tests for the new vector operation and separation behavior.
  • Update SolarSystemBody#phase_angle to use separation_from, and document the new API (with new ephemeris helper for broader-date test data).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/support/test_ephem_helper.rb Adds a helper to load an INPOP 2000–2050 excerpt ephemeris for new separation specs.
spec/astronoby/util/maths_spec.rb Adds unit tests for Util::Maths.cross_product.
spec/astronoby/reference_frame_spec.rb Adds end-to-end specs validating separation across frames/body types and error cases.
lib/astronoby/util/maths.rb Introduces cross_product used by separation calculations.
lib/astronoby/reference_frame.rb Implements #separation_from and comparability validation.
lib/astronoby/bodies/solar_system_body.rb Refactors phase-angle computation to use the new separation API.
docs/reference_frames.md Documents #separation_from and provides usage example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +77 to +80
def separation_from(other)
ensure_comparable!(other)
return Angle.zero if @position.zero? || other.position.zero?

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