POV-Ray : Newsgroups : povray.general : Roots of a function : Re: Roots of a function Server Time
20 Apr 2024 08:34:46 EDT (-0400)
  Re: Roots of a function  
From: William F Pokorny
Date: 28 Sep 2019 09:26:40
Message: <5d8f5f90$1@news.povray.org>
On 9/28/19 8:08 AM, Bald Eagle wrote:
> 
> "IGM" <iar### [at] gmailcom> wrote:
>> Hi,
>> I have a monotone function y=(x) defined as spline (it describes the position of
>> an object in the scene), and I need to find its root, i.e. where it crosses x
>> axis. Is there any elegant way to do this inside povray? Maybe I could transform
>> the function in a prism surface, and using "trace" to find the intersection of a
>> ray at height y=0 with the surface. Other ideas?
>>
>> Thanks!
>> igmar
> 
> You could do it the typical algebraic way and solve for x, where y=0.
> You could do it numerically, where you use a #for loop and choose an increment
> for x, evaluating the function and checking each iteration to see if y<= some
> small amount.
> If you actually want to harness [one or more of] POV-Ray's internal root
> solvers, that's currently William Pokorny's domain.
> 
> If you want to do it "graphically", maybe you could do something like define a
> cylinder for the x-axis, and a sphere-sweep for the function, and do an
> intersection{}.  Then maybe use trace () and/or eval_pigment to find those
> regions, replace with spheres encompassing those regions, redo the intersections
> and find the center of the bounding box.   Iterate to a small value.
> 
> 
> There are also online equation root solvers that you can just plug in your
> equation, and it will spit the answer out from the black box.  :D
> 
> That's all I've got [so far] pre-1st-coffee.
> 
> 
Good suggestions though the first hard I think if not a linear spline. 
Nothing simpler than what's been suggested comes to mind for the 
question posed. I should first go grab my second cup...

POV-Ray's internal common solvers to which Bill refers are not directly 
accessible in the scene language except I think in one of the hgpovray 
releases. If remembering correctly, I'm not sure the feature is today in 
the most current hgpovray38. If it is there, you'd have to be careful 
using these even if your function was set up as a uni-variate power 
polynomial and it's not - you have some spline. Further, the internal 
solvers are set up for ray tracing, not general root solving (and there 
are bugs too). I'd not recommend using them as general solvers even with 
the right form of polynomials.

To your ideas I'd add using the function in an isosurface with the 
default threshold of 0. Something as simple as FnIso being z-Fn(x) 
should create shape edges where the spline based function crosses zero - 
which you'd then need to find with trace or some other method. This can 
be complicated too if your spline isn't 'well behaved' with respect to 
gradients and continuity. Some sort of pigment based solution might be 
more robust.

A site and web search might be worthwhile. I remember Tor Olav 
Kristensen creating a simplex solver (for min, max) some while ago in 
the SDL. Expect somebody, at some time past, has gone after a problem 
similar to yours. Quickly finding previous work of a type can be a 
difficult trick though.

Bill P.


Post a reply to this message

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