Let's say that I have some function $f(x,y,z)$ representing an implicit surface.
For instance it might be the equation of a sphere like below, but could also be many other types of functions / shapes.
$f(x,y,z) = (x^2+y^2+z^2)^{0.5} - 0.5 = 0$
If I have a point that I know to be on the surface, what is the correct way to get a vector that is perpendicular to the surface (aka the surface normal)?
I've tried normalizing the vector made up of partial derivatives of x, y and z, but that seems to be failing for some situations.
It's difficult to provide specifics of what is failing specifically, but I'm curious, is that the correct way? or is it a problem that I really have an equation like the below with an implicit variable $w$ that I'm not taking into account in the gradient calculation?
$w=f(x,y,z)$