Skip to content

Conversation

@Priyanshu1303d
Copy link
Contributor

This PR adds an implementation of Newton's Law of Universal Gravitation (Gravitation.java) to the physics module.


  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file src\main\java\com\thealgorithms\physics\Gravitation.java

This utility class provides two key, related functions:

  1. calculateGravitationalForce: Calculates the 2D force vector between two bodies.
  2. calculateCircularOrbitVelocity: Calculates the speed required for a stable circular orbit.

I have run the GravitationTest.java file locally and overall using mvn test, and all tests passed with a BUILD SUCCESS.

@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.15%. Comparing base (ab65ac6) to head (db04332).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #6855   +/-   ##
=========================================
  Coverage     78.15%   78.15%           
- Complexity     6498     6503    +5     
=========================================
  Files           740      741    +1     
  Lines         21662    21675   +13     
  Branches       4235     4236    +1     
=========================================
+ Hits          16929    16940   +11     
- Misses         4062     4063    +1     
- Partials        671      672    +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.

@Priyanshu1303d Priyanshu1303d force-pushed the feat/gravitation-physics branch 2 times, most recently from 7cd59cb to ad8a195 Compare October 24, 2025 12:01
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