public void setMagnitude(double magnitude)
    {
        double scalar;

        // If the vector is zero, create it with an angle of zero.
        if (_y == 0 && _x == 0)
        {
            _x = magnitude;
        }

        scalar = Math.abs(magnitude) / getMagnitude();
        _x *= scalar;
        _y *= scalar;
    }