123456789101112131415161718192021222324252627282930313233343536373839404142 |
- const Vector3 = require("./Vector3");
- module.exports = class Moon {
- /**
- * @param {Vector3} position The starting position of the moon
- */
- constructor(position) {
- /**
- * The position of the moon in space
- */
- this.position = position;
- /**
- * The position of the moon at the time of creation
- *
- * This is a silly trick to get a clean copy of the Vector, but it works.
- *
- * @private
- */
- this._initialPosition = position.negate().negate();
- /**
- * The current velocity of the moon
- */
- this.velocity = new Vector3(0, 0, 0);
- }
- /**
- * Check whether or not the moon has returned to its initial position
- *
- * @returns {bool} True if the current position is the same as the initial position and if the velocity is zero
- */
- hasReachedInitialState() {
- return (
- this._initialPosition.x == this.position.x
- && this._initialPosition.y == this.position.y
- && this._initialPosition.z == this.position.z
- ) && (
- this.velocity.x == 0
- && this.velocity.y == 0
- && this.velocity.z == 0
- );
- }
- };
|