Skip to content

Conversation

@AliAlimohammadi
Copy link
Contributor

@AliAlimohammadi AliAlimohammadi commented Jan 20, 2026

Description

This PR adds a rectangular (Cartesian) to polar coordinate conversion to the conversions module.

The implementation:

  • Computes magnitude using $r = \sqrt{x^2 + y^2}$
  • Computes angle using $\theta = \text{atan2}(y, x)$ and converts it to degrees
  • Rounds both magnitude and angle to two decimal places
  • Uses only the Rust standard library

Changes Made

  • Added rectangular_to_polar.rs under src/conversions
  • Registered the new module in src/conversions/mod.rs
  • Included unit tests covering typical and edge-case inputs

Notes

  • No external dependencies were introduced
  • Code is formatted with cargo fmt
  • All tests pass successfully

Reference

Polar Coordinate System

@AliAlimohammadi
Copy link
Contributor Author

@siriak, this is ready to be merged.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.06%. Comparing base (4402903) to head (9930af9).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1003      +/-   ##
==========================================
- Coverage   96.06%   96.06%   -0.01%     
==========================================
  Files         371      372       +1     
  Lines       25943    25963      +20     
==========================================
+ Hits        24922    24941      +19     
- Misses       1021     1022       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@siriak siriak merged commit 8385617 into TheAlgorithms:master Jan 20, 2026
7 checks passed
@AliAlimohammadi AliAlimohammadi deleted the conversions-rectangular-to-polar branch January 20, 2026 20:32
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.

3 participants