Semi-analytic impedance modeling of three-dimensional photonic and metamaterial structures