Add ReferenceFrame#separation_from for angular separation#269
Merged
Conversation
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`).
There was a problem hiding this comment.
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_productplus unit tests for the new vector operation and separation behavior. - Update
SolarSystemBody#phase_angleto useseparation_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? | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an angular separation method on
ReferenceFrameclass, so it works uniformly across all frame and body types (planets,Moon,Sun, deep-sky objects,TEME).