3 ms·
I guess it's not important to the rendering, but it would be nice if the author explained what "signed distance function" is specifically. * The distance to th
by quietbritishjim 4y ago
I guess it's not important to the rendering, but it would be nice if the author explained what "signed distance function" is specifically.
* The distance to the boundary of a circle is abs(sqrt(x*2 + y*2) - radius) ... so as you would expect on the outside, but it's also positive on the inside of the circle
* The distance to the circle is max(0, sqrt(x*2 + y*2) - radius) ... so as you would expect on the outside, but it's 0 on the inside
* The signed distance function of the circle is sqrt(x*2 + y*2) - radius ... so as you would expect on the outside, but it's negative on the inside
Technically the regular distance function would do for the flat looking rendering in the article but you have to calculate the signed distance function on the way there first anyway.
But the signed distance function does have a lot of interesting features you can't recover from the regular distance function [1]. One is that you can recover the surface normal from it by taking the gradient - exactly what was used for getting the normal vector in the article! Another property, not relevant here but very nice, is you can use (point on surface, signed distance) as a coordinate system in the space near to the surface. This gives you a nice formula for the integral of a function in a vicinity of the surface.
[1] https://en.wikipedia.org/wiki/Signed_distance_function#Properties_in_Euclidean_space https://en.wikipedia.org/wiki/Signed_distance_function#Prope...
- moonchild 4y ago> The distance to the circle is max(0, sqrt(x*2 + y*2) - radius) ... so as you would expect on the outside, but it's 0 on the inside That is the distance to a disc.
- quietbritishjim 4y agoOops you are right! That's a depressing reminder how long it's been since I was a research mathematician (when I wouldn't have made that mistake... probably). In fairness, "circle" is fairly often used to refer to the 2d shape, even sometimes in real maths contexts e.g. "squaring the circle" in classical geometry is never referred to as "squaring the disc". In fact I suspect use of "circle" to refer exclusively to the 1d boundary probably comes a very long time after the word first existed in the English language. And even when I was a research mathematician, I never would've corrected someone if it was really clear from the context that they were talking about the 2d shape (which, to be honest, is true of my comment above).