POV-Ray : Newsgroups : povray.general : Minimum Distance Function : Re: Minimum Distance Function Server Time15 Aug 2022 09:48:19 EDT (-0400)
 Re: Minimum Distance Function
 From: jceddy Date: 12 Jul 2022 10:00:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.62cd7d6f6fb4e448864166f75d51d79c%40news.povray.org",
"dateCreated": "2022-07-12T14:00:00+00:00",
"datePublished": "2022-07-12T14:00:00+00:00",
"author": {
"@type": "Person",
"name": "jceddy"
}
}
> FYI. A chance the following inside_vector issue in play.
>
> "Leaving mesh inside_vector untouched on transforms."
> https://github.com/POV-Ray/povray/pull/361
>

That merge request changes the inside_vector test to use MInvTransPoint instead
of MInvTransRay followed by a Normalize, which makes sense to me.

In the version where I don't transform the mesh vertex data, I am doing
MInvTransPoint to tranform the test point, computing the minimum distance Vector
from the transformed test point to the original mesh data, then using
MInvTransDirection to transform that Vector using the mesh's Trans, then using
the length of the transformed vector as the distance.

The result obtained this way is a lot worse.

I wonder if there are cases where it would actually get a *wrong* answer, not
just loss of precision...such as the case where the object is scaled
non-uniformly. I think you can come up with an easy example where this is the
case where a "fat" ellipse that has a larger diameter in the x/y plane is scaled
such that it has a larger diameter in the x/z plane. Looking at the point at the
center of the ellipse, the minimum distance direction vector would switch from
<1, 0, 0> to <0, 1, 0> (for example).
```