change rectangle with segment intersection