public void accelerate() {
        
        double accelRate = baseAccelRate;
        double currentMagnitude = Math.sqrt(dx*dx + dy*dy);

        if (isBoosting) {
            accelRate *= 2;
        } else if (this instanceof Ship && currentMagnitude < accelRate) {
            // If currently travelling slowly, then accelerate slowly.
            accelRate *= .2;
        }

        // Determining new velocity: Take the vector representing the current
        // velocity and the vector representing the addition of this increment
        // of acceleration, and add them together. If the magnitude of this
        // new vector is less than or equal to maxVelocity, we're done. If it's
        // greater, then we need to find the vector with length maxVelocity and
        // with direction of the sum vector. (Another way to visualize this is
        // where the sum vector intersects a circle with radius maxVelocity.)

        // Take the vector representing the current velocity...
        double startDX = dx,
               startDY = dy;
        // and the vector representing the addition of this increment of
        // acceleration...
        double accelDX = Math.cos(angle) * accelRate,
               accelDY = Math.sin(angle) * accelRate;
        // and add them together.
        dx += accelDX;
        dy += accelDY;
        // If the magnitude of this new vector...
        double newMagnitude = Math.sqrt(dx*dx + dy*dy);
        // is less than or equal to maxVelocity, we're done. If it's greater...
        if ((newMagnitude > maxVelocity && !isBoosting)
            || newMagnitude > maxVelocity * 2) {
            // then we need to find the vector with length maxVelocity and with
            // direction of the sum vector.
            double theta = Math.atan(dy/dx);
            if (dx < 0)
                theta += Math.PI;
            dx = Math.cos(theta) * maxVelocity;
            dy = Math.sin(theta) * maxVelocity;
        }
    }