POV-Ray : Newsgroups : povray.general : Minimum Distance Function : Minimum Distance Function Server Time
15 Aug 2022 09:26:36 EDT (-0400)
  Minimum Distance Function  
From: jceddy
Date: 6 Jul 2022 16:15:00
Message: <web.62c5ec8895296eb4864166f75d51d79c@news.povray.org>
I've implemented a Minimum Distance algorithm that estimates the minimum
distance from any point and the surface of an object.

The reason I implemented it is so that I could use it inside an "internal"
function that I can then use in the definition of (for example) and isosurface.

The algorithm does a really short "brute force", checking vectors in a bunch of
directions from the point, and finding the shortest distance in any of those
directions (if there is actually a "hit" in any of those directions), in order
to get an initial estimate, then uses simulated annealing to improve the

I have a few questions that are really specific to the development team:

Is there already functionality implementing a minimum distance to an arbitrary
object that I missed? I looked for one, but haven't actually asked directly.

Is this something that could work its way back into the povray code? I was
thinking that I would add a class to implement the simulated annealing in a
general way, a minimum distance implementation, and "internal" function to call
it from POV STL, and then probably a minimum distance pattern that would work
similar to the existing object pattern, except it wouldn't have sharp edges at
the object boundary. Where would be the preferred place to stick the simulated
annealing class? Is that the kind of thing that would go under Core/Math?

I am still playing with it a bit, but am thinking that if it might be useful for
other folks, I should do it "right" so I can submit it over on github.

I've included an attachment showing some of the testing I have been doing while
using the function to define an isosurface. In the two images, the object in the
center is just an object rendered directly, on the left is the object rendered
as an isosurface using a pigment pattern as the defining function (of course it
is terrible, due to the infinite gradient at the object surface), and on the
right the the object rendered as an isosurface using the minimum distance
function with a very short annealing period (BTW, the function flips the sign to
negative for points inside the object, so you have a clean 0.0 threshold at the
surface of the object).

Post a reply to this message

Download 'test_both.png' (118 KB)

Preview of image 'test_both.png'


Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.