POV-Ray : Newsgroups : povray.general : Roots of a function : Re: Roots of a function Server Time
26 Apr 2024 06:16:11 EDT (-0400)
  Re: Roots of a function  
From: Tor Olav Kristensen
Date: 29 Sep 2019 18:25:01
Message: <web.5d912de6b127c26fb701681f0@news.povray.org>
"IGM" <iar### [at] gmailcom> wrote:
> This is my poor-man solution:
>
> // root(s) of function F = Y(X)-thr
>...

If your function is strictly monotone you can just define another linear spline
with the values switched at each index, like this:


#version 3.7;

#declare NoOfPoints = 10;

#declare X =
    array [NoOfPoints] {
        0,
        10,
        20,
        30,
        40,
        50,
        60,
        70,
        80,
        90
    }
;
#declare Y =
    array [NoOfPoints] {
        0.0,
        21.0,
        44.0,
        69.0,
        97.0,
        124.0,
        158.0,
        181.0,
        206.0,
        232.0
    }
;
#declare Spline =
    spline {
        linear_spline
        #for (I, 0, NoOfPoints-1)
            X[I], Y[I]*y
        #end // for
    }

#declare ReverseSpline =
    spline {
        linear_spline
        #for (I, 0, NoOfPoints-1)
            Y[I], X[I]*x
        #end // for
    }

#declare Thr = 35;

#declare Root = ReverseSpline(Thr).x;

#debug "\n\n"
#debug concat("Root: ", str(Root, 0, -1))
#debug "\n\n"

#error "To stop text output and prevent render window"

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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