|
@@ -43,5 +43,13 @@ class Vector3 {
|
|
* @returns {void}
|
|
* @returns {void}
|
|
*/
|
|
*/
|
|
function calculateGravity(moonA, moonB) {
|
|
function calculateGravity(moonA, moonB) {
|
|
-
|
|
|
|
-}
|
|
|
|
|
|
+ // The gravitational pull on Moon A caused by Moon B
|
|
|
|
+ const gravityA = new Vector3(
|
|
|
|
+ // eslint-disable-next-line no-nested-ternary
|
|
|
|
+ moonB.x > moonA.x ? 1 : (moonB.x < moonA.x ? -1 : 0),
|
|
|
|
+ // eslint-disable-next-line no-nested-ternary
|
|
|
|
+ moonB.y > moonA.y ? 1 : (moonB.y < moonA.y ? -1 : 0),
|
|
|
|
+ // eslint-disable-next-line no-nested-ternary
|
|
|
|
+ moonB.z > moonA.z ? 1 : (moonB.z < moonA.z ? -1 : 0),
|
|
|
|
+ );
|
|
|
|
+}
|