POV-Ray : Newsgroups : povray.beta-test.binaries : Function / pattern issues. Adding f_remap. Server Time10 Sep 2024 13:27:54 EDT (-0400)
 Function / pattern issues. Adding f_remap. (Message 1 to 1 of 1)
 From: William F Pokorny Subject: Function / pattern issues. Adding f_remap. Date: 10 Apr 2020 07:19:40 Message: <5e90564c@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#5e90564c%40news.povray.org",
"dateCreated": "2020-04-10T11:19:40+00:00",
"datePublished": "2020-04-10T11:19:40+00:00",
"author": {
"@type": "Person",
"name": "William F Pokorny"
}
}
Previous related postings:

and

max(Fn01(x,y,z)-VarThickness/2.0,-Fn01(x,y,z)-VarThickness/2.0)

for creating isosurface shells; shells of negative value. If you want
more than one shell based on the same function, it can be done, but in
the simplest linear function forms, it ends up that the shell at 0.0 is
twice the 'thickness' of all the others. The set up is also messy.

To help added a new inbuilt f_remap function to povr.

#declare f_remap = function { internal(3) }
// Parameters:
// 1. Incoming value to remap to weighted triangular peaked
// wave -1 to 1 to -1.
// 2. Number of triangle peaks in values remap. Min of 2.
// 3. Threshold for shell values. 0.0 returns weighted
// triangular values. When > 0.0 negative, normalized negative value
// shells created around the 2-8 values specified with
// parameters [4-11].
// 4-11 values to consider 0 points between peaks. Max of 8.

--- Upper left image
Used to displace the y plane via:

#declare Fn00 = function { f_gradient(x,y,z,1,0,0.5) }
#declare Fn01 = function {
f_remap(Fn00(x,y,z),3,0.0,
-1.0,0.0,0.5,2.0,
100,100,100,100)
}
#declare Fn03 = function { y + Fn01(x,y,z)*0.25 }

it generates the upper left image. It remaps values so as to have 0
crossings at the 2-8 values specified. Given the f_gradient input (and
yes, that is a new inbuilt function too replacing the three X,Y,Z only
functions.inc forms), we end up with ramps into and out of the 0
crossing which themselves peak in a triangular fashion at -1 and 1 values.

--- Upper right mage
Using a normal-ish approach to get shells (here walls) at the zero
values we use:

#declare Fn02 = function {
max(Fn01(x,y,z)-VarThickness/2.0,
-Fn01(x,y,z)-VarThickness/2.0) }

and get the upper right result where though the shells now all two sided
they still change widths due the differences in ramps into and out of
the zero regions.

--- Lower left image
Here we pass the VarThickness threshold to the f_remap function. It
creates the shells while normalizing to the steepest ramp from 1 or -1
into any 0 value. The use code for this looks like:

#declare Fn00 = function { f_gradient(x,y,z,1,0,0) }
#declare VarThickness = 0.15;
#declare Fn01 = function {
f_remap(Fn00(x,y,z),3,VarThickness,
-1.0,0.0,0.5,1.2,
100,100,100,100)
}

with Fn01 used directly in the isosurface function. Result in the lower
left.  Yes, for less linear input functions the shell/width thicknesses
are still going to vary even with normalization - but substantially less so.

--- Lower right image...
Playing with the value difference between noise generator 2 and 3 as
wondered about in the recent posting to p.b.i. The code for that looks like:

#declare Fn00 = function {
f_snoise3d(x-2/2,y/2,z/2,2)-
f_snoise3d(x-2/2,y/2,z/2,3)
}
#declare VarThickness = 0.02;
#declare Fn01 = function {
f_remap(Fn00(x,y,z),5,VarThickness,
-0.6,-0.3,0.0,0.3,0.6,
100,100,100)
}

and the result is shown in the lower right. Yes, f_snoise3d is now
inbuilt and requires the noise generator to be set.

Bill P.
```

Attachments:

Preview of image 'f_remapstory.png'