I'm trying to find the z component of a unit normal of a plane given the x and y components.

Since it's a unit normal I know that I have \(\displaystyle n_x^2 + n_y^2+n_z^2 = 1\), therefore, \(\displaystyle n_z = \sqrt{1 - n_x^2 - n_y^2}\).

This seems fine in testing, until a case where \(\displaystyle n_z\) should be negative, at which point the world breaks! Am I doing something stupid here? It's worth mentioning that I'm doing this as part of an image-plane to world-plane correction and as such don't have any coordinates of points on the world-plane itself. The only information I have is a set of image-plane coordinates.

Thanks!