Blender Cycle's z-coordinate vs. camera-centered z-coordinate (orthogonal distance)

Rendering a scene and writing the 'Z-buffer' into an EXR file using 'Blender Cycles', I get a depth map. That depth map differs from the depth map which is produced by 'Blender Render'. Given its shape, I was assuming that the depth map corresponds to the 'sight ray's length'. However, that did not work out.

I derived my formula as follows:

ys [px]: y-coordinate of the pixel
cy [px]: y-coordinate of the principal point.
d  [m/px]: density, i.e. length / pixel on the camera sensor
(y_size [m] / y_size [px])
f  [m]:  focal length
zs [m]:  length of the 'sight ray'
zc [m]:  orthogonal distance to lense's plane
(z-coordinate in camera centered coordinates)


Then,

$$z_c=z_s\cos(\alpha)$$

assume

$$\alpha=\arctan\frac{(c_y-y_s)d}{f}$$

applying

$$\cos\arctan(x)=\frac{1}{\sqrt{1+x^2}}$$

delivers

$$z_c=\frac{fz_s}{\sqrt{f^2+(y_s-c_y)^2d^2}}$$

But, that does not seem to work out. What am I doing wrong? What would be the formula?

The aforementioned formula is the correct, only that Blender provides the depth at $(x+0.5, y+0.5)$ at pixel $(x, y)$. The general solution is
$$z_c=\frac{fz_s}{\sqrt{f^2+((c_x-x)^2+(c_y-y)^2)d^2}}$$
$$z_c=\frac{fz_s}{\sqrt{f^2+((c_x-x-0.5)^2d_x^2+(c_y-y-0.5)^2)d^2}}$$
$$z_c=\frac{fz_s}{\sqrt{f^2+(c_x-x-0.5)^2d_x^2+(c_y-y-0.5)^2d_y^2}}$$