Plot in Octave of Integral on unit circle $\int_{-\pi}^\pi \frac{(1-r^2)\cos(x)}{1-2r \cos(\theta-x)+r^2}dx $ i want to get a 3D Plot in Octave of the function
$$f(r\cdot e^{i\theta})=\int_{-\pi}^\pi \frac{(1-r^2)\cdot\cos(x)}{1-2\cdot r\cdot\cos(\theta-x)+r^2}dx $$
what is called the Poisson-Integral for the function $\cos(x)$ for $0\leq r<1$. I really don't know how to get it and didn't find any answers in the internet. so maybe someone can help me.
Until now i got the following code but the output is far away from what i need:
r = linspace(0,0.999,10)
theta = pi*linspace(-1,1,10)
z = r.*exp(1i*theta)
[Y1,Y2]=meshgrid(sqrt(real(z).^2+imag(z).^2),imag(z))
for i=1:10
  for j=1:10
    n=Y1(i,j)
    m=Y2(i,j)
    y=@(x) (1-n.^2).*cos(x)/(1-2.*n.*cos(m-x)-n.^2)
    Z(i,j)= quad(y,-pi,pi)
  end
end

plot3(real(z),imag(z),Z)

I'm thankful for every answer or try to help me.

Let $t= x -\theta$
\begin{align}
\int_{-\pi}^\pi \frac{(1-r^2)\cos x}{1-2r\cos(\theta-x)+r^2}dx
=&(1-r^2) \int_{-\pi-\theta}^{\pi -\theta}\frac{\cos t\cos\theta- \sin t \sin\theta}{1-2r\cos t+r^2}dt\\
 =& 2\cos\theta (1-r^2)\int_{0}^{\pi}\frac{\cos t}{1-2r\cos t+r^2}dt\\=& 2\pi r\cos\theta
\end{align}
where, with $y=\tan\frac t2$
\begin{align}
&\int_{0}^{\pi}\frac{\cos t}{1-2r\cos t+r^2}dt
 =\frac{1}{2r}\left(-\pi+  \frac{2(1+r^2)}{(1+r)^2} \int_{0}^{\infty}\frac{dy}{y^2+ \left(\frac{1-r}{1+r}\right)^2}\right)
=\frac{\pi r}{1-r^2}
\end{align}
