[FEAT] Add Newton's Law of Gravitation algorithm #6855
+149
−0
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 PR adds an implementation of Newton's Law of Universal Gravitation (
Gravitation.java) to thephysicsmodule.clang-format -i --style=file src\main\java\com\thealgorithms\physics\Gravitation.javaThis utility class provides two key, related functions:
calculateGravitationalForce: Calculates the 2D force vector between two bodies.calculateCircularOrbitVelocity: Calculates the speed required for a stable circular orbit.I have run the
GravitationTest.javafile locally and overall using mvn test, and all tests passed with a BUILD SUCCESS.