Completely square is easy - place the habitat gate first, turn on angle snap, and make your barrier. As long as you don't alter the length of the barrier as you're placing it you should be able to turn at right angles on the corners and make a perfect square.