Skip to content

Astro feature#4

Merged
VPRamon merged 8 commits intomainfrom
astro-feature
Feb 12, 2026
Merged

Astro feature#4
VPRamon merged 8 commits intomainfrom
astro-feature

Conversation

@VPRamon
Copy link
Member

@VPRamon VPRamon commented Feb 11, 2026

This pull request introduces a new "astro" feature to the crate, providing built-in support for astronomical reference frames (such as ICRS, Ecliptic, Galactic, etc.) with convenient, frame-specific constructors and getters for spherical coordinates. It also enhances the affn-derive procedural macro to generate inherent methods (named constructors and accessors) for frames defined in the same crate as Direction/Position, and refines canonicalization behavior for direction creation. Several code and documentation improvements are included to support these changes.

New "astro" feature and astronomical frames:

  • Added an astro feature to Cargo.toml and implemented a new src/frames/astro.rs module containing standard astronomical frames (ICRS, Ecliptic, Galactic, Horizontal, ITRF, ECEF, etc.), each with appropriate spherical coordinate naming and documentation. These frames are feature-gated and only available when the astro feature is enabled. [1] [2] [3] [4]

Procedural macro enhancements:

  • Updated the affn-derive macro to support a new #[frame(inherent)] attribute, which generates inherent named constructors and getters (e.g., .ra(), .dec(), Direction::<ICRS>::new(ra, dec)) for frames defined in the same crate as Direction/Position. This includes parsing the new attribute, generating the relevant code, and updating documentation. [1] [2] [3] [4] [5] [6]

API and canonicalization changes:

  • Deprecated the generic Direction::<F>::new() constructor in favor of frame-specific constructors and made new_raw() the primary generic constructor, clarifying its intended use and canonicalization responsibilities. Updated documentation and code examples accordingly. [1] [2] [3] [4]

  • Fixed canonicalization in Cartesian-to-spherical conversion to ensure azimuth is always normalized to [0°, 360°) by using new_raw() with explicit normalization.

These changes make it much easier and safer to work with standard astronomical frames and their coordinate conventions, and provide a more ergonomic and discoverable API for users of the crate.

…on handling

- Introduced new feature `astro` in Cargo.toml to enable astronomical reference frames.
- Added `astro.rs` module defining various astronomical reference frames (ICRS, Horizontal, Ecliptic, etc.) with inherent methods.
- Enhanced `affn-derive` to support `#[frame(inherent)]` for generating inherent methods in derived frames.
- Updated `Direction` and `Position` types to utilize raw angle constructors, improving flexibility and performance.
- Refactored angular separation calculations in `Direction` and `Position` to use a more numerically stable Vincenty formula.
- Adjusted tests to ensure proper serialization/deserialization of spherical directions and positions.
@VPRamon VPRamon self-assigned this Feb 11, 2026
- Introduced `Rotation3`, `Translation3`, and `Isometry3` types for pure mathematical operations on 3D transformations.
- Implemented allocation-free and inline-friendly operators that work with raw `f64` vectors and `XYZ<f64>`.
- Added macro `impl_quantity_mul!` to generate multiplication implementations for unit-aware operations.
- Created a `serde_utils` module with a utility function to check for zero-sized types.

refactor: Enhance spherical coordinate conversions

- Added utility functions `canonicalize_azimuth` and `canonicalize_polar` for angle normalization.
- Refactored `Direction` and `Position` implementations to utilize new spherical conversion functions.
- Improved handling of azimuth and polar angles to ensure valid ranges and prevent domain errors.

test: Extend tests for new affine and spherical functionalities

- Added comprehensive tests for `Rotation3` and `Translation3` operations, including unit-aware multiplication.
- Updated tests for spherical direction and position to validate new canonicalization logic.
@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Code Coverage

Package Line Rate Complexity Health
src.ops 100% 0
src.frames 92% 0
src.cartesian 98% 0
src.spherical 94% 0
src 100% 0
Summary 97% (2099 / 2157) 0

@VPRamon VPRamon merged commit 59dc634 into main Feb 12, 2026
5 checks passed
@VPRamon VPRamon deleted the astro-feature branch February 12, 2026 16:46
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.

1 participant