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, as well as the full project test suite, locally 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 77.96%. Comparing base (d5289b9) to head (39359a0).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #6854   +/-   ##
=========================================
  Coverage     77.95%   77.96%           
- Complexity     6429     6435    +6     
=========================================
  Files           736      737    +1     
  Lines         21476    21489   +13     
  Branches       4204     4205    +1     
=========================================
+ Hits          16742    16754   +12     
- Misses         4060     4061    +1     
  Partials        674      674           

☔ 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 branch 2 times, most recently from 86bafb8 to 4d54467 Compare October 20, 2025 17:15
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