POV-Ray : Newsgroups : povray.general : Minimum Distance Function : Re: Minimum Distance Function Server Time
28 Mar 2024 07:16:34 EDT (-0400)
  Re: Minimum Distance Function  
From: jceddy
Date: 11 Jul 2022 17:30:00
Message: <web.62cc95526fb4e448864166f75d51d79c@news.povray.org>
> What if instead of re-transforming the mesh data, you transform the reference
> point to measure the length?
> Then it's only ever one transform in either direction.
>

That is exactly what I tried, if I am understanding you.

I want to find the distance from point P to mesh M (which contains
vertex/triangle data as well as a transformation).

So I tried basically this:


P_inv = InverseTransformPoint(P, M->Trans)
N = NearestPoint(P_inv, M->Data)
V = N - P_inv  // get the vector from P_inv to N
V_trans = TransformDirection(V, M->Trans)

If(Inside(P, M))
  distance = -Length(V_trans)
Else
  distance = Length(V_trans)


....and the result was much worse than finding the distance from point P to mesh
M (which contains transformed vertex/triangle data), but doing this:


N = NearestPoint(P, TransformAllVertices(M->Data, M->Trans))
V = N - P

If(Inside(P, M))
  distance = -Length(V)
Else
  distance = Length(V)



I mean, obviously the second one looks cleaner, as well, but it hides all the
code required to make sure M->TransformedData is there to use.


Post a reply to this message

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