12_1.js 824 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. class Vector3 {
  2. /**
  3. * A 3D vector
  4. *
  5. * @param {number} x The X value of this vector
  6. * @param {number} y The Y value of this vector
  7. * @param {number} z The Z value of this vector
  8. */
  9. constructor(x, y, z) {
  10. this.x = x;
  11. this.y = y;
  12. this.z = z;
  13. }
  14. /**
  15. * Add another vector to this one
  16. *
  17. * @param {Vector3} operand The vector to add to this one
  18. * @returns {void}
  19. */
  20. add(operand) {
  21. this.x += operand.x;
  22. this.y += operand.y;
  23. this.z += operand.z;
  24. }
  25. }
  26. /**
  27. * Find the gravitational influence two moons have on each other
  28. *
  29. * @param {Vector3} moonA The first moon to consider
  30. * @param {Vector3} moonB The second moon to consider
  31. *
  32. * @returns {void}
  33. */
  34. function calculateGravity(moonA, moonB) {
  35. }