|
|
On 1/2/24 07:34, Bald Eagle wrote:
> Rather than puzzling out single-use formulas for doing such a conversion, it
> would be extremely convenient, especially to new users, to have a set if inbuilt
> functions specifically for this purpose.
>
> A basic set of formulas, proposed by Freya Holmer
> https://www.youtube.com/watch?v=NzjF1pdlK7Y
> is suggested for use below:
> //------------------------------------------------------------------------
>
> // Freya Holmer
> #declare Lerp = function (Start, End, Value) {(1 - Value) * Start + (End *
> Value)}
>
> #declare InvLerp = function (Start, End, Value) {(Value - Start) / (End -
> Start)}
>
> #declare ReMap = function (OldMin, OldMax, NewMin, NewMax, Value) {Lerp
> (NewMin, NewMax, InvLerp (OldMin, OldMax, Value) )}
>
> //------------------------------------------------------------------------
>
> While hunting down this code, I found a functions.inc file by WFP that had some
> internal remapping functions (presumably for use in isosurfaces in povr/yuqk)
> but the accompanying documentation was pretty complex, dense and hard to follow,
> but it suggests that there are other remapping schemes may be desirable.
Yuqk's functions.inc documents a f_range2range() inbuilt which is likely
equivalent to the the 'Remap' function above - though the value is the
first parameter rather than the last.
Yes, yuqk's f_remap() is somewhat complicated. It could be used for one
range to range pair, but it's aimed more at creating multiple roots
(more particularly, isosurface shells) at particular value locations
within an existing functions value's overall range. For example,
multiple shells within f_sphere()'s return values where we'd normally be
able to create only one shell about f_sphere()'s radius value / single
root.
Providing inbuilt function(s?) for common interpolation methods is a
good idea. Some time ago Ingo coded up an include with a largish set of
gradients / interpolation methods. My aim is to someday create a
f_interpolation() inbuilt which encapsulated most (or all?) of those and
probably others. Maybe I'll at least create an initial version when I go
after those additional 3x, 21 bit float functions...
I have started a directory of examples for the inbuilt functions which
is shipped in the examples tar ball. Overall progress is admittedly slow.
Aside: I have large collection of scene files for playing with / testing
the inbuilt functions, but those are mostly not good examples as coded.
Plus, quite a few no longer work because of later yuqk changes...
Aside: The functions.inc file has a self test section at the bottom with
the functions coded up for sanity testing purposes. That testing code
sometimes works as decent example code.
Anyhow. In general, I agree with the suggestions in your post! :-)
Bill P.
Post a reply to this message
|
|