Do we know how close we can settle to other capitals without pissing off the AI?

Basically what the title says. Is there a set amount of tiles you should keep between your new settlement and the AIs if you want to avoid relationship penalties? And does it only apply to their capital or all cities?

And actually, come to think of it; since relationships are mutual, is there any reason to avoid it? I mean, if you avoid settling too close to them, then probably they will just grab the same spot instead and spark a diplomatic incident either way, no?