POV-Ray : Newsgroups : povray.general : Minimum Distance Function : Re: Minimum Distance Function Server Time
15 Aug 2022 09:45:22 EDT (-0400)
  Re: Minimum Distance Function  
From: jceddy
Date: 9 Jul 2022 12:10:00
Message: <web.62c9a7ca6fb4e448864166f75d51d79c@news.povray.org>
> So today, I verified that you can, indeed, get at the underlying Mesh data if
> the object *is a* Mesh. So, in that case, given the Vertex/Triangle data in the
> Mesh, along with the transformation matrix (also easy to get), you should be
> able to implement a fast and accurate minimum-distance calculation by applying
> the inverse of the object's transformation matrix to the test point (to get the
> point in the same coordinates as the original mesh data...I THINK???), and then
> doing some math.

Been working on the math. Added a couple of things to the mesh's data that can
be computed and cached as needed:

1) A kd-tree of the vertex data (makes it easy to quickly query the nearest mesh
vertex to a point).
2) A list of triangles for each vertex index. So ones you query the nearest
vertex, you can immediately get a list of triangles with that vertex.

Working on the code to check the minimum distance for each triangle touching
with the nearest vertex...that should be the minimum distance to the mesh.

The next thing will be handling transformations...I realized this morning that I
can't just apply an inverse transform to the point being tested...this won't
work for scale and shear transformations. I think I will need to actually
generate and cache a version of the mesh data with the object transformations
applied, and then use THAT mesh data for calculating minimum distance.

Anyway, one step at a time.

Also, I am thinking about changing "minimum_distance" to "proximity", as it
feels perhaps more succinct? Yea or nay?


Post a reply to this message

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